>>I have a question back at you along this example.
>>any insights why yours can run as MyPackage.as?
Do you start out your package as:
package MyPackage
{
//class definitions
}
and then import like this:
import MyPackage.*
?
That should work.
>>if I change the name of the .as file to
>>HelloWorld.as
>>then all works fine
Yeah, I think it will still drill down and look for a class with the
same name if it doesn't find a package of the same name as the file. You
wouldn't want to name your files the same name as the class though...
the package file can contain multiple classes.
Jason Merrill
Bank of America
GT&O Learning & Leadership Development
eTools & Multimedia Team
>>-----Original Message-----
>>From: [EMAIL PROTECTED]
>>[mailto:[EMAIL PROTECTED] On Behalf
>>Of Rob Romanek
>>Sent: Thursday, March 22, 2007 3:33 PM
>>To: [email protected]
>>Subject: Re: [Flashcoders] Actionscript 3.0 help w/ simple HelloWorld
>>
>>Try adding this to your fla
>>
>>addChild(hw);
>>
>>In your HelloWorld class you've added your textField inside
>>but since you have added you HelloWorld() object to the
>>display list of the movie it will never get drawn.
>>
>>
>>my.fla
>>[MyPackage]
>> MyPackage.as (with the HelloWorld class)
>>
>>using the code in the fla I never get HelloWorld to properly
>>initiate.
>>Instead I get an error
>>**Error** Scene 1, Layer 'Layer 1', Frame 1 : Line 2, Column 8 :
>>[Compiler] Error #1046: Type was not found or was not a compile-time
>>constant: HelloWorld.
>>var hw:HelloWorld = new HelloWorld();
>>
>>if I change the name of the .as file to
>>HelloWorld.as
>>then all works fine
>>
>>any insights why yours can run as MyPackage.as?
>>
>>Rob
>>
>>On Thu, 22 Mar 2007 09:08:45 -0400, Merrill, Jason
>><[EMAIL PROTECTED]> wrote:
>>
>>> //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...)
>>>
>>
>>_______________________________________________
>>[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