Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 3 of 3

Thread: AS3 Call JS functions. At a loss CS4 - Publishing issue?

  1. #1

    AS3 Call JS functions. At a loss CS4 - Publishing issue?

    Okay I was looking at this page "http://www.kirupa.com/flash/calling_..._using_as3.htm"
    And I have rewritten my code countless times.
    For ease of access I have been pasting this function directly under the head <script> tag in the published html with my javascript
     <script language="JavaScript" type="text/javascript">
    function displayAlert(message){
    This is the function to be called from my Action Script 3 code:
    import flash.external.ExternalInterface;
    btn_call.addEventListener(MouseEvent.CLICK, callFunction);
    function callFunction(event:MouseEvent):void{
        outputText.text = inputText.text;
        ExternalInterface.call("displayAlert('" + inputText.text +"')");
    Looking at the outputText.text = inputText.text;
    And the ExternalInterface.call("displayAlert('" + inputText.text +"')")
    Pieces of code, I have discovered that when switched to be:
    function callFunction(event:MouseEvent):void{    
    ExternalInterface.call("displayAlert('" + inputText.text +"')");
        outputText.text = inputText.text;
    the outputText.text = inputText.text;
    does not execute. Otherwise in the first code snippet it will execute the outputText in browser.
    I really do not know what is going wrong.
    Any suggestions and questions will be appreciated.

  2. #2
    I havent a clue why this was happening but somehow I have fixed it. Perhaps a spelling error? But I did change the AS3 Code to:
    //actionscript - as3
    import flash.external.ExternalInterface;
    //Set up Javascript to Actioscript
    ExternalInterface.addCallback("sendTextFromJS", receiveTextFromJS);
    function receiveTextFromJS(t:String):void {
    	outputText.text = t;
    //Actionscript to Javascript
    function sendTextFromAS3(e:MouseEvent):void {
    	outputText.text = inputText.text;
    	ExternalInterface.call("receiveTextFromAS3", inputText.text);
    btn_call.buttonMode = true;

  3. #3
    I believe that you can only pass arguments to a function by using the approach you used in the second example:
    ExternalInterface.call("functionName", argument);
    In our first example, you passed in the argument as a string as part of the function call itself. I am not 100% sure, but I think that was your problem

    Great, now even Kirupa is { facebooking | twittering }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Home About kirupa.com Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012