calling JavaScript in AS3

243 Views Asked by At

So i have this expandable banner. And everything is ok with it, but when i'm testing it on our system it's not expanding. And here is the problem. Because our system is using this JavaScript for the floating : getURL("javascript:expandEaFloating('"+_level0.id+"')"); But this is AS2 and i need it for AS3. Here is the code:

import flash.external.ExternalInterface;
import flash.events.Event;
stop();


b1_btn.buttonMode = true;

b1_btn.addEventListener(MouseEvent.MOUSE_OVER, aBanner2);
b1_btn.addEventListener(MouseEvent.MOUSE_OVER, openBaner);


function openBaner(e:Event){  
    ExternalInterface.call("expandEaFloating('"+root.id+"')");
}

function aBanner2(e:Event){
this.gotoAndStop(2);
}
2

There are 2 best solutions below

1
On

try this:

ExternalInterface.call("expandEaFloating",root.id);
0
On

Instead of root.id use ExternalInterface.objectID

ExternalInterface.call("expandEaFloating",ExternalInterface.objectID);

From the adobe docs:

Returns the id attribute of the object tag in Internet Explorer, or the name attribute of the embed tag in Netscape.

So be shure to set id and name of the object tag to the same value!