Skip to main content
Participant
April 15, 2007
Question

change the variable in parent flash,is it possible?

  • April 15, 2007
  • 4 replies
  • 354 views
Well,I know I can use the loader class to load a swf file(child swf) into the current playing swf(parent swf).and I can use the ApplicationDomain.currentDomain.getDefinition to change the variable in child swf movie.
But I want to know ,can I change the variable in parent swf movie from the loaded child swf movie?for example:if I click a button in child swf,I can call a function defined in parent swf movie.
It seems possible in adobe' s flex2 live doc(article ApplicationDomain),but this doc is very ambious,
Pls give me some tips about this.
thx alot.

This topic has been closed for replies.

4 replies

L_J_SAuthor
Participant
April 15, 2007
Sigh...I'm stupid....
use this.parent.parent in child swf file is ok...
thank you guys again...
L_J_SAuthor
Participant
April 15, 2007
sorry,but I used flash9 actionscript3.
_root,_parent can not use in it.

thank your help.
kglad
Community Expert
Community Expert
April 15, 2007
you can change access everything no matter its location in a swf file. you just need to use the correct absolute or relative path.

you can't get any help with the relative path because you gave insufficient information except to say using _parent will start moving your reference from a timeline in the child swf towards the main timeline in the main swf.

the absolute path is easier to reference (usually). the main timeline in your main swf is always _level0. and the absolute path to your object/variable is the same no matter where it is used.
Inspiring
April 15, 2007
Yes you can...you just need the correct 'path' to the right level in the hierachy.

If you consider the main timeline as the _root level, then your Loader class/component might be called myLoader. Its 'content' is your loaded clip. So if it had code saying :
_parent._parent.doSomething();


Then it should be accessing a function at the _root level.
or _parent._parent.myVar ++;

In the past I've loaded a form application inside a Loader and I think it was 3 levels up to get to the _root timeline from the loaded root form.

Hope that helps.