flash actionscript:
I'm using AS 3 in Adobe Flash 9 Public Alpha. I have a MovieClip named "RandImg" in my Library with an associated "RandImg.as" class file. I'm placing this MC on the stage during design time. This MC contains an instance of another MC with with the instance name of "mcDefault". In the constructor of my RandImg.as class file, if I attempt to reference mcDefault, I get the following error when I try to compile: ReferenceError: Error #1056: Cannot create property mcDefault on RandImg. How do I reference this movie clip in AS 3? Also, if I want to remove mcDefault from memory, but keep the RandImg MC in memory, in the "RandImg.as" class file would I just call: removeChild( mcDefault ); ? Thanks! ~JC
You would be better served using the flash9_actionscript3_preview forum for these questions. Here's a response from a thread in that forum: ----------------------------------------------------------------- Hi, Currently, those are the only solutions to this problem: - Declare the document class dynamic - Add public variable declarations for stage instances If you want to maintain encapsulation and plan on using the document class with several FLA files, you could make one base class with the core functionality, then subclass that base class for the document classes. In those subclasses, you can add variable declarations for the stage instances specific to each FLA file. We realize this can be cumbersome. We are planning on adding an option to automatically declare stage instances in the Flash 9 timeframe. -Nivesh -----------------------------------------------------------------
Making my variable declaration public solved the problem.
Don't see what you're looking for? Try a search.
|