Skip to main content
Known Participant
November 6, 2013
Answered

loadmovienum example with variables

  • November 6, 2013
  • 1 reply
  • 784 views

this is for AS 2

I have an existing loadmovienum() call that I need to modify to pass variables to the called .swf

Can't seem to find an example for both the call and then reading/accessing the variables passed

I have the sytax, loadMovieNum(url:String, level:Number [, variables:String])

but can't find a practical example of what exactly is 'variables:String' and then how to read those variables.

the existing call is like this, loadmovienum("some.swf, 5) so its loading movie 5 which I don't want to change,

just add 2 variables

Then in the startup in some.swf I need to access the passed variables for use throughout program,

move them to some local variable in some.swf?

If somebody has a link to an example or more comprehensive documentation please post

<moved by mod from actionscript 3 forum - kglad>

This topic has been closed for replies.
Correct answer kglad

use:

loadMovieNum(url, levelnum, "GET");

you can then append the variables/values to the url in a query string.  parse the query string using the _url property in the receiving swf.

eg:

loading swf:

loadMovieNum("test1.swf?var1=hi&var2=bye",2,"GET");

loaded swf:

var s:String = this._url.split("?")[1];

//tf is textfield on stage used to display the variables/values.

tf.text = "";

var varVal:Array = s.split("&");

for(var i:Number=0;i<varVal.length;i++){

    tf.text += varVal.split("=")[0]+" has value = "+varVal.split("=")[1]+"\n";

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
November 6, 2013

use:

loadMovieNum(url, levelnum, "GET");

you can then append the variables/values to the url in a query string.  parse the query string using the _url property in the receiving swf.

eg:

loading swf:

loadMovieNum("test1.swf?var1=hi&var2=bye",2,"GET");

loaded swf:

var s:String = this._url.split("?")[1];

//tf is textfield on stage used to display the variables/values.

tf.text = "";

var varVal:Array = s.split("&");

for(var i:Number=0;i<varVal.length;i++){

    tf.text += varVal.split("=")[0]+" has value = "+varVal.split("=")[1]+"\n";

}

bbxrider1Author
Known Participant
November 8, 2013

wow, above and beyond  the call of duty!

first off for how to get (no pun intended) the url string and then the extra mile with the splitting and unstringing the parms

I even got to create the passed variables from other variables sent to the 1st .swf from a calling .asp.

asp calls prog-1 with other data it gathers up

.......

         + '<EMBED src="'+ prog1.swf + varString + '"'

.......

prog1.swf calls prog2.swf

loadMovieNum ("prog2.swf?var1FromVarString=" + var1 + "?var2FromVarString=" + var2, 5, "GET");

there is also quite a bit of additional info after whatever vars I sent, it took a couple of trys to figure out I didn't need to put  the 2nd & after my 2 vars, that gets put on automagically

many many thanks for your excellent helpl

kglad
Community Expert
Community Expert
November 8, 2013

you're welcome.