Flash Vars via monkey
Monkey Targets Forums/Flash/Flash Vars via monkey
| ||
Hi everyone. Does anyone know how to Flash vars via monkey so that I can pass information to an app from information embedded on the HTML page? |
| ||
I'd suggest having a glance at the Monkey and native code in some simple modules. The way I would do it would be to make a flash class to load the data, with functions that can report it, and then define the same class and functions as Extern in Monkey. |
| ||
Thanks Gerry - I'll look into doing that. Fingers crossed! |
| ||
what I do for this is something like: file: flashvars.as function GetFlashVars():Array { var paramarray:Array = new Array ; paramarray[0] = game.stage.loaderInfo.parameters.lang ; paramarray[1] = game.stage.loaderInfo.parameters.filesUrl ; return paramarray ; } file: prog.monkey Import "flashvars.as" Extern function GetFlashVars:String[]() Public local flashvars:String[] = GetFlashVars() then flashvars[0] is lang="en" from your FlashVars in html page |
| ||
Thanks everyone. I'll check this out later in the week and let you know if I have any problems. |
| ||
@Fred Many thanks!! Been looking for a way to do this for quite a long time now! I've did this as you said, flashvars.as, then imported and used GetFlashVars() to retrieve the value I wanted ^_^ Then, on the html page: <embed src="MonkeyGame.swf" type="application/x-shockwave-flash" width="640" height="480" wmode="direct"> <param name="flashvars" value="filesUrl=test"> </embed> Added FlashVars <embed src="MonkeyGame.swf" type="application/x-shockwave-flash" FlashVars="lang=en&filesUrl=1" width="640" height="480" wmode="direct"> <param name="flashvars" value="filesUrl=test"> </embed> Works perfectly for my game! ( http://mlm.blitzspace.com/?mode=replay&rep=1 ) Now i can change the $_get value of "rep" without changing anything in the flash. :D Cheers! |
| ||
Thanks everyone. I got it set up and works nicely. |
| ||
Did not work anymore. New code: flashvars.as: function GetFlashVars():Array { var stage:Stage=BBFlashGame.FlashGame().GetDisplayObjectContainer().stage; var paramarray:Array = new Array ; paramarray[0] = stage.loaderInfo.parameters.PUT YOUR VAR HERE; paramarray[1] = stage.loaderInfo.parameters.PUT YOUR VAR HERE; return paramarray ; } Huge thanks to the original author. |