Skip to main content
Known Participant
July 2, 2010
Question

External Interface Issue

  • July 2, 2010
  • 1 reply
  • 998 views

package {
    import flash.external.ExternalInterface;

public class Main extends MovieClip {

modelUsed.modelInv.addEventListener(MouseEvent.CLICK,modelUse);

public function modelUse(event:MouseEvent):void {
            HT_slctdTxt.text = "hello";
            ExternalInterface.call("ovrLay")
        }

}

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
July 2, 2010

you can't have code outside your class.

Known Participant
July 2, 2010

HI,

I am trying to call a JS function from Flash.. but unable to do so.. not sure what I am missing...

Flash Code:

--------------------------------------------

   package {

    import flash.external.ExternalInterface;
    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    public class Main extends MovieClip {

               modelUsed.modelInv.addEventListener(MouseEvent.CLICK,modelUse);

          public function modelUse(event:MouseEvent):void {
            slctdTxt.text = "hello";                   /*This works*/
            ExternalInterface.call("ovrLay")             /*even tried ExternalInterface.call("ovrLay()");*/
             }

}

}

JS Code:

--------------------------------------------

<script language="JavaScript">

function ovrLay(){
    alert("asas");
}
</script>

Inspiring
July 2, 2010

As kglad said, your syntax is wrong. You cannot add listener outside class method, which is what you are trying to do.