[flexcoders] Re: looping through xml (newbie question)

2009-02-10 Thread annelie2008
Thanks for this, I ended up stripping out the namespaces instead as I 
don't need them (and I couldn't actually make it work), but it's a 
big help to know it was the namespaces creating the problem and if I 
do need them in the future I know what I need to read up on.

Thanks!

Annelie


--- In flexcoders@yahoogroups.com, Tracy Spratt tspr...@... wrote:

 You have a default xml namespace you need to deal with.  Try:
 
 default xml namespace =
 http://schemas.microsoft.com/winfx/2006/xaml/presentation;;
 
  
 
  I see another namespcae declared, x, but it does not appear to be
 used.
 
  
 
 Check the archives and docs for more information about xml 
namespace.
 
  
 
 Tracy Spratt 
 Lariat Services 
 
 Flex development bandwidth available 
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:flexcod...@yahoogroups.com] On
 Behalf Of annelie2008
 Sent: Monday, February 09, 2009 7:34 AM
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] looping through xml (newbie question)
 
  



[flexcoders] Re: Displaying UIComponents vertically

2009-02-09 Thread annelie2008
Turns out it was my fault entirely, I hadn't checked the xml code 
properly and assumed it was supposed to give me three vertically 
stacked staves but it was actually showing them horizontally. I will 
check more properly before posting a question in the future.

Thanks for answering though!

Annelie

--- In flexcoders@yahoogroups.com, Alex Harui aha...@... wrote:

 Each child of VBox must report have either its measuredWidth/Height 
or explicitWidth/Height set, otherwise the VBox doesn't know how big 
they are
 
 Alex Harui
 Flex SDK Developer
 Adobe Systems Inc.http://www.adobe.com/
 Blog: http://blogs.adobe.com/aharui




[flexcoders] looping through xml (newbie question)

2009-02-09 Thread annelie2008
Hi,

I'm trying to loop through my xml, but I'm having some problems. I 
thought this would give me all the line nodes, but it's empty:

var xmlLines:XMLList = myXmlList..Line;

Is that the right way to go about it, or is there another way?

Xml code is below.

Many thanks,

Annelie

