What you are suggesting, is almost the same as I suggested, except that
you are avoiding the xml object and instead using a string; however,
because of how a string is converted when passing the data, I wouldn't
recommend it for anything too complex.
On 6/6/2010 7:13 AM, Ashim D'Silva wrote:
The last 2 weeks were crazy and I completely lost track of this so I
apologise for not responding to the answers (cheers though!). We
couldn't find a solution so we used an array instead, but the idea was
this.
I have:
var objs:Array = [1, 2, 3, 4, 5]; // arbitrary length defined by the
number of parameters I receive from the XML.
I want to pass it to javascript like this:
ExternalInterface.call('jsFunc', objs[0], objs[1], objs[2], …);
so that the JS can use whatever params are provided.
I realise now however, that passing an Array (or name-value pairs) is
a far more stream-lined method of achieving this, but I'm still
curious if I could in fact build a function in a loop and then call it
after. Interpretive languages could possibly handle this real easily,
but is there an interesting workaround?
Maybe something like:
var st:String = "function() { jsFunc(";
for each(var i:String in objs)
{
st += i+", ";
}
st+=");";
ExternalInterface.call(st);
It's reaching for stupidity because I lose the beautiful automatic
Array conversion that AS3 does, but curiosity has the better of me at
the moment.
Cheers,
Ashim
The Random Lines
www.therandomlines.com
On 28 May 2010 22:13, Anthony Pace<[email protected]> wrote:
............................................................................
If you want an array from javascript to actionscript
............................................................................
somewhere in your class put something like:
ExternalInterface.addCallback('SWFReceiver', as3Receiver);
but remember that you need a receiver in as3:
public function as3Receiver(a:Array /*or object, or *, etc...*/):void {
//do something with your array
}
then in js:
var swfo = document.getElementById('idOfYourSwfElement');
swfo.SWFReceiver(yourArrayObject);
................................................................................
if you want an array from AS3 to javascript
................................................................................
var dataScript:XML= new XML("<![CDATA[ function(){ jsReceiver(["+
formattedArrayAsString +"]);} ]]>");
ExternalInterface.call(dataScript);
On 5/26/2010 3:07 AM, Ashim D'Silva wrote:
This seems fairly impossible but if there's an awesome way to do it
I'll be heaps grateful.
I receive a function name and a set of parameters via XML
<analytics>
<function>
<name>webtrends</name>
<params>
<param>98780</param>
<param>Joseph</param>
<param>Iceland</param>
</params>
</function>
</analytics>
I'm hoping there's a way for me to fire an ExternalInterface.call()
function with any amount of parameters provided to me.
I'm one step away from telling the other side I'll send them an array,
but hoping for the long shot.
Cheers,
Ashim
The Random Lines
www.therandomlines.com
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders