Results 1 to 6 of 6

Thread: Calling a JavaScript function from Flash

  1. #1
    Join Date
    Jul 2010
    Posts
    37

    Calling a JavaScript function from Flash

    I have just completed some topics about declaring the Javascript, still I am looking for some help into it. Also the main thing that I am here is to know about calling the function that is declared in javascript from the flash. Since you all have explained many things to me related to programming language, I thought to take some more help from you people. Please tell me about calling a JavaScript function from Flash. It would be much helpful, if you provide some sample of coding along with an explanation due to which I can easily understand. I am hoping some quick help from your side soon.

  2. #2
    Join Date
    Apr 2009
    Posts
    64

    Re: Calling a JavaScript function from Flash

    Commonly, a Javascript code is declared at the beginning of the html page that uses it, the tags <head>.
    HTML Code:
    <html> 
    <head> 
    <title> </ title> 
    <script language="JavaScript" type="text/javascript"> 
    <! - 
    FirstFunctionName function () 
    { 
    // Block of statements 
    } 
    SecondFunctionName function () 
    { 
    // Block of statements 
    } 
    //--> 
    </ Script> </ head> 
    <body> </ body> 
    </ Html>
    Without going into details of the opening and closing tags, and structure of the code, when it comes to "enter a code between the tags <head> Page means:
    HTML Code:
    <html> 
    <head> 
    // Insert code here 
    </ Head> 
    <body> </ body> 
    </ Html>

  3. #3
    Join Date
    Dec 2008
    Posts
    183

    Re: Calling a JavaScript function from Flash

    A function declared in the javascript code on the page, can be called at other points with this syntax:
    Code:
    functionName ([parameters]);
    that is, writing the name of the function, opening and closing parentheses at the end of it. If it is required to pass parameters, these should be inserted between the parentheses, separated by a comma if more than one:
    Code:
    functionName (param1, param2, ..., paramN);
    For example, if we want the function test () is executed when the page html, insert the reference to same within the tag <body>, more specifically under the control onLoad event:
    HTML Code:
    <html> 
    <head> 
    <title> </ title> 
    <script language="JavaScript" type="text/javascript"> 
    <! - 
    function test () 
    { 
    // Block of statements 
    } 
    //--> 
    </ Script> </ head>
    If we want to perform the function by pressing a button, we can use the onClick event:
    HTML Code:
    <html> 
    <head> 
    <title> </ title> 
    <script language="JavaScript" type="text/javascript"> 
    <! - 
    function test () { 
    / / Block of statements 
    } 
    //--> 
    </ Script> 
    </ Head> 
    <body> 
    <input type="submit" value="Run"> 
    </ Body> 
    </ Html>

  4. #4
    Join Date
    Apr 2008
    Posts
    193

    Re: Calling a JavaScript function from Flash

    If the function has been correctly declared within the tag <head> html page that embeds the movie, you can call it directly from flash using the following syntax:
    Code:
    getURL ("javascript: functionName ([parameters ])");
    The method to use only the getURL: as a parameter is passed a string containing the function call to pass any parameters, which are separated by commas if more than one, or omitted if there are not. The method may be associated with a frame for a button or a movieclip. Can be invoked without parameters:
    Code:
    getURL ("javascript: functionName ()");
    call with one parameter:
    Code:
    getURL ("javascript: functionName (param)");
    call with multiple parameters:
    Code:
    getURL ("javascript: functionName (param1, param2)");

  5. #5
    Join Date
    Mar 2008
    Posts
    232

    Re: Calling a JavaScript function from Flash

    I would like to provide some important notations that you should be aware about :
    1. before the name of the function to call, it is absolutely necessary to insert the word "javascript" followed by a colon. This is to tell the browser that we are actually invoking a javascript code, whether it is present in the HTML page is that it is not proper.
    2. the word javascript, colon, and the first word that we call the javascript code (in this case, "functionName"), are written together without spaces. Sometimes, copying a script from a page like this, and paste it into Flash, you have the space or the head side.
    It is therefore important to eliminate the spaces and line breaks the code as it is read here. Where necessary, the codes will be presented in external text files.

  6. #6
    Join Date
    Mar 2008
    Posts
    227

    Re: Calling a JavaScript function from Flash

    I am providing some sample of example (so that you can understand easily )
    within the tags <head> html page that incorporates our movie, paste:
    HTML Code:
    </ Head> 
    <script language="JavaScript" type="text/javascript"> 
    <! - 
    function greet () { 
    alert ('message from html'); 
    } 
    </ Script> 
    </ Head>
    a button in some movie, you can associate:
    Code:
    on (release) { 
    getURL ("javascript: salutes ()"); 
    }
    This will bring the film salutes the function () without passing parameters, which opens a window with the message of alert message from the html page.

Similar Threads

  1. Calling JavaScript from Managed Code
    By Computer_Freak in forum Tips & Tweaks
    Replies: 1
    Last Post: 03-08-2010, 03:31 PM
  2. Problem when calling a Javascript function
    By Truster in forum Software Development
    Replies: 5
    Last Post: 21-07-2010, 11:37 PM
  3. c# function equivalent to gettime function in javascript
    By Omaar in forum Software Development
    Replies: 4
    Last Post: 10-03-2010, 10:44 PM
  4. Calling a function from a client Web Service
    By HarshaB in forum Software Development
    Replies: 3
    Last Post: 02-11-2009, 06:46 PM
  5. Calling Struts using Javascript
    By Novino in forum Software Development
    Replies: 2
    Last Post: 25-10-2008, 02:42 PM

Tags for this Thread

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
  •  
Page generated in 1,714,252,377.96887 seconds with 17 queries