# Multiple .swf + php + variables

**URL:** <https://forum.kirupa.com/t/multiple-swf-php-variables/62879>\
**Category:** flash\
**Created:** [September 1, 2004, 8:10am UTC](https://forum.kirupa.com/t/multiple-swf-php-variables/62879 "2004-09-01T08:10:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Urme](https://avatars.discourse-cdn.com/v4/letter/u/f1d935/32.png) [@Urme](https://forum.kirupa.com/u/Urme)\
**Post date:** [September 1, 2004, 8:10am UTC](https://forum.kirupa.com/t/multiple-swf-php-variables/62879/1 "2004-09-01T08:10:01Z")

</div>

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:

```php

    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:

```

```php

    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:

```

```php

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

```

```
The function rootlink looks like this. (It is in page1.swf)

```

```php

    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:**

```

```php

    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 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 1, 2004, 11:30pm UTC](https://forum.kirupa.com/t/multiple-swf-php-variables/62879/2 "2004-09-01T23:30:14Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 2, 2004, 4:24am UTC](https://forum.kirupa.com/t/multiple-swf-php-variables/62879/3 "2004-09-02T04:24:04Z")

</div>

next time try to write a shorter description.

nobody has time to go through such a long description.

APDesign’s method should do though

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [September 7, 2004, 8:16am UTC](https://forum.kirupa.com/t/multiple-swf-php-variables/62879/4 "2004-09-07T08:16:08Z")

</div>

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

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

```php

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

```

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

[color=#dd0000]

```php

caseid = _root.caseid;

```

[/color]

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