TwelvestoneFlash

Another dumb question:testing URL parameters


Sign in

  • Waiting for Godot ( 730 k posts )
    Just conversation.
  • Thunder Dome ( 23 k posts )
    Photoshop Tennis and Collabs.
  • Photography ( 5.1 k posts )
    For all you shutterbugs, sh...
  • Flash ( 18 k posts )
    ActionScripting to tweens, ...
  • Front End ( 5.9 k posts )
    general front end design an...
  • Back End ( 9.7 k posts )
    serverside scripting, progr...
  • Projects and Theory ( 12 k posts )
    This forum is for discussio...
  • FAQ ( 269 posts )
    All those nagging questions...
  • Design ( 17 k posts )
    graphics & all aspects of g...
  • Purgatory ( 3.6 k posts )
    12stone Jail, feel free to ...
Stickman
 
2009-05-16

I really am rusty with this stuff...

I'm creating a Flash movie that will depend on a parameter passed in from the page it's embedded in. While I'm in development, is there s simple way to simulate this behaviour when testing within Flash itself? BTW, I'm stuck with Flash 8 on this project.

Cheers!

DontBogartMe
 
2009-05-16

right at the start of the movie, set that param to whatever value you want to use to test.

e.g. if the param is called user_id, then do: _root.user_id = whatever;

or you might be able to just do

user_id = whatever;

jimmyn
 
2009-05-16

One method I've been using a lot of lately is using short-circuit booleans or trinary operators to set a variable to a given parameter or a default if the parameter doesn't exist. For example:

var myDynamicString:String = _root.queryStringParam || "defaultValue";

// or

var myDynamicString:String = (_root.queryStringParam !== undefined) ? _root.queryStringParam : "defaultValue";

The first syntax using the || uses actionscripts loose typing nature to get a quick settings in place. If _root.queryStringParam is set to anything (and also not 0 or false) it will be stored as the value, otherwise the default value is stored.

The second syntax is a little more verbose, but technically a little cleaner. If the queryStringParam is defined and set to anything (meaning something came through from the dynamic context) that value will be used, otherwise the default value will be used.

From this point you then just use your own variable (in this case myDynamicString) when you want to use the value of the property. I generally avoid keeping the name of the variable I want to use the same as the name of the variable getting passed to me to avoid any confusion--as long as I use my variable I know what I am using. Because default settings have been used, your code can be assured to always have some value and that will make testing much easier.

Stickman
 
2009-05-18

Thanks guys. Don't know why, but I was sure there was a way to set Flash itself up so that you could set parameters externally when testing. :shrug:

Sorry, you must be a member to post to a conversation. Either log in or sign up to get involved.
TwelvestoneFlash

Another dumb question:testing URL parameters