Multiple .swf + php + variables

I’m using Flash MX 2004.

I will explain how my .swf files etc works first.

I have 3 .swf files.
index.swf
page1.swf
page2.swf

Index.swf is the “top” flash file… and includes page1 and page2. First thing that happens is that index.swf got a small intro and on frame 100 (label: page1) I’m loading page1.swf with the following script:


    stop();
    undersidor_movie.unloadMovie();
    undersidor_movie.loadMovie("page1.swf");
    
On frame 1 in page1.swf I'm calling a php-script that will load text and images. Like this:

    page1Data = new LoadVars() 
    page1Data.ref = this 
    page1Data.load("page1.php") 
    page1Data.onLoad = function(success){ 
    	if(success){  
    			text1 = this["text1"];
    			text2 = this["text2"];
    			text3 = this["text3"];
    	} else trace("Error loading data") 
    }
    

I have a menu in index.swf and if you click on “Page 2” in that menu index.swf will load page2 on frame 101(label:page2) in index.swf.
And it uses the same procedure as page1… you unload the movie, load page2.swf. Then calling a php script (page2.php) that will include the text etc for page2.swf.

I actually have 5 pages that works like this.

Ok my problem is this:

In page1.swf I have a text1 variable as you can see that variable is a "internal" link like this:

    <a href=\"asfunction:rootlink,page2|6\">Link 1</a>
    
The function rootlink looks like this. (It is in page1.swf)

    function rootlink(arg){
    	var argArray = arg.split("|");
    	_root.gotoAndPlay(argArray[0]);
    	caseid = argArray[1];
    }
    
As you can see this link will play Label: page2 in index.swf and jump to page2.swf.

**My question is, how can I get the variable "caseid" to follow to page2.swf? I need that variable in page2.swf so I can load the correct data from the .php file. Like this:**

    page2Data = new LoadVars() 
    page2Data.ref = this 
    page2Data.load("page2.php?Id="+caseid)
    page2Data.onLoad = function(success){ 
    	if(success){  
    			text1 = this["text1"];
    			text2 = this["text2"];
    			text3 = this["text3"];
    	} else trace("Error loading data") 
    }
    
I'm very new to Actionscripts and not sure if this is the best way to code it.. need serious help :(

P.S don’t complain about my english grammar please :slight_smile:

I’m pretty sure you could just save caseid as a _global variable and access it from anywhere. I kind of skimmed down to your question tough. Thought I would at least throw out an idea since there are 0 replies.

next time try to write a shorter description.

nobody has time to go through such a long description.

APDesign’s method should do though

Ok, sorry for the long description :slight_smile: … the problem was easier than I thought.

I just took the “rootlink” function and wrote it in index.swf and called it like this:


<a href="asfunction:_root.rootlink,page2|6">Link 1</a> 

[color=#dd0000]Then in page2.swf I wrote:[/color]

[color=#dd0000]


caseid = _root.caseid;

[/color]

[color=#dd0000]Easy :)[/color]