How to use flashvars in as3

I use flashvars heavily to create customizable swfs. After some time I got tired of copy pasting my code and found this:

[as3]
function getFlashVars():Object {
return Object(LoaderInfo(this.loaderInfo).parameters);
}
[/as3]

I only need to call this method (which returns an object) and chain it with the flashvar I want. This only works on timeline code though.

Here’s how I use it:

[as3]
strXMLPath = getFlashVars().xmlPath || "slideshow.xml";
[/as3]

The || is for error handling. If I can’t get the flashvar:xmlPath, I created a default file slideshow.xml to show default data.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s