The forums have permanently moved to This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.

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 ""
    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;"displayAlert('" + inputText.text +"')");
    Looking at the outputText.text = inputText.text;
    And the"displayAlert('" + inputText.text +"')")
    Pieces of code, I have discovered that when switched to be:
    function callFunction(event:MouseEvent):void{"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;"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:
    Code:"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 Meet the Moderators Advertise

 Link to Us


Copyright 1999 - 2012