PDA

View Full Version : access instances for custom class



kritikal
October 31st, 2008, 12:08 PM
Hey guys,

say I have a shell that loads main.swf, the shell has a document class of Shell.as and the main.swf has a document class of TemplateBase.as now I need to write another class to animate and control main.swf, how can I access the movieclip instances inside of main.swf from my class (Content.as)

If I take out the shell and just pass the stage element from TemplateBase to Content everything works fine, but when the shell is used (I have to use it) then I get errors.

Any suggestions?

creatify
October 31st, 2008, 03:43 PM
Where is Content.as imported? Where are you creating a new Content(); for example? What are the errors you're getting?

When loading into your shell, my first guess would be that you're trying to access and pass the stage references prior to the swf being added to the stage. Search the forums/online for Event.ADDED_TO_STAGE.

kritikal
October 31st, 2008, 03:54 PM
Where is Content.as imported? Where are you creating a new Content(); for example? What are the errors you're getting?

When loading into your shell, my first guess would be that you're trying to access and pass the stage references prior to the swf being added to the stage. Search the forums/online for Event.ADDED_TO_STAGE.

hey creatify

Content.as is imported inside of TemplateBase.as and the Content() constructor is being instantiated inside of a method in TemplateBase, to be more specific, there's a method called init that does



indexLoader = new URLLoader();
indexLoader.addEventListener( Event.COMPLETE, onIndexLoaded, false, 0, true );
indexLoader.load( new URLRequest( basePath + "index.shtml" ) );


and inside of onIndexLoaded, after everything else I call my constructor. Now I tried extending TemplateBase but that just gave an error saying something about the data inside of the swf being bad.

When I don't extend TemplateBase, the errors I get are just saying that my objects are either null or don't exist, I'm guessing it's refering to the stage element.

I'll take a look at Event.ADDED_TO_STAGE, let me know if you have more suggestions