# \[Flash8\]Help Setting an external Variable?

**URL:** <https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950>\
**Category:** Uncategorized\
**Created:** [May 10, 2008, 8:37pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950 "2008-05-10T20:37:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![spongepants](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@spongepants](https://forum.kirupa.com/u/spongepants)\
**Post date:** [May 10, 2008, 8:37pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/1 "2008-05-10T20:37:34Z")

</div>

Hi guys,

Any idea how I can declare a variable that is retrievable when the browser reloads.

spanks:pirate3:

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 10, 2008, 10:14pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/2 "2008-05-10T22:14:29Z")

</div>

If you want it to be retrieved by the same SWF, check out SharedObject in the help files.

---

<div class="post-metadata">

**Author:** ![spongepants](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@spongepants](https://forum.kirupa.com/u/spongepants)\
**Post date:** [May 10, 2008, 10:26pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/3 "2008-05-10T22:26:54Z")

</div>

hi glosrfc,

It needs to be used by two swf files. Can I use a cookie?

thanks

---

<div class="post-metadata">

**Author:** ![pablo\_2006](https://avatars.discourse-cdn.com/v4/letter/p/c67d28/32.png) [@pablo\_2006](https://forum.kirupa.com/u/pablo_2006)\
**Post date:** [May 10, 2008, 10:37pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/4 "2008-05-10T22:37:55Z")

</div>

See post #3 & #5

> **[Flash menu inside html page](https://www.kirupa.com/forum/showthread.php?t=297019)**
>
> Got a web design/development question or just want to hang out with the most awesome people on the planet? Drop on in!

Pablo

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 10, 2008, 10:52pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/5 "2008-05-10T22:52:27Z")

</div>

Try this easy primer too:  
[http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm](http://www.kirupa.com/developer/actionscript/tricks/passingvariables.htm)

---

<div class="post-metadata">

**Author:** ![spongepants](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@spongepants](https://forum.kirupa.com/u/spongepants)\
**Post date:** [May 11, 2008, 2:40pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/6 "2008-05-11T14:40:05Z")

</div>

Hi, thanks for your help it’s much appreciated.

I have this working to an extent. I am doing this for a client who would like the feature in an oscommerce shop install.

I have an index.php page where we have designed a flash program to sit on its own. On product pages we want to have a flash navigation bar appear in the leftColumn.

This actually works very well. I simply replaced the the var name to the default oscommerce var (cPath).

So I have:

if(cPath==“24”){  
gotoAndStop(31);  
}else{  
gotoAndStop(30);  
}

My problem is that cPath will not always equal 24. It will be all sorts of strings? (24\_29 this is a string not number because of the \_)?

Is there a way to define lots of variable values in flash? Just carry on the If statement?

chris

---

<div class="post-metadata">

**Author:** ![glosrfc](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/glosrfc/32/8334_2.png) [@glosrfc](https://forum.kirupa.com/u/glosrfc)\
**Post date:** [May 11, 2008, 3:23pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/7 "2008-05-11T15:23:34Z")

</div>

You can code a switch/case statement rather than create loads of if statements and you can use strings or numbers:  
switch (cPath) {  
case 24 :  
trace(“cPath is number 24”);  
break;  
case “24” :  
trace(“cPath is string 24”);  
break;  
case 25 :  
case 26 :  
case 27 :  
trace(“Some other number”);  
case “25” :  
case “26” :  
case “27” :  
trace(“Some other string”);  
break;  
default :  
trace(“Number or string invalid”);  
}

This will make it easier to edit because the problem that I see with this navigation in the future is that it will need editing every time the product range changes along with their respective strings.

---

<div class="post-metadata">

**Author:** ![spongepants](https://avatars.discourse-cdn.com/v4/letter/s/898d66/32.png) [@spongepants](https://forum.kirupa.com/u/spongepants)\
**Post date:** [May 11, 2008, 8:14pm UTC](https://forum.kirupa.com/t/flash8-help-setting-an-external-variable/259950/8 "2008-05-11T20:14:31Z")

</div>

Hi glosrfc,

thanks, I take your point about updating this navigation. May have to look at some xml code.

Just to let you know I found that is works best (so far) if I do this:

if(cPath==""){  
gotoAndStop(30);  
}else{  
gotoAndStop(31);  
}

by way of redirect page, i have sent people to cPath= which results in the index.php page.  
As you know, this means any other cPath vars will result in FRAME 31 (in my example…i think).

probably a bit oscommerce specific but might help someone.

thanks again
