A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: SOS: Calling JavaScript Function from Flash to return a value

  1. #1
    Linux + BeOS = ? ? ? ? ? ? connect2nikhil's Avatar
    Join Date
    Aug 2003
    Location
    file://d:/desai/nikhil
    Posts
    391

    SOS: Calling JavaScript Function from Flash to return a value

    Hello!

    I would like to call a JavaScript Function stored in <head> tag of HTML from Flash.

    I would like it to execute the whole function and return the value. I am unable to decipher how to do it.

    I am putting all the code below.

    The JavaScript Function in HTML:
    <script>
    var buildInfo="";
    var name="";
    var majorVersion="";
    var minorVersion="";
    var label="";
    var buildName="";
    function getBuildInfo(){debugger;
    var theUrl = pxReqURI+ "?pyActivity=@baseclass.GetXMLAboutScreen";
    var strBuildInfoXML = httpRequestAsynch(theUrl);
    var objXml = new ActiveXObject("microsoft.xmldom");
    objXml.async = false;
    objXml.loadXML(strBuildInfoXML);
    buildInfo = objXml.selectSingleNode("//aboutInfo");
    name = buildInfo.selectSingleNode("name").text;
    majorVersion = buildInfo.selectSingleNode("majorVersion").text;
    minorVersion = buildInfo.selectSingleNode("minorVersion").text;
    label = buildInfo.selectSingleNode("label").text;
    buildName = buildInfo.selectSingleNode("buildName").text;
    }
    </script>


    The Code I used in Flash:
    onClipEvent (load) {
    getURL("javascript:getBuildInfo('""')");
    txt.HTMLtext=name+" "+majorversion+"."+minorversion+" "+label+"<br>"+buildname;
    }


    What I want to do is take the values generated from JavaScript and display them in Flash, but it doesnot seem to work.

    Please help me out........... need this code solved badly today......... Your help will be highly regarded
    To design is Human. To Flash is Divine.- Nikhil "NicK" Desai
    Anyone, who stops learning is old, whether at twenty or eighty.
    Anyone, who continues learning stays young.
    The greatest thing in life is to keep learning and stay young. - Henry Ford

  2. #2
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    for communicating between javascript and flash , i would recommend using ExternalInterface:

    http://blog.deconcept.com/2005/08/16...nal-interface/
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  3. #3
    Linux + BeOS = ? ? ? ? ? ? connect2nikhil's Avatar
    Join Date
    Aug 2003
    Location
    file://d:/desai/nikhil
    Posts
    391
    I really tried understanding it, but could not get it...........

    If you can pass on a sample fla, it would help me a lot.

    I am about to explode working on this thing.......... wish if you could send me an fla sample for this concept..........
    To design is Human. To Flash is Divine.- Nikhil "NicK" Desai
    Anyone, who stops learning is old, whether at twenty or eighty.
    Anyone, who continues learning stays young.
    The greatest thing in life is to keep learning and stay young. - Henry Ford

  4. #4
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    are you using flash 8?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  5. #5
    Linux + BeOS = ? ? ? ? ? ? connect2nikhil's Avatar
    Join Date
    Aug 2003
    Location
    file://d:/desai/nikhil
    Posts
    391
    Yes, I am using Flash 8.
    To design is Human. To Flash is Divine.- Nikhil "NicK" Desai
    Anyone, who stops learning is old, whether at twenty or eighty.
    Anyone, who continues learning stays young.
    The greatest thing in life is to keep learning and stay young. - Henry Ford

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