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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting a variable and retrieving in external swf

Status
Not open for further replies.

2cxc

Programmer
Aug 29, 2003
245
0
0
CA
Hello, I have a bunch of if statements under a button and each one sets a different variable, like so: var aa = 13;

normally in the same movie i can retrieve this variable and use it like so:
if (aa==1) {

I was wonder if set the variable in the button as mentioned, is there some way an external swf can get it if i load the other swf as _self or possibly using some other method?

Thanks
 
If you set your variable as a global variable, you shouldn't have any problems retreiving it or setting it from anywhere, even in a loaded movie, replacing the main movie in which the variable was initially set...

_global.aa = 13;

Then from anywhere...

_global.aa = "new_value"; // to change it...

trace(_global.aa);
my_var = _global.aa;
Etc...
 
sorry i explained this poorly i have a bunch if IFs like so:
if(......){
var aa = 123;
formdata.sendAndLoad("31c.asp", dummy, "POST");
}
if(.......){
var aa = 124;
formdata.sendAndLoad("31d.asp", dummy, "POST");
}
getURL("preferencea.asp", "_self");


Well i luckily stumbled upon the right solutions for me which was:
getURL("preferencea.asp?aa="+aa, "_self");

now the url have the string value, the preferencea.asp has a movie in level1 that loads the asp variables. So how does the URL value pair enter into flash on level1, do i have to call for it or does it just happen? and i read somewhere some time ago and not sure if it pertains to this situation, but that this method of getting the url does not occur instantaneously and that i may have to establish a mean of catching the pair after an indefinite delay (the delay depending on server traffic, net traffic, size of string, and so on) is that true?
 
Well, to pass the variables to Flash, you need to append variables to the end of the movie tags. In PHP, its done like this (don't know how to do it in ASP):

Code:
<PARAM NAME=movie VALUE=myMovie.swf?aa=.$aa>

Where the
Code:
.$aa
is the variable
Code:
aa
. Hopefully you know how to do this in ASP, because I don't! Its probably something like
Code:
 & aa
.

FLASHfreak :)

By the way, not sure if you need to do it to the
Code:
<EMBED src=myMovie.swf>
tag. Not sure.

FLASHfreak :)
- The Flash Experience
 
what if i'm going from a non flash embeded page and using a string to send a flash page a variable like ..?bb=2
Can flash interpret this string?
 
You need bb==3 instead of bb=3, I think, otherwise you're just setting the variable bb to 3.
 
the single = does not work either,

When i posted my question i tried to keep things simple, this is my actual situation, maybe if i tell it as it is my problem may be easier to solve:
I have a button in swf1 that sets a variable like so:
if(.....){
var bb = 1;
} Else If {
......
Play();

//Then on the next frame i have:
stop();
if(bb==1){
getURL(&quot;preferencea.asp?bb=&quot;+bb, &quot;_self&quot;);
}

//then in the html of preferencea.asp i have:
<PARAM NAME=movie VALUE=&quot;preferencea.swf?<%=Request.QueryString()%>&quot; >
<PARAM NAME=loop VALUE=false>
<PARAM NAME=quality VALUE=high>
<PARAM NAME=scale VALUE=exactfit>
<PARAM NAME=bgcolor VALUE=#FFFFFF>
<EMBED src=&quot;preferencea.swf?<%=Request.QueryString()%>&quot;

// when i response.write the Request.QueryString() i get bb=1

//then i have a preload in preference which plays when Bytes loaded = 100% then the frame after the preloader i have:

if (bb == 1) {
loadVariablesNum(&quot; 1);
} else if (bb == 2) {
loadVariablesNum(&quot; 1);
}

I'm displaying the loadedvariables in text box called &quot;display&quot;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top