haXe Forum > Haxe and SWFOBJECT
-
Roberto Ferrer Feb 21 at 19:25
Hi people! I have an SWF made in haxe embed in a html using swfobject, I am trying to pass it a variable called texto with the text "Hello haxe from html!!". I put the variable inside the flashvars block.
The html code look like this:
<script src="js/swfobject.js" type="text/javascript"></script> <script type="text/javascript"> var flashvars = { texto : "Hello Haxe!!! This is a message from JS and HTML"; }; var params = { menu: "false", scale: "noScale", allowFullscreen: "true", allowScriptAccess: "always", bgcolor: "#FFFFFF" }; var attributes = { id:"MySample" }; swfobject.embedSWF("MySample.swf", "altContent", "100%", "100%", "9.0.0", "expressInstall.swf", flashvars, params, attributes); </script>
And this is the haxe code:
class Main { static function main() { var info = Lib.current.loaderInfo.parameters.texto; trace (info ); } }
Anyway, I only obtain Main.hx 16: null .
Anybody can help with something simple like this?
Regards!
-
Oleg Sivokon Feb 22 at 00:29
I think you need current.root.loaderInfo, but haven't tried it, so, take it just as a guess.
-
Roberto Ferrer Feb 23 at 06:23
Hi Oleg, thanks for your answer!
I have tried but it does´t works.
Any idea?
-
Oleg Sivokon Feb 23 at 12:21
Hi, I just tried your example and it worked fro me, except that you had a semicolon after the :
texto : "Hello Haxe!!! This is a message from JS and HTML";
That is not valid JavaScript syntax for object literal, the key-value pairs are delimited by commas, the last key-value pair should not have a delimiter after it. So, remove the semicolon and try it again - should work. -
ludo Feb 23 at 17:27
var so = new SWFObject("mysample.swf","client",750,400,8,"#ffffff"); so.addVariable("texto", "hello from..."); so.addParam("AllowScriptAccess","always"); so.addParam("wmode", "transparent"); so.write("flashcontent");
flashcontent is your div id where you want to put your flash content
-
Roberto Ferrer Feb 24 at 22:05
Hi again, the two ways works for me!!!
Thanks very much!