dcsimg
A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: calling JavaScript from Flash

Hybrid View

  1. #1
    Senior Member
    Join Date
    Mar 2003
    Location
    New Orleans
    Posts
    191

    calling JavaScript from Flash

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

    Code:
    <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
    	);}
    </script>
    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:
    Code:
    on(press){loadMovie("knowledge.swf", "_root.main_holder_MC");
    getURL("javascript:f_scrollTop();");}
    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?

    thanks
    I'm only in it for the pleasure

  2. #2
    Moderator whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,755
    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