Having some issues accessing my param tags from within actionscript. Essentially I have the following tag:
<param name="config" value="config" />
But I am unable to access it. There are two issues that I have, and I’ve been searching the internet high and low for the answers.
1) How do I even access the parameter? I have some people saying use _root.config, LoaderInfo(this.root.loaderInfo).parameters[“config”], and just config. None work, and searching for this stuff is so hard because it’s so generic.
2) I assume that once I do find out how to access the param that is being passed, I’m going to have issues with accessing it from another file because I read somewhere during my searching that other files do not have access to global variables. If this is the case, how do I do that? I have seen _globals thrown around a couple of times and some people say it works, some don’t.
Sorry if these are very basic questions, but I’m a php/.NET coder that had to update an actionscript file, and it’s nothing like what I expected.
Thanks.
It seems there is a confusion between Flashvars & Flash parameters. You can access Flashvars within your code by using loaderInfo.parameters, but you won’t be able to access the Flash parameters( why would you want to? )
Have a look at the following example to see the difference between the two
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000272.html
Flash parameters will set a bunch of properties to embed your movie in an HTML page, whilst Flashvars are values that you wish to use within your application.
After loading your flashvars, there are several ways to access them across your application, a simple solution ( probably not the best ) would be to create an Asset class with public static variables.
public class Asset { public static var config:String; public static var amount:int; } public class Main extends Sprite { public function Main { var params:Object = this.loaderInfo.parameters; //set your Asset variables Asset.config = params.config; Asset.amount = params.amount; //now that the values are set , you can use them //across your app. See below... } } public class Whatever { public function Whatever() { var amount:int = Asset.amount; } }