A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: calling JavaScript from Flash

  1. #1
    Senior Member
    Join Date
    Mar 2003
    New Orleans

    calling JavaScript from Flash

    Hi, I have a text file with the following JavaScript:

    <script language="javascript">
    function f_scrollTop() {
    	return f_filterResults (
    		window.pageYOffset ? window.pageYOffset : 0,
    		document.documentElement ? document.documentElement.scrollTop : 0,
    		document.body ? document.body.scrollTop : 0
    this code makes the browser scroll back to the top.
    My flash movie is rather tall, and I need to automatically scroll back to the top when a link is clicked lower in the page.
    So, I try to call the above JavaScript from within Flash, using the following code:
    on(press){loadMovie("knowledge.swf", "_root.main_holder_MC");
    I have tested the JavaScript in a simple HTML page, and it works. Unfortunately, my Flash button is unable to call the JavaScript. The "loadMovie" works, but the "GetURL," which calls the JavaScript doesn't work.

    Can someone assist me with this?

    I'm only in it for the pleasure

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    CFA2h (respect the HEX)
    you need to use:

    ExternalInterface.call() to call the javaScript function located in the container page (ie: html page)

    HTH =)

Posting Permissions

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

Click Here to Expand Forum to Full Width

HTML5 Development Center