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 [email protected], "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: <[email protected]>
> 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 [email protected], "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: [email protected]
> > [mailto:[email protected]] On
> >> Behalf Of annelie2008
> >> Sent: 29 January 2009 10:43
> >> To: [email protected]
> >> 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://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-
446f-b4cf-1e62079f6847
> > Search Archives: 
> > http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! 
Groups 
> > Links
> >
> >
> >
>


Reply via email to