PDA

View Full Version : actionscript and Javascript communication


spii
06-15-2007, 12:19 AM
hey,

--> i have this code in flash:

import flash.external.ExternalInterface;

var result:Object = ExternalInterface.call("getTextFromFlash");

//writes in the inputtext what it receives from JavaScript
resultado.text = result.toString();

switch (result.toString()) {
case ("1") :
gotoAndStop("2");
case ("2") :
gotoAndStop("3");
}

stop();

--> and i have this in javascript:

function getTextFromFlash() {
return "1";
}

--> my problem is that when they communicate in the Inputtext apears - 1 - but the switch doesnt make a match. Also in IE 7 the text that apears is - undefined - so they don't communicate.

Can someone help me with this problem?? i already googled everything i could and found nothing that helped me.

spii
06-17-2007, 01:54 AM
well, it suddenly started working.... don't know why.

Anyway, I still have a problem. In the IE i managed to avoid the first click to have interaction with flash but the comunication between flash and javascript only happens after i hit refresh.

can someone help me avoid the refresh ????

PS: if i wasn't very clear let me know. thks

atomic
06-17-2007, 01:58 AM
http://blog.deconcept.com/swfobject/

spii
06-18-2007, 07:03 PM
http://blog.deconcept.com/swfobject/


thks, helped a lot!