Hey off the top of my head, I think I see the problem.
So, you add the text field child to the HelloWorld Sprite. Adding the
child in the hello world sprite, does not add it to the stage. When you
use add child alone, you have to pretend it's this.addChild. If you
chose to import flash.display.Stage and do Stage.addChild(message_txt)
you'd see it. What you did is add the field to just the sprite. But
where's the sprite? It's nowhere still.
In the fla, I'd bet if you put
import MyPackage.*
var hw:HelloWorld = new HelloWorld();
addChild(hw);
it might just work!
Merrill, Jason wrote:
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
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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
_______________________________________________
Flashcoders@chattyfig.figleaf.com
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