xmlflashquery-stringflashvars

How can I get FlashVars values in ActionScript 2.0?


I have to dynamically send a flashvars value from <object>/<embed>, for example "<object name="flashvars" value="test=myxml.xml"> to my swf file.

And in my AS, I have this:

var xmlPath:String = _level0.test;
doc.load(xmlPath);

So, this way I want to read several xml files (at least it's my intention!). But nothing of what I do works...

I also tried

doc.load(_root.test)

but it didnt work too.

If I do:

doc.load("someXML.xml")

It works just fine!!

I'm trying to solve this for many many hours and still didn't find any solution!!

Thanks in advance!!!


Solution

  • I think the problem lies in your HTML markup:

    For an <object> tag you need to use a param tag within it, e.g.

    <object ...>
    <param name="FlashVars" value="test=myxml.xml">
    </object>
    

    For an <embed> tag, its an attribute of the tag

    <embed FlashVars="test=myxml.xml" ...>
    

    Here's an Adobe TechNote on using FlashVars which might help you too.