PDA

View Full Version : Variable assignment from SWF to loaded SWF



nextstep
April 7th, 2005, 06:39 PM
Hi, I have been playing with this for a day and haven't been able to figure out the proper path to load this variable.

So I have a main movie, a menu (movie clip) in it, and each menu option loads an external swf in a movie clip instance (called content) in the main movie.

Loading the movies works fine.

My problem is I want assign a variable that I have declared in a loaded movie in the 'content' instance.

Main Movie
|
- Menu (MC)
-onrelease -loads movie.swf, assigns defaultpage var a value
|
_ content (MC)
|
- Movie loaded dynamically from Menu (eg. movie.swf)
-Variable defaultpage is declared on frame 1


Here is the onrelease code I'm using

on (release) {
this._parent.content.loadMovie("company.swf"); //this works
this._parent.content.defaultpage = "somevalueinhere"; //this doesnt
}


What am I doing wrong? thanks :)

dreeft
April 7th, 2005, 07:11 PM
You don't need the 'this' in your button commands. just use _parent.content.

nextstep
April 7th, 2005, 07:56 PM
ooh. Ok tried that and it doesn't seem to work.

I am calling the variable in the loaded swf like so:

trace("The variable is: "+defaultpage);

and it's coming up undefined. :( oh and I tired this.defaultpage as well with no luck.

stringy
April 8th, 2005, 01:31 AM
Hi, I have been playing with this for a day and haven't been able to figure out the proper path to load this variable.

So I have a main movie, a menu (movie clip) in it, and each menu option loads an external swf in a movie clip instance (called content) in the main movie.

Loading the movies works fine.

My problem is I want assign a variable that I have declared in a loaded movie in the 'content' instance.

Main Movie
|
- Menu (MC)
-onrelease -loads movie.swf, assigns defaultpage var a value
|
_ content (MC)
|
- Movie loaded dynamically from Menu (eg. movie.swf)
-Variable defaultpage is declared on frame 1


Here is the onrelease code I'm using

on (release) {
this._parent.content.loadMovie("company.swf"); //this works
this._parent.content.defaultpage = "somevalueinhere"; //this doesnt
}


What am I doing wrong? thanks :)
make sure it is loaded before assigning variable
Try something similar to this
http://www.kirupa.com/forum/showthread.php?t=92186

nextstep
April 11th, 2005, 02:00 PM
Thanks stringy. Exactly what was wrong :)

stringy
April 11th, 2005, 02:21 PM
Thanks stringy. Exactly what was wrong :)
glad you sorted it out