--
?xml version=1.0 encoding=UTF-16?
Canvas Margin=5,12,0,0 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; 
xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml;
Canvas Tag=Measure
Line X1=0 Y1=0 X2=0 Y2=20 Stroke=Black 
StrokeThickness=0.3 /
Line X1=350 Y1=0 X2=350 Y2=20 Stroke=Black 
StrokeThickness=0.3 /
Canvas Tag=Column
Line X1=0 Y1=0 X2=350 Y2=0 
Stroke=Black StrokeThickness=0.3 /
Line X1=0 Y1=5 X2=350 Y2=5 
Stroke=Black StrokeThickness=0.3 /
Line X1=0 Y1=10 X2=350 Y2=10 
Stroke=Black StrokeThickness=0.3 /
Line X1=0 Y1=15 X2=350 Y2=15 
Stroke=Black StrokeThickness=0.3 /
Line X1=0 Y1=20 X2=350 Y2=20 
Stroke=Black StrokeThickness=0.3 /
Canvas 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; /
Glyphs Tag=1Et Width=14 Height=55.5 
Fill=#FF00 FontRenderingEmSize=14 UnicodeString=q 
Canvas.Left=58 Canvas.Top=10 /
Canvas 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; /
Glyphs Tag=1Et Width=14 Height=55.5 
Fill=#FF00 FontRenderingEmSize=14 UnicodeString=q 
Canvas.Left=116 Canvas.Top=-2.5 /
Canvas 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; /
Glyphs Tag=1Et Width=14 Height=55.5 
Fill=#FF00 FontRenderingEmSize=14 UnicodeString=h 
Canvas.Left=174 Canvas.Top=2.5 /
/Canvas
/Canvas
Canvas Tag=Measure
Line X1=350 Y1=0 X2=350 Y2=20 Stroke=Black 
StrokeThickness=0.3 /
Line X1=700 Y1=0 X2=700 Y2=20 Stroke=Black 
StrokeThickness=0.3 /
Canvas Tag=Column
Line X1=350 Y1=0 X2=700 Y2=0 
Stroke=Black StrokeThickness=0.3 /
Line X1=350 Y1=5 X2=700 Y2=5 
Stroke=Black StrokeThickness=0.3 /
Line X1=350 Y1=10 X2=700 Y2=10 
Stroke=Black StrokeThickness=0.3 /
Line X1=350 Y1=15 X2=700 Y2=15 
Stroke=Black StrokeThickness=0.3 /
Line X1=350 Y1=20 X2=700 Y2=20 
Stroke=Black StrokeThickness=0.3 /
Canvas 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; /
Glyphs Tag=1Et Width=14 Height=55.5 
Fill=#FF00 FontRenderingEmSize=14 UnicodeString=w 
Canvas.Left=408 Canvas.Top=2 /
/Canvas
/Canvas
Canvas Tag=Measure
Line X1=700 Y1=0 X2=700 Y2=20 Stroke=Black 
StrokeThickness=0.3 /
Line X1=1050 Y1=0 X2=1050 Y2=20 
Stroke=Black StrokeThickness=0.3 /
Canvas Tag=Column
Line X1=700 Y1=0 X2=1050 Y2=0 
Stroke=Black StrokeThickness=0.3 /
Line X1=700 Y1=5 X2=1050 Y2=5 
Stroke=Black StrokeThickness=0.3 /
Line X1=700 Y1=10 X2=1050 Y2=10 
Stroke=Black StrokeThickness=0.3 /
Line X1=700 Y1=15 X2=1050 Y2=15 
Stroke=Black StrokeThickness=0.3 /
Line X1=700 Y1=20 X2=1050 Y2=20 
Stroke=Black StrokeThickness=0.3 /
Canvas 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; /
Glyphs Tag=1Et Width=14 Height=55.5 
Fill=#FF00 FontRenderingEmSize=14 UnicodeString=h 
Canvas.Left=758 Canvas.Top=0 /
Canvas 
xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation; /
Glyphs Tag=1Et Width=14 Height=55.5 
Fill=#FF00 FontRenderingEmSize=14 UnicodeString=h 
Canvas.Left=874 Canvas.Top=0 /
/Canvas
/Canvas
/Canvas
--



[flexcoders] Displaying UIComponents vertically

2009-02-05 Thread annelie2008
Hi,

I'm having trouble with the layout of the musical score I'm 
displaying. It's generated from an xml file and I want the staves to 
be placed on top of each other but I can't make it work. I have a 
class which draws out the lines and the notes on it, so I instantiate 
that class, create the lines and notes, then create a UIComponent to 
add it to. There's three staves, so I do this for all three, then I 
add them all to a VBox which I display. I thought this would mean 
they'd be stacked on top of each other, but they're horizontally 
placed (the second two a little bit lower than the first for some 
reason). I'm assuming I'm missing something really obvious, so I'd be 
grateful if anyone could point me in the right direction.

Here's the code:
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; 
layout=vertical
initialize=initializeHandler()
horizontalAlign=left

mx:Script
![CDATA[
import mx.containers.HBox;
import mx.containers.VBox;
import mx.containers.Canvas;
import mx.core.UIComponent;
import test.DrawNotes;

public var myXmlList:XMLList;

private function initializeHandler():void
{
//myXmlList = scoreXml.children();
// loop through this xml to get the 
attributes for the lines and fonts, but for now just hardcode it

// MEASURE 1
var measure1:DrawNotes = new DrawNotes
();

measure1.createLine(0, 0, 0, 
20, Black, 0.3, );
measure1.createLine(350, 0, 350, 
20, Black, 0.3, );

measure1.createLine(0, 0, 350, 
0, Black, 0.3, );
measure1.createLine(0, 5, 350, 
5, Black, 0.3, );
measure1.createLine(0, 10, 350, 
10, Black, 0.3, );
measure1.createLine(0, 15, 350, 
15, Black, 0.3, );
measure1.createLine(0, 20, 350, 
20, Black, 0.3, );
measure1.createGlyph(1Et, 14, 
55.5, #FF00, 14, q, , 58, 10, );
measure1.createGlyph(1Et, 14, 
55.5, #FF00, 14, q, , 116, -2.5, );
measure1.createGlyph(1Et, 14, 
55.5, #FF00, 14, h, , 174, 2.5, );

// MEASURE 2
var measure2:DrawNotes = new DrawNotes
();
measure2.createLine(350, 0, 350, 
20, Black, 0.3, );
measure2.createLine(700, 0, 700, 
20, Black, 0.3, );
measure2.createLine(350, 0, 700, 
0, Black, 0.3, );
measure2.createLine(350, 5, 700, 
5, Black, 0.3, );
measure2.createLine(350, 10, 700, 
10, Black, 0.3, );
measure2.createLine(350, 15, 700, 
15, Black, 0.3, );
measure2.createLine(350, 20, 700, 
20, Black, 0.3, );
measure2.createGlyph(1Et, 14, 
55.5, #FF00, 14, w, , 408, 2, );

// MEASURE 3
var measure3:DrawNotes = new DrawNotes
();
measure3.createLine(700, 0, 700, 
20, Black, 0.3, );
measure3.createLine(1050, 0, 1050, 
20, Black, 0.3, );
measure3.createLine(700, 0, 1050, 
0, Black, 0.3, );
measure3.createLine(700, 5, 1050, 
5, Black, 0.3, );
measure3.createLine(700, 10, 1050, 
10, Black, 0.3, );
measure3.createLine(700, 15, 1050, 
15, Black, 0.3, );
measure3.createLine(700, 20, 1050, 
20, Black, 0.3, );
measure3.createGlyph(1Et, 14, 
55.5, #FF00, 14, h, , 758, 0, );
measure3.createGlyph(1Et, 14, 
55.5, #FF00, 14, h, , 874, 0, ); 

var uic1:UIComponent = new UIComponent
();
uic1.addChild(measure1);

var uic2:UIComponent = new UIComponent
();
uic2.addChild(measure2);

var uic3:UIComponent = new UIComponent
();

[flexcoders] newbie question - call to actionscript class

2009-01-29 Thread annelie2008
Hello,

I'm brand new to Flex so I'm sure this is a very stupid question, but 
hopefully someone will be able to help.

My ultimate goal is to take an xaml file with a musical score and 
convert it to flex, but to start with I've hardcoded a score (or 
rather some score elements) in an actionscript class and I'm trying 
to call it from my main application file. When I debug I can see that 
it does get called, however nothing gets drawn on screen. I first did 
the hardcoded score in a project on its own, so I know that the score 
should be able to be displayed.

Here's the code:
?xml version=1.0 encoding=utf-8?
mx:Application xmlns:mx=http://www.adobe.com/2006/mxml; 
layout=absolute initialize=initializeHandler()

mx:Script
![CDATA[

import test.DrawNotes;

public var myXmlList:XMLList;

private function initializeHandler():void
{
myXmlList = scoreXml.children();

// loop through the xml here and call 
the relevant functions in DrawNotes

var notes:DrawNotes = new DrawNotes();
}

]]
/mx:Script

mx:XML id=scoreXml source=scoreCanvas.xml /

/mx:Application


Does anyone know what I'm doing wrong?

Many thanks,

Annelie



[flexcoders] Re: newbie question - call to actionscript class

2009-01-29 Thread annelie2008
I should probably have commented out that bit of code, it's not the 
xml I'm having problems with now (well, I have, but I'll get to those 
questions later). I thought that by calling my actionscript class, 
var notes:DrawNotes = new DrawNotes();, that would display my hard 
coded score on screen? I was going to loop through the xml later to 
go draw every specific element but for now I'm just trying to draw 
anything. Do I need to connect that to a visual element?

Cheers,

Annelie


--- In flexcoders@yahoogroups.com, Gregor Kiddie gkid...@... 
wrote:

 mx:XML ... / isn't a visual component. You'll need to use the XML 
as a
 dataprovider from something that is.
 
  
 
 Gk.
 
 Gregor Kiddie
 Senior Developer
 INPS
 
 Tel:   01382 564343
 
 Registered address: The Bread Factory, 1a Broughton Street, London 
SW8
 3QJ
 
 Registered Number: 1788577
 
 Registered in the UK
 
 Visit our Internet Web site at www.inps.co.uk
 blocked::http://www.inps.co.uk/ 
 
 The information in this internet email is confidential and is 
intended
 solely for the addressee. Access, copying or re-use of information 
in it
 by anyone else is not authorised. Any views or opinions presented 
are
 solely those of the author and do not necessarily represent those of
 INPS or any of its affiliates. If you are not the intended recipient
 please contact is.helpd...@...
 
 
 
 From: flexcoders@yahoogroups.com 
[mailto:flexcod...@yahoogroups.com] On
 Behalf Of annelie2008
 Sent: 29 January 2009 10:43
 To: flexcoders@yahoogroups.com
 Subject: [flexcoders] newbie question - call to actionscript class
 
  
 
 Hello,
 
 I'm brand new to Flex so I'm sure this is a very stupid question, 
but 
 hopefully someone will be able to help.
 
 My ultimate goal is to take an xaml file with a musical score and 
 convert it to flex, but to start with I've hardcoded a score (or 
 rather some score elements) in an actionscript class and I'm trying 
 to call it from my main application file. When I debug I can see 
that 
 it does get called, however nothing gets drawn on screen. I first 
did 
 the hardcoded score in a project on its own, so I know that the 
score 
 should be able to be displayed.
 
 Here's the code:
 ?xml version=1.0 encoding=utf-8?
 mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
 http://www.adobe.com/2006/mxml  
 layout=absolute initialize=initializeHandler()
 
 mx:Script
 ![CDATA[
 
 import test.DrawNotes;
 
 public var myXmlList:XMLList;
 
 private function initializeHandler():void
 {
 myXmlList = scoreXml.children();
 
 // loop through the xml here and call 
 the relevant functions in DrawNotes
 
 var notes:DrawNotes = new DrawNotes();
 }
 
 ]]
 /mx:Script
 
 mx:XML id=scoreXml source=scoreCanvas.xml /
 
 /mx:Application
 
 Does anyone know what I'm doing wrong?
 
 Many thanks,
 
 Annelie





[flexcoders] Re: newbie question - call to actionscript class

2009-01-29 Thread annelie2008
I tried addChild(notes); but that threw an error (Error #1034: Type 
Coercion failed: cannot convert test::drawno...@7218ca1 to 
mx.core.IUIComponent.). I googled a bit and it seems like you have to 
make it into a UIComponent first. I tried this:

var uic:UIComponent = new UIComponent;
uic.addChild(notes);

This doesn't do anything though, so maybe my actionscript code is 
wrong. I thought notes would be a Sprite, but maybe I need to do 
something more? Here's the actionscript class:

package test
{
import assets.Note;

import flash.display.Sprite;
import flash.text.*;

public class DrawNotes extends Sprite
{
[Embed(source=HELSINKI.TTF, fontFamily=HELSINKI)]
private var embeddedFont:String;

private var note1:Note;

public function DrawNotes()
{
super();

// I've removed it as it would make the code 
too long, but this calls a function that creates a textfield with the 
music notes
createTextField(17, 
AntiAliasType.NORMAL, , 63, 53);

note1 = new Note();
addChild(note1);
}
}
}

Cheers,

Annelie


--- In flexcoders@yahoogroups.com, Paul Andrews p...@... wrote:

 The usual reason for things not appearing is that the component 
that should 
 appear hasn't been added to the display list - just using new 
doesn't add an 
 object to the display list.
 
 Maybe addChild(notes) will help.
 
 Paul
 - Original Message - 
 From: annelie2008 annelie.karls...@...
 To: flexcoders@yahoogroups.com
 Sent: Thursday, January 29, 2009 1:47 PM
 Subject: [flexcoders] Re: newbie question - call to actionscript 
class
 
 
 I should probably have commented out that bit of code, it's not the
  xml I'm having problems with now (well, I have, but I'll get to 
those
  questions later). I thought that by calling my actionscript class,
  var notes:DrawNotes = new DrawNotes();, that would display my hard
  coded score on screen? I was going to loop through the xml later 
to
  go draw every specific element but for now I'm just trying to draw
  anything. Do I need to connect that to a visual element?
 
  Cheers,
 
  Annelie
 
 
  --- In flexcoders@yahoogroups.com, Gregor Kiddie gkiddie@
  wrote:
 
  mx:XML ... / isn't a visual component. You'll need to use the 
XML
  as a
  dataprovider from something that is.
 
 
 
  Gk.
 
  Gregor Kiddie
  Senior Developer
  INPS
 
  Tel:   01382 564343
 
  Registered address: The Bread Factory, 1a Broughton Street, 
London
  SW8
  3QJ
 
  Registered Number: 1788577
 
  Registered in the UK
 
  Visit our Internet Web site at www.inps.co.uk
  blocked::http://www.inps.co.uk/
 
  The information in this internet email is confidential and is
  intended
  solely for the addressee. Access, copying or re-use of 
information
  in it
  by anyone else is not authorised. Any views or opinions presented
  are
  solely those of the author and do not necessarily represent 
those of
  INPS or any of its affiliates. If you are not the intended 
recipient
  please contact is.helpdesk@
 
  
 
  From: flexcoders@yahoogroups.com
  [mailto:flexcod...@yahoogroups.com] On
  Behalf Of annelie2008
  Sent: 29 January 2009 10:43
  To: flexcoders@yahoogroups.com
  Subject: [flexcoders] newbie question - call to actionscript 
class
 
 
 
  Hello,
 
  I'm brand new to Flex so I'm sure this is a very stupid question,
  but
  hopefully someone will be able to help.
 
  My ultimate goal is to take an xaml file with a musical score and
  convert it to flex, but to start with I've hardcoded a score (or
  rather some score elements) in an actionscript class and I'm 
trying
  to call it from my main application file. When I debug I can see
  that
  it does get called, however nothing gets drawn on screen. I first
  did
  the hardcoded score in a project on its own, so I know that the
  score
  should be able to be displayed.
 
  Here's the code:
  ?xml version=1.0 encoding=utf-8?
  mx:Application xmlns:mx=http://www.adobe.com/2006/mxml
  http://www.adobe.com/2006/mxml 
  layout=absolute initialize=initializeHandler()
 
  mx:Script
  ![CDATA[
 
  import test.DrawNotes;
 
  public var myXmlList:XMLList;
 
  private function initializeHandler():void
  {
  myXmlList = scoreXml.children();
 
  // loop through the xml here and call
  the relevant functions in DrawNotes
 
  var notes:DrawNotes = new DrawNotes();
  }
 
  ]]
  /mx:Script
 
  mx:XML id=scoreXml source=scoreCanvas.xml /
 
  /mx:Application
 
  Does anyone know what I'm doing wrong?
 
  Many thanks,
 
  Annelie
 
 
 
 
  
 
  --
  Flexcoders Mailing List
  FAQ: 
http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
  Alternative FAQ location: 
  https

[flexcoders] Re: newbie question - call to actionscript class

2009-01-29 Thread annelie2008
Brilliant, it works now! Thank you so much!

No doubt I will return with more questions soon...!

Cheers,

Annelie


--- In flexcoders@yahoogroups.com, Gregor Kiddie gkid...@... 
wrote:

 Its close, you do need to have a UIComponent wrapper to add the 
Sprite
 to, and then add the UIComponent to the application.
 
  
 
 So what you had there (but make sure you actually do new UIComponent
() )
 
  
 
 And finish with addChild(uic);
 
  
 
 Gk.
 
 Gregor Kiddie
 Senior Developer
 INPS
 
 Tel:   01382 564343
 
 Registered address: The Bread Factory, 1a Broughton Street, London 
SW8
 3QJ
 
 Registered Number: 1788577
 
 Registered in the UK
 
 Visit our Internet Web site at www.inps.co.uk
 blocked::http://www.inps.co.uk/ 
 
 The information in this internet email is confidential and is 
intended
 solely for the addressee. Access, copying or re-use of information 
in it
 by anyone else is not authorised. Any views or opinions presented 
are
 solely those of the author and do not necessarily represent those of
 INPS or any of its affiliates. If you are not the intended recipient
 please contact is.helpd...@...