Created
December 5, 2011 00:21
-
-
Save icodeforlove/1431760 to your computer and use it in GitHub Desktop.
Working with flash params
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/swfobject/2.2/swfobject.js"></script> | |
<script type="text/javascript"> | |
var flashvars = { | |
name: 'bob' | |
}; | |
var params = { | |
menu: 'false', | |
allowscriptaccess: 'always', | |
wmode: 'window' | |
}; | |
var attributes = { | |
id: 'example', | |
name: 'example' | |
}; | |
swfobject.embedSWF('example.swf', 'example', 100, 100, '9.0.0', false, flashvars, params, attributes); | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import flash.display.Loader; | |
import flash.display.LoaderInfo; | |
/* | |
* pull a var from the embed and return it, if there is no param matching the name | |
* return a default value | |
*/ | |
function getEmbedParam(name:String, defaultValue:String):String | |
{ | |
var parameters:Object = LoaderInfo(stage.loaderInfo).parameters; | |
if(parameters[name] != null) { | |
return parameters[name]; | |
} else { | |
return defaultValue; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trace(getEmbedParam('name','default name')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment