Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

variable advice 1

Status
Not open for further replies.

ksbigfoot

Programmer
Apr 15, 2002
856
CA
I have loaded a swf (level1) into my main swf (level0).
I would like to read variables from level1 that were declared in level0 and vice versa.
What is the best way to retrieve these variables.
Thanks
 
Read from level 1 on level 0 (once the movie is fully loaded...)

mylevel0_var = _level1.whatever_variable;
trace(mylevel0_var);

The reverse...

mylevel1_var = _level0.whatever_variable;
trace(mylevel1_var);

Regards. Web Hosting - Web Design
03/13/05 -> OLDNEWBIE VS FLASHKIT
 
Howdy oldnewbie,
It is not working for me.
I only have one frame in my imported swf and I created actionscript code on that frame and here is what I have declared.
Code:
var strFlag:String = "1";
Here is the code I am running in my main swf
Code:
trace (_level1.strFlag);
Here is how I loaded the swf file into level1
Code:
loadMovieNum("MazeText.swf", 1);
I found a way around it, buy declaring Setters and Getters functions in my swf that I loaded into my main swf. I am calling those functions and it is returning the values.

I am still interested to see if there is an easier way to retrieve parameter values.

Thanks
ksbigfoot
 
Howdy oldnewbie,

I just realized as I was working on my swf file that sometimes I was able to access the value by typing _level1.strFlag and other times I was not.

If I take out the call _level1.fStartTime();
then I get an unidentified error.
If I call _level1.fStartTime(); first followed by the trace statement I don't get an error on the trace statement.
If I place _level1.fStartTime(); after the trace statement, I get unidentified on the first trace call and then the actual value the second time it is called.

Code:
onClipEvent (enterFrame) {
	with (_root.player) {
		trace(_level1.strFlag);
		_level1.fStartTime();	
     }
}

I gave you a star oldnewbie as what you originally told me works if I am not within the onClipEvent.
I am not sure why I have to have the function call first to _level1 before I can access the variables.

Thanks
ksbigfoot
 
Make sure your MazeText has some content other than just actionscript, even if it's off-stage, so that the movie has a width > 0.

Add your actionscript...
var strFlag:String = "1";

In your main movie, use this...
Code:
stop();
loadMovieNum("MazeText.swf",1);
this.onEnterFrame = function(){
	if(_level1._width > 0){ // if the movie is fully loaded...
		trace("The value is: "+_level1.strFlag);
		delete this.onEnterFrame;
	}else{
		trace("Movie not fully loaded yet!");
	}
};

Regards. Web Hosting - Web Design
03/13/05 -> OLDNEWBIE VS FLASHKIT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top