View Full Version : external parameters
ta2000
05-14-2002, 09:07 AM
I have a simple fla which displays jpg's one at a time with a prev and next button.
It has an action script which has a variable maxPic which is currently hard coded.
I want to either have the page which calls the flash pass in the maxPic value or have it in a txt file so that I can use the same source object and have it independent of the number of pictures.
I've looked at quite a few sites and come across some very good stuff but non seem to do basic parameter driven stuff.
Can onyone help?
Jesse
05-14-2002, 10:23 AM
To do it with an external variable from a text file just use loadVariables, wait until the variable is loaded, convert it into a integer then run your script with the loaded var as your maxPic value...
See the Passing Variables Around tutorial to see how to do it by passing the var in directly.
ta2000
05-14-2002, 03:47 PM
Thanx for pointer - now got it working - here is working code.
This could of course be extended to dynamically work out whether a parameter is present, if so in what position and thus either get value or set default or throw error.
<object ...>
<param name=movie value="Flash/test.swf?maxPic=9&whichPic=1">
<embed src="Flash/test.swf?maxPic=9&whichPic=1"...></embed>
</object>
// This line is for use within Flash MX only for use with test movie
//myURL = "http://localhost/projxtrade/flash/load_images_1.swf?maxPic=9&whichPic=3";
// This line is normal working line
myURL = this._url;
//Get name=value pairs
myPos = myURL.lastIndexOf("?");
myString = myURL.substring(myPos + 1,myURL.length);
myValuePairs = myString.split("&");
//Set first value
myTemp = myValuePairs [0];
myParam = myTemp.split("=");
maxPic = int(Number(myParam [1]));
//Set second value
myTemp = myValuePairs [1];
myParam = myTemp.split("=");
whichPic = int(Number(myParam [1]));
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.