Welcome, Guest
  • Author Topic: JavaScript - speak to a function in a *.js file controling a *.html file  (Read 1991 times)

    `eniGM@dMiN“

    • Seasoned Programmer
    • ***
    • Posts: 136
      • View Profile
    hi ppl...

    i just need sum actionscript/javascript help ere =)


    at the moment i have a *.js file which i control (a button i press) in a *.html file, to display an image (4 egsample).


    now i want to combine it with flash; what i want to say is:

    as soon as the flash mc reaches a certain frame, it should call up the function.
    the result of this function must then be displayed on the html page.

    can any one help me with sum syntax?

    the button code in the *.html file:
    Code: [Select]
    <a href="javascript:function(2)">BUTTON</a>

    and the code in the *.js file consists of:
    Code: [Select]
    function function(whichOne){

    var thingy = new Array();

    thingy[1] = "hello.jpg";
    thingy[2] = "bye.jpg";

    if (document.body){
    document.body.background = thingy[whichOne];
    }
    }
    « Last Edit: 11/15/04, 09:17 by `eniGM@dMiN“ »
    .
           __|_____
          |  o  o   /
          |  o  o |                  
    ,,=================================>
    ||.-----------------------------------,,------------““
      \|||||||> · eniGMa· · · · · · · · · · · · · · · · ·//
      =============================
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    Jorge Solis

    • Global Moderator
    • Systems Administrator
    • *****
    • Posts: 14616
      • View Profile
    function is a bad name for a functions: is a reserved word. You can have problems. To call a JavaScript function from Flash is the same:

    on(press){
     getURL("javascript: myFunction()")
    }

    where myFunction is the name of your function.

    Jorge

    `eniGM@dMiN“

    • Seasoned Programmer
    • ***
    • Posts: 136
      • View Profile
    hehe ye i know bout that =)
    the code i showed u guys is just a quick general sketch of the original one =P

    does that code then call it to the html part or the flash part?

    btw. and how do i tell it to speak to a specific *.js file?
    (like "helloworld.js")

    cheers 4 ya help!
    « Last Edit: 11/15/04, 09:52 by `eniGM@dMiN“ »
    .
           __|_____
          |  o  o   /
          |  o  o |                  
    ,,=================================>
    ||.-----------------------------------,,------------““
      \|||||||> · eniGMa· · · · · · · · · · · · · · · · ·//
      =============================
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    `eniGM@dMiN“

    • Seasoned Programmer
    • ***
    • Posts: 136
      • View Profile

    ok problem solved =)

    THNX PPL.... FLASH DB 4 EVER!
    .
           __|_____
          |  o  o   /
          |  o  o |                  
    ,,=================================>
    ||.-----------------------------------,,------------““
      \|||||||> · eniGMa· · · · · · · · · · · · · · · · ·//
      =============================
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^