Professional Web Applications Themes

Actionscript: Calling JS function from Flash - Macromedia Flash

Hi! I need to call a JS function from a Flash animation. The JS function resides on the same page as the Flash. I've searched the Internet for a solution, and the answer I found was the "getUrl" function in Flash. So I wrote: getURL("javascript :PageFunction()"); I also tried: iNumber = getURL("javascript :PageFunction()"); in Flash, and made a JS function on the html page named PageFunction (it is just a test function which returns the number 5). And now the good part; When the getUrl is executed, it unloads the whole page, and loads a blank page with the number ...

  1. #1

    Default Actionscript: Calling JS function from Flash

    Hi!

    I need to call a JS function from a Flash animation. The JS function resides
    on the same page as the Flash. I've searched the Internet for a solution,
    and the answer I found was the "getUrl" function in Flash. So I wrote:

    getURL("javascript:PageFunction()");

    I also tried:

    iNumber = getURL("javascript:PageFunction()");

    in Flash, and made a JS function on the html page named PageFunction (it is
    just a test function which returns the number 5). And now the good part;
    When the getUrl is executed, it unloads the whole page, and loads a blank
    page with the number 5 on it..... What is this??

    I need to call a JS function WITHOUT refreshing the page. How can I do that?

    Is it possible to do it the other way around; call an ActionScript function
    in a Flash animation from a JS function on the html page?

    Any help appreciated
    Jan Petter Skarbovik


    Jan Petter Skarbovik Guest

  2. #2

    Default Re: Actionscript: Calling JS function from Flash

    Are you having this problem in Netscape, by any chance? You might try
    embedding the function in the void() function, like this:

    getURL("javascript:void(PageFunction())")

    I seem to recall that this fixes that problem. I could be wrong, but I
    think it is something on this track. You might look up void() on some JS
    reference page if that ain't right.

    sp

    In article <bjmuna$98n$1news.netpower.no>,
    "Jan Petter Skarbovik" <janpetternetpower.no> wrote:
    >Hi!
    >
    >I need to call a JS function from a Flash animation. The JS function resides
    >on the same page as the Flash. I've searched the Internet for a solution,
    >and the answer I found was the "getUrl" function in Flash. So I wrote:
    >
    >getURL("javascript:PageFunction()");
    >
    >I also tried:
    >
    >iNumber = getURL("javascript:PageFunction()");
    >
    >in Flash, and made a JS function on the html page named PageFunction (it is
    >just a test function which returns the number 5). And now the good part;
    >When the getUrl is executed, it unloads the whole page, and loads a blank
    >page with the number 5 on it..... What is this??
    >
    >I need to call a JS function WITHOUT refreshing the page. How can I do that?
    >
    >Is it possible to do it the other way around; call an ActionScript function
    >in a Flash animation from a JS function on the html page?
    >
    >Any help appreciated
    >Jan Petter Skarbovik
    >
    >
    --
    S t e v e n P o s t
    s . p o s t n u m b e r - 1 0 . g o v . u k
    Steven Post Guest

  3. #3

    Default Re: Actionscript: Calling JS function from Flash

    Jan Petter,

    I would recommend you look for fscommand() which is s more direct way of
    calling javascript, geturl was meant to be used to jump to a different page,
    and although it can be used to fire javascript, it causes a clicking sound
    in MSIE and i think in your case show the return value of your function as
    if it were web content

    Good luck,

    Bart

    "Jan Petter Skarbovik" <janpetternetpower.no> wrote in message
    news:bjmuna$98n$1news.netpower.no...
    > Hi!
    >
    > I need to call a JS function from a Flash animation. The JS function
    resides
    > on the same page as the Flash. I've searched the Internet for a solution,
    > and the answer I found was the "getUrl" function in Flash. So I wrote:
    >
    > getURL("javascript:PageFunction()");
    >
    > I also tried:
    >
    > iNumber = getURL("javascript:PageFunction()");
    >
    > in Flash, and made a JS function on the html page named PageFunction (it
    is
    > just a test function which returns the number 5). And now the good part;
    > When the getUrl is executed, it unloads the whole page, and loads a blank
    > page with the number 5 on it..... What is this??
    >
    > I need to call a JS function WITHOUT refreshing the page. How can I do
    that?
    >
    > Is it possible to do it the other way around; call an ActionScript
    function
    > in a Flash animation from a JS function on the html page?
    >
    > Any help appreciated
    > Jan Petter Skarbovik
    >
    >

    Bart Adriaanse Guest

  4. #4

    Default Re: Actionscript: Calling JS function from Flash


    "Bart Adriaanse" <Brt.nl> wrote in message
    news:3f60ae0e$0$58711$e4fe514cnews.xs4all.nl...
    > Jan Petter,
    >
    > I would recommend you look for fscommand() which is s more direct way of
    > calling javascript, geturl was meant to be used to jump to a different
    page,
    > and although it can be used to fire javascript, it causes a clicking sound
    > in MSIE and i think in your case show the return value of your function as
    > if it were web content
    >
    I'm having the same problem, and so far haven't found a good solution. I'd
    like to do the following

    1. Call a javascript function that returns a value, and that is on the same
    web page, without reloading the page.
    2. Call an ActionScript function from javascript, that returns a value.

    Is this possible? Does mx 2004 have better support for this?





    Bootstrap Bill Guest

Similar Threads

  1. Calling Flash function from Javascript
    By Alain Levy in forum Coldfusion Flash Integration
    Replies: 0
    Last Post: August 9th, 07:12 AM
  2. Calling a javascript function from flash
    By sixstringdev in forum Macromedia Flash Data Integration
    Replies: 2
    Last Post: April 13th, 09:26 PM
  3. calling a flash function from Javascript
    By marcelogsouza webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 1
    Last Post: January 21st, 02:22 PM
  4. Sending event or calling function in flash from director?!
    By Peleg Kurland in forum Macromedia Director Lingo
    Replies: 1
    Last Post: October 24th, 08:32 PM
  5. Replies: 1
    Last Post: October 17th, 11:16 AM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139