haXe Forum > Haxe and SWFOBJECT

  • 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!

  • I think you need current.root.loaderInfo, but haven't tried it, so, take it just as a guess.

  • Hi Oleg, thanks for your answer!

    I have tried but it does´t works.

    Any idea?

  • 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.

  • 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

  • Hi again, the two ways works for me!!!
    Thanks very much!

< Prev | Page 1 / 1 | Next >