Skip navigation
Currently Being Moderated

Actionscript external interface onload

Jun 15, 2012 5:22 PM

Hi

 

I Have this external interface code that sends a video url to a video player when a user clicks a button it goes some thing like this:

 

<script language="JavaScript" type="text/javascript">
$(document).ready(function() {
function callJavascript(sendText){

 

   window.document.myMovie.SetVariable("testValue", sendText);
}

  });
</script>

 

The code above works fine when a user click a button with onclick the passed variable is a video url

and is send to the player.

 

The problem is I would like to get the video url passed when the page is loaded.

 

I have tried.

 

<script language="JavaScript" type="text/javascript">

$(document).ready(function() {

 

var sendText=$("Videosroll/Videos/1.flv").val();                                                                      

window.document.myMovie.SetVariable("testValue", sendText);

 

}

</script>

This does not work. I think its because the videoplayer is not fully loaded when this action is called. 

 

I have looked at javascript timers etc. If any one has a solution please help.

 
Replies
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 16, 2012 1:24 AM   in reply to Tony404

    use the externalinterface call() method to call callJavascript() (but it wouldn't make any sense to have flash pass sendText so that should be variable in callJavascript() )

     
    |
    Mark as:
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 16, 2012 6:31 AM   in reply to Tony404

    again,  in your html use:

     

    <script language="JavaScript" type="text/javascript">

     

    function callJavascript(){

      return videourl;  // <- make sure this is defined.  if it's not defined when your page loads, use a loop in flash to keep calling until it is defined.
    }


    </script>

     

    // in flash, use:

     

    import flash.Exteneral.ExternalInterface;

     

    var videoURL:String=ExternalInterface.call("callJavascript");

    // do whatever with videoURL;

     
    |
    Mark as:
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 17, 2012 6:19 AM   in reply to Tony404

    where is videourl (in your html document) defined?

     
    |
    Mark as:
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 17, 2012 7:38 AM   in reply to Tony404

    use:

     

    <script language="JavaScript" type="text/javascript">

     

    function callJavascript(){

      return "Videos/1.flv";
    }


    </script>

     
    |
    Mark as:
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 17, 2012 8:44 AM   in reply to Tony404

    i have no idea why you keep changing the javascript code i suggest.  the only javascript needed is in message 7.  that's it.

     

    if that fails, add a textfield, assign it an instance name (eg, tf) and use the following actionscript:

     

    import flash.Exteneral.ExternalInterface;

    var videoURL:String=ExternalInterface.call("callnow");

     

    tf.text=videoURL;

     

    myVid.play(videoURL);

     
    |
    Mark as:
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 19, 2012 10:58 AM   in reply to Tony404

    the actionscript is calling the callnow function.   there's no need for that onload="callnow()".

     

    copy and paste the actionscript you're using.  if that is copied and pasted, you have a typo in you import statement that needs to be fixed.

     
    |
    Mark as:
  • kglad
    72,164 posts
    Jul 21, 2002
    Currently Being Moderated
    Jun 28, 2012 5:12 PM   in reply to Tony404

    you're welcome.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points