That's weird that you also have to addChild() the class instance to the stage, 
but makes sense I guess - I thought addChild(textField) in the class would be 
enough, but I can see it now. Works. Thanks.

Jason Merrill
Bank of America  
GT&O Learning & Leadership Development
eTools & Multimedia Team


 

>>-----Original Message-----
>>From: [EMAIL PROTECTED] 
>>[mailto:[EMAIL PROTECTED] On Behalf 
>>Of Andrés González & Aragón
>>Sent: Thursday, March 22, 2007 11:34 AM
>>To: [email protected]
>>Subject: Re: [Flashcoders] Actionscript 3.0 help w/ simple HelloWorld
>>
>>Hi,
>>
>>In your fla add:
>>
>>import MyPackage.*
>>var hw:HelloWorld = new HelloWorld();
>>//You need to add the Child to the Stage addChild(hw);
>>
>>
>>Other way to do it is set as 'Main Class 'of the fla file 
>>Helloworld.as, you can do it in Publish settings in 
>>ActionScript option (the same where you set the source paths).
>>
>>
>>Saludos
>>
>>Andrés González Aragón
>>Desarrollador Multimedia
>>
>>2007/3/22, Merrill, Jason <[EMAIL PROTECTED]>:
>>>
>>> Getting my feet wet with AS3, I just bought the AS3 
>>cookbook and have 
>>> learned a lot already - great book.  I feel like an idiot 
>>asking this 
>>> as I'm pretty good in AS2, but with AS3, I'm not getting a simple 
>>> script working. I have the Flash 9 AS3 preview, trying to write a 
>>> simple HelloWorld class (based on an example in the book) 
>>to show a TextField:
>>>
>>> //MyPackage.as
>>> package MyPackage
>>> {
>>>        //do I actually need this one?:
>>>        import flash.display.DisplayObjectContainer;
>>>
>>>        import flash.display.Sprite;
>>>        import flash.text.TextField;
>>>
>>>        public class HelloWorld extends Sprite
>>>        {
>>>                public function HelloWorld()
>>>                {
>>>                        var message_txt:TextField = new TextField();
>>>                        message_txt.text = "Hello World";
>>>                        addChild(message_txt);  //does not show!
>>>                        trace("constructor runs")//traces fine
>>>                }
>>>        }
>>> }
>>>
>>> Then in the .fla, I put:
>>>
>>> import MyPackage.*
>>> var hw:HelloWorld = new HelloWorld();
>>>
>>> The constructor traces fine in the output window, but the TextField 
>>> does not show.  What have I done wrong?  My Export settings 
>>in F9 As3 
>>> preview are for AS 3.0 and FP9.  In later scripts, I tried 
>>moving the 
>>> textfield, changing the color, changing the stage color to 
>>be sure it 
>>> wasn't matching the textfield and this invisible, 
>>etc...(but it should 
>>> show as black Times New Roman text by default anyway...)
>>>
>>> Thanks,
>>>
>>> Oh, and as a side note, I use FlashDevelop 2.0.1 and have my syntax 
>>> set to AS3, but have notices code hinting doesn't always work or is 
>>> sometimes incomplete - has anyone else noticed that?  Maybe I just 
>>> need to update it.
>>>
>>> Jason Merrill
>>> Bank of America
>>> GT&O Learning & Leadership Development eTools & Multimedia Team
>>>
>>>
>>>
>>> _______________________________________________
>>> [email protected]
>>> To change your subscription options or search the archive:
>>> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>>
>>> Brought to you by Fig Leaf Software
>>> Premier Authorized Adobe Consulting and Training
>>> http://www.figleaf.com
>>> http://training.figleaf.com
>>>
>>_______________________________________________
>>[email protected]
>>To change your subscription options or search the archive:
>>http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>>
>>Brought to you by Fig Leaf Software
>>Premier Authorized Adobe Consulting and Training
>>http://www.figleaf.com
>>http://training.figleaf.com
>>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com

Reply via email to