Introduction:
What are Flash Vars? Flash Vars are variables programmed on the web page that can be pulled into flash and then used appropriately.
What not to use flash vars for:
If your passing any type of secure information like passwords and credit card numbers, DO NOT USE FLASH VARS. Flash Vars can be seen if a user views the source, therefore being able to see the password or credit card number and this compromises red flag compliance laws.
Lets do this:
HTML code:
add to object tag:
param name="allowScriptAccess" value="sameDomain"
param name="FlashVars" value="val1=Variable"
add to embed tag:
allowScriptAccess="sameDomain"Your HTML code is now able to pull the Variable into flash!
FlashVars="val1=Variable"
Very simply, this is the code you need in your flash:
function retrieveFlashVar():Object{
return Object(LoaderInfo(this.LoaderInfo).parameter);
}
The function above is receiving and storing the flash vars into an object. In order to access the variable, I would recommend storing the Flash Var into a new variable within flash. You can do this with this code:
var variable1 = retrieveFlashVar().val1
I used val1 because that was the name of the flash var in the html code I provided. But if you have another name for your variable, replace val1 with whatever you named your variable.
From there, you can now use the pulled information as if it was in flash itself. Just refer to it as variable1.
No comments:
Post a Comment