views:

33

answers:

2

i have a flash button and i want to pass the button link (after click) as parameter. what is the best way to do it?

+1  A: 

You can pass parameters along to Flash using flashvars.

Suppose you want to pass the URL of the website to navigate to when the user clicks a button, you can add the following parameter to your Flash <OBJECT> HTML tag:

<param name="url" value="http://www.helloworld.com" />

In ActionScript, you can read this flashvar using this piece of code:

var flashVars:Object = LoaderInfo(this.root.loaderInfo).parameters;
var url:String = "http://www.backupurl.com";

if (flashVars.url != undefined) {
    url = flashVars.url;
}

(Source example borrowed from this blog article)

Prutswonder
this is what i was looking for.how do i read it inside the flash?
junkqwe
Updated my answer with some source code for you. :-)
Prutswonder
A: 

this is how it's done in AS3: root.loaderInfo.parameters[ "name of param you want to read" ];

__dominic