View Full Version : Passing parameters at run time
Andy.burnett
03-29-2002, 11:13 PM
I want to pass parameters at the startup of a movie. In languages like C I would put arguments on the command line. Is there a similar way of doing this with Flash. For instance, is that some way of defining extra Object <PARAMETER NAME=...> tags which I could set in the HTML page, and that I can then access in the value of in movie?
JHallam
03-29-2002, 11:44 PM
I don't think Flash 5 can, but I'm pretty sure MX maybe able to pass varibles. Depending on which type.
To add parameters to the component, you will use the Component Definition dialog box. When you create a parameter, you give it a name, indicate the variable it is associated with, assign it a value, and specify a type. You will create three parameters: label, for the label text of the button, Label Font, for the font used in the label text, and Label Color, for the fill color of the label text.
....Says Macromedia // http://......Link (http://search.atomz.com/search/?sp-p=any&sp-k=Flash+Support&sp-k=General+Support&sp-a=sp1001395b&sp-q=Parameters)
Hope this helps
Andy.burnett
03-30-2002, 09:18 AM
And if not, I will have to add it to the Flash wishlist.
muffl3r
04-29-2002, 05:51 PM
One way you can get around not being able to pass a parameter in is to add a "querystring" to your swf src in the embed tag / param movie in your object tag and then look at the _url property for the movie and strip off the query part. By this I mean:
Your html is like this
<object ...>
<param name=movie value="Flash/test.swf?x=123">
<embed src="Flash/test.swf?x=123"...></embed>
</object>
and then in your flash file you can look up this._url which will return your full path including the movie name and the "querystring". You then use string manipulation to get the parameter value out e.g.
myURL = this._url;
myPos = myURL.lastIndexOf("?");
myParam = myURL.substring(myPos,myURL.length - 1);
//this returns the querystring elements - you can now split these using split
Hope this helps - it should work in Flash 4 but definitely works in 5 from my tests so far.
muffl3r
04-29-2002, 05:58 PM
One way you can get around not being able to pass a parameter in is to add a "querystring" to your swf src in the embed tag / param movie in your object tag and then look at the _url property for the movie and strip off the query part. By this I mean:
Your html is like this
<object ...>
<param name=movie value="Flash/test.swf?x=123">
<embed src="Flash/test.swf?x=123"...></embed>
</object>
and then in your flash file you can look up this._url which will return your full path including the movie name and the "querystring". You then use string manipulation to get the parameter value out e.g.
myURL = this._url;
myPos = myURL.lastIndexOf("?");
myParam = myURL.substring(myPos,myURL.length);
//this returns the querystring elements - you can now split these using split
Hope this helps - it should work in Flash 4 but definitely works in 5 from my tests so far.
Andy.burnett
04-29-2002, 06:38 PM
Thanks very much for that. I think that is a great fix
tinnesda
12-23-2002, 10:55 PM
What if you wanted to pass some parameters into an .exe like ice projector or generator. Does anyone have any suggestions for this? Can it be done?
Thanks Much
-Dave
Archangel7
08-08-2005, 07:26 PM
one little question... and If I have to pass a really really big sting?
CyanBlue
08-23-2005, 05:34 AM
I am not remembering what the actual limit was but it was something like 1024 or something similar... So, if you have bigger string than that, you've got to find another way of passing the variables such as using the server side script with LoadVars() object, for example...
shivraaz
09-09-2005, 06:29 AM
To get parameter values passed using queryString, we can directly use _root.<<parameter name>>.
For Ex: <param name=movie value="Flash/test.swf?x=123">
In your actionscript you can directly get its values using _root.x;
other way would be, "FLASHVAR". Using this we can directly attach additional parameters.
Checkout macromedia help to get more about parameters.
penmig
11-06-2005, 10:51 PM
I'm using this solution in Flash MX and works great, when passing to Flash 8 I'm getting a weird page (the destination page) and don't works, anyone knows the new method ?
Thanks
To get parameter values passed using queryString, we can directly use _root.<<parameter name>>.
For Ex: <param name=movie value="Flash/test.swf?x=123">
In your actionscript you can directly get its values using _root.x;
other way would be, "FLASHVAR". Using this we can directly attach additional parameters.
Checkout macromedia help to get more about parameters.
I am using the _root.parameter_name method, but there is something weird with this: I'm passing a single digit number as a parameter. I suppose that everything is passed as a string, and as I needed the number as a Number, I converted it to a number using Number(_root.param). This returns a NaN value, so I checked the string length to see if there's something I am not seeing. To my surprise I realised that although the string has only one character (the digit), the length reports 2.
Why does it have a greater length than what it is suppose to have?
CyanBlue
04-17-2006, 07:23 PM
Howdy... :)
Try using parseInt() or parseFloat() function instead of Number() function...
Unfortunately both those functions return the same result: NaN.
CyanBlue
04-17-2006, 09:03 PM
Do the trace on the variable before you cast it by using whatever function you are using, and do the trace after that and post it with the exact code you are using... ;)
I already did that, of course :). The value is correct: it's the one digit number, but the string repors a length of 2 characters.
CyanBlue
04-17-2006, 09:51 PM
Well... I have no idea what's going on then especially I am not watching your monitor... :(
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.