开发者

How to receive an array from flash vars?

How do I receive an array from flash vars?

So I have HTML page. with a flash app on it. I want to send an array to flash.

How do I do such thing using flashVars (I have something like uid=12&sid=12&sid=32&sid=12&sid=32) so I need to get d开发者_运维百科ynamic\random\beeg\unknown number of Sid's while not losind UID. How to do such thing?

btw I want to pass in an array of values and have it recognized by Flash as an Array object;

For example, with POST and GET requests an array is formed as "field[]=value&field[]=value" etc.


If you could join the sid's into a comma-delimited string, then you could split them in the actionscript.


I'm confused, you want to send parameters to your flash movie or receive? And if you want to send them as I suspect, how are they produced in the first place? Is it from an HTML form on some other page? You can use PHP for this or JavaScript that will construct your HTML with the parameters passed.

// write flash obj with query string
function writeFlash() {
    // appearance vars, these can be customized to your liking
    var width = '200'
    var height = '100'
    var src = 'query.swf'
    // queries -- type in the variables you want to send to flash here
    var queries = '?uid='+QueryString('uid')+'&sid='+QueryString('sid')+''

    // assemble flash obj
    var l1 = '<object width="'+width+'" height="'+height+'" data="'+src+queries+'" type="application/x-shockwave-flash"><param name="quality" value="high" /><param name="src" value="'+src+queries+'" /></object>'

    // write all lines
    document.write(l1+l2+l3+l4+l5)
}

This is your answer in JavaScript, taken from http://noscope.com/journal/2003/12./query_string and slightly modified.


"How to recive an array from flash vars?"

Application.application.parameters.


In this situation, I usually create a dynamically generated XML file and pass the url to it as a flashvar.

The reason I prefer XML is that I hate having to write extra javascript which encodes the flashvars and then extra actionscript to parse them. However, if your flash app is very simple and you don't plan on adding many arrays/relationships to it then ignore my answer. :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