all groups > flash actionscript > august 2006 >
You're in the

flash actionscript

group:

AS 3 - Referencing and unloading child MC's


AS 3 - Referencing and unloading child MC's Ignitrix
8/7/2006 10:30:02 PM
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

Re: AS 3 - Referencing and unloading child MC's Raymond Basque
8/8/2006 12:00:00 AM
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
-----------------------------------------------------------------

Re: AS 3 - Referencing and unloading child MC's Raymond Basque
8/8/2006 12:00:00 AM
Re: duplicate post [ignore] Ignitrix
8/8/2006 11:47:14 PM
Making my variable declaration public solved the problem.
AddThis Social Bookmark Button