ExternalInterface.call

Hi,
I want to check how ExternalInterface.call works.
Following is the as3 code for that.
ExternalInterface.call("TestExternalInterface ", "some new text variable");
Here is the javascript function.
function TestExternalInterface (data)
                                             alert(data);
But I don't understand how these two codes interact with each other. As an example whether this ExternalInterface.call works with a button click in SWF file or at the time of loading SWF file into web page. All the articcle I went through, talks about javascript function and actionscript code, but the initialization of the interaction between these two files is not clear for me. I really appreciate if someone can tell me the missing part of this.
Thank you.

I'm sorry for posting codes from two different cases. Since my fiirst attempt didn't work, I started created the html page and as3 file  gain with different javascript function name.
Here is the javascript function:
<script language="javascript">
                              function myJavascriptFunction (data)
                                             alert(data);
</script>
And following is the as3 contnents:
btnGo.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
               ExternalInterface.call("myJavascriptFunction", "some new text variable");
The link you've given functions exactly as I wanted. Can you please check the above code and tell me what's wrong with that. If you want I can send you the files, but I didn't find a way to attach files to the post. Anyway thanks for your reply.

Similar Messages

  • Problem with ExternalInterface.call and Internet Explorer

    Hi, I´m developing a site, (
    www.gen-studio.com/avelart2
    ), and I´m using a swf to display a set of thumbs that when
    clicked show an item and its description on the browser, those
    items might be images or video, everything works fine with the
    images.
    And actually it works fine with the videos too, when using
    Firefox, but when I test the page on Internet explorer it just
    doesn’t work!
    On principle let me describe how it´s supposed to work,
    a thumbnail when clicked sends an id number to javaScript using
    ExternalInterface.call(“myFunction”,myId); -I´m
    using AS3 for the swf´s-
    the javaScript file has already loaded (ever since$(
    document).ready) a XML file which uses to match the id with a file
    and the description, if the item to show it´s a video, then it
    creates a variable which holds a string with the proper html to
    embed a swf (a swf movie player that resides just next to the HTML
    file), when loaded, the swf movie player uses
    ExternalInterface.call() to ask for the source of the video that
    has to play, and that function is as follows:
    setVideo: function(){
    alert("hola");
    return comun.miVideo;
    (The alert(“hola”); is just to test that the
    function is being called), which it is, but it returns null as a
    value instead of the proper string, and this happens only on
    internet Explorer, but works correctly on Firefox.
    I´ve been reading all day about the subject and found a
    few interesting things, which though have made me narrow my
    problem, they haven´t just provided me with a solution, what I
    found so far:
    -I must have in account flash security issues: Checked (my
    actionScript follows:)
    import fl.video.*;
    import flash.external.ExternalInterface;
    flash.system.Security.allowDomain("*");
    var vid:FLVPlayback = this.miPlayer;
    vid.source =
    flash.external.ExternalInterface.call("comun.setVideo");
    -ExternalInterface and Internet explorer don´t work
    properly when tested locally: Checked (I have a server on my PC and
    I´m testing the site as well in the above direction).
    -The object tag holding the swf must have a proper id
    attribute: Checked.
    -It´s super important the way the object tag is formed:
    Checked, and I also tested the tag separately (I put it directly in
    the HTML instead of adding it via javaScript) and it worked as
    expected in both Firefox and Internet Explorer, which leads me to
    believe:
    -I read somewhere that if you add the object tag by using
    innerHTML or appendChild, returning values from javaScript to swf
    won´t work, but I couldn´t find an explanation nor a
    solution.
    Well, as I said now I´ve been looking all day for an
    answer, so I really hope you can help me or give me some advice on
    the subject, thank you so much for your time!

    Hi! it solved itself !! (nahh, I wish), but it indeed had a
    solution, it was something quite simple, and I don´t really
    understand why it was not working in the first place, but here is
    the thing:
    I´m learning jquery and this is the first proyect
    I´m officially using it, so I was using
    $('#myDIV').append("string"); to embed the swf, (and it was working
    perfectly on Firefox), so since I had narrowed my problem to those
    lines, I decided to try some good-old-fashioned-javaScript and
    changed it for: var myDiv =
    document.getElementById('thatParticularDiv'); myDiv.innerHTML =
    ('string'); and it worked both in Firefox and IE !!!!!! :)
    I´m quite happy about it, and if someone knows
    what´s the issue with my jquery approach I would love to hear
    it. THANKS !!

  • ExternalInterface.call not working

    ***Flash CS4 -published to AS3.0 and Player  10***
    I am having a problem using ExternalInterface.call to a javascript  function. I have used this method many times in many places and at some  point during this project, it was working, but now it stalls my Flash  file when executed.
    I have the function:
    var initialize=function(){
    ExternalInterface.call("SCOInitialize");
    statusTxt.text="initializing";
    On my html page, there is a SCOInitialize function that works perfectly  if I call it via the html page:
    <body onLoad="SCOInitialize()">
    </body>
    When I make the call using flash...
    initialize();
    ...the Flash file just gets hung up and it actually wont execute the  second line of code in the function: statusTxt.text="initializing";
    What is the deal? I can't for the life of me figure out why it won't  work anymore!!!
    Also, I have checked to see if the ExternalInterface is available, and  it returns "true".

    I am testing locally using an HTML file that virtualizes an LMS. I have used is many times in the past. I originally used javascript that I normally create for these circumstances that always worked in the past, then switched to trying to use the Javascript that Flash created. In either case, the call to the Initialization function onLoad from the HTML page itself worked fine, both actually having different Function names, but perform the same function, while the ExternalInterface call to both fails.

  • ExternalInterface.call problem with object-orientation

    Hi
    I am using an swf inside a PDF. In a PDF-context the ExternalInterface-class works much the same as it does within a website. So far calling a function in the document-script works.
    The thing now is, that I really try to use an object-oriented approach as often as I can. In this case I have a function I could call using
    var jsCaller:Object = ExternalInterface.call("myFunction",parameters);
    This works as expected.
    However, I have now made that function a method in an object, so I can access it within JS using dot-notation: myCoolObject.myFunction(); This works as well, so the problem is not the function itself. However, the call
    var jsCaller:Object = ExternalInterface.call("myCoolObject.myFunction",parameters);
    does not work.
    This means there's either something I'm missing, or it's a limitation of ExternalInterface, or it's a limitation of externalInterface in a pdf-context.
    Anyone to enlighten me?

    If EI calls eval it should be able to resolve the object-path. However, this doesn't seem to be the case. Also note that my parameter is an array, so this probably wouldn't work, even if the syntax did.
    Anyway, I tested your syntax in my PDF, and it showed the same behaviour as before (i.e. the function in which the EI-call was placed could not be executed, and acrobat claimed there was no such function). It didn't work with my normal function, and not even with a simple console.println-statement that way. So in PDFs it definitely doesn't work like that.
    But thanks for the suggestion!

  • ExternalInterface Call Javascript Array to AS2 throwing undefined error

    I need to pass various (tracking) IDs to a .swf.  the IDs are in an array like this =
    <script type="text/javascript">
    function getImpID() {
    var medID={impID:'12345',pvID:'677890',exID:'654332'};
    return medID;
    function thisMovie(banner) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[banner]
        else {
            return document[banner]
    window.onload=getImpID;
    </script>
    Right now the AS2 I have is:
    import flash.external.*;
    System.security.allowDomain(sourceDomain)
    var allID:String = ExternalInterface.call.apply("getImpID");
    function getIDs(){
              var impID:Number;
              var pvID:Number;
              var exID:Number;
              var id_arr:Array = allID.split(",");
        _root.id_test.text = impID;
    getIDs();
    Basically what I need is to split the three ID's from the javascript so that I can append them with various URL clickTags in the AS.  Main issue I have is the 'undefined' error, so I'm going out on a limb here that the AS2 I have doesn't do anything right now of value.  Biggest head scratcher for me is, if I have the IDs in an array in the javascript (medID) how to get them not only properly into Flash but to separate them into their separate IDs. 
    Any suggestions would be greatly appreciated.
    Thanks!

    Forgot to reply, your guidance helped in solving the riddle =
    actionscript:
    function idTag(){
              getID = Object(ExternalInterface.call("getImpID"));
              getID.toString();
      //_root.id_test.text = getID;
    idTag();
    javascript
    <script type="text/javascript">
    function getImpID() {
              var getID=['impID=8910424942498409873&pvID=8910423767061585831'];
              thisMovie("banner").getID;
              return getID;
    function thisMovie(movieName) {
        if (navigator.appName.indexOf("Microsoft") != -1) {
            return window[movieName]
        else {
            return document[movieName]
    </script>
    worked like a charm!

  • ExternalInterface.call('scroll',0,0) not working in chrome

    My application has a requirement that if the user is in the bottom of the page and clicks on any link which in turn opens a flex popup, it will take the user to the top of the application as popup opens on the top (as per requirement). For this i have used ExternalInterface.call('scroll',0,0); which works perfectly for every browser except google chrome. in chrome when user clicks it takes the user to the top but doesnt opens any popup, once user clicks on browser scrollbar and moves slightly then the pop up opens.
    Need a solution for this.
    Thanks in advance.

    Maybe chrome needs to get focus, if so instead of calling the scroll call
    another JS  function which scrolls and sets the focus on some html element in
    the browser. Not sure if it will work but you can give it a try.
    C

  • Problem with AS3 "ExternalInterface.call" in InternetExplorer

    Hi,
    Explaining how the page is setup:
    I have a HTML page with 2 different AS3 Flash movies.
    The first flash movie is the main animation and sits in the
    middle of the screen with a large background image set into the
    body of the HTML.
    The second flash movie stretches 100% width/height of the
    screen dimensions and acts as a fade from black>to invisible.
    What I'm trying to do:
    Once the second Flash animation has faded from black to
    invisible it calls a JavaScript function in the HTML page to hide
    the div element the second flash movie is embed into (this is
    because the first flash movie will display a set of input boxes
    which the user needs to be able to type into - which they wont be
    able to click on if there is another flash movie overlaying the
    entire first movie).
    My intial solution:
    In the second Flash movie is the following code:
    stop();
    // this will load the API necessary to communicate with
    external entities
    import flash.external.ExternalInterface;
    // call the JavaScript function
    ExternalInterface.call('myJavaScriptFunction');
    ...and this works fine in Mozilla Firefox/Safari. The
    actionscript successfully calls the JavaScript function in the HTML
    page and that JavaScript function simply (at this stage displays an
    alert() message to show that it has been successfully called).
    Problem with IE:
    But, the moment I try this in Internet Explorer I don't get a
    alert() message but a JavaScript error message that says:
    Code: Select all
    Line: 1
    Char: 106
    Error: 'null' is null or not an object
    Code: 0
    As you can expect I'm totally confused as to what the problem
    could be.
    This is really urgent as it's a live project that needs to
    get completed immediately, so any help you may have would be
    greatly appreciated!
    Kind regards,
    Mark.

    My guess is that its to do with your embedding code. Check a)
    you have an id attribute assigned to the resulting object tag from
    whatever embedding method you use and b) for good measure make sure
    its unique in your html page.
    Javascript needs to have a valid reference to return the
    value from the javascript function back to flash. In my experience
    IE is more sensitive to issues here.
    If you get stuck post a test page somewhere.
    Tools to use to help with javascript debugging and view the
    html embed results (e.g. from swfobject or activecontent.js):
    In firefox : Firebug
    In IE: IE Developer Toolbar , Companion JS, and DebugBar are
    all helpful and , combined, get close to Firebug.

  • ExternalInterface.call() does not work normally since flash player 11.8.800.168

    Problem Description:
    korean character crash when using ExternalInterface.call(funcName, args)
         funcName : alpha-numeric
         args : include korean characters
    Steps to Reproduce:
    <flex source>
    private function handleRequest(val):void {
         ExternalInterface.call("processRequest", "가나다라");
    <javascript source>
    function processRequest(param) {
         alert(param); //does not display korean characters
    Actual Result:
         媛&#128;?섎떎??
    Expected Result:
         가나다라
    Any Workarounds:
    Nothing !!
    OS : Windows7 Pro 64bit(korean)
    Flex Builder : 3.0
    Flash Player : 11.8.800.168 ActiveX
    Browser : IE10
    WAS : WebLogic 8.1, 12g, Tomcat 5,6,7
    Chrome : 29.0.1547.66 m <== Good
    FireFox : 23.0.1 <== Good

    Same problem here! With the exact same version.
    Problems on IE.
    Chrome and FF OK

  • Flash Player v. 9.0.115.0 broke my ExternalInterface.call

    The latest version of Flash Player has obviously broken my
    ExternalInterface.call, which works for all previous versions. I
    know that there are security changes in the latest version but by
    using the debugger provided it did not kick out any problems. By
    reading the
    article
    about the security changes, I couldn't find anything useful in
    to solve this.
    Please help me!
    Backend:
    import flash.external.ExternalInterface;
    private function getData():Void {
    if (ExternalInterface.available) {
    try {
    this.args = ExternalInterface.call("passData");
    output.text = "Values from ExternalInterface: "+this.args;
    } catch (e) {
    output.text = "A Security Error occurred : "+e.message+"\n";
    } else {
    output.text = "External interface is not available for this
    container.";
    Front end
    <script type="text/javascript" language="javascript">
    function passData(){
    var args = new Object();
    args.something1= 466;
    args.something2= 466;
    return args;
    </script>
    Output text on v.115 : Values from ExternalInterface:null
    Output text on pervious versions: Values from
    ExternalInterface: [Object]
    It is working perfectly fine in previous versions of Flash
    player, but after I upgraded to the latest version 9.0.115.0 the
    ExternalInterface returns null, I tested in other previous versions
    and it returns the object pass from the Javascript ok. Surely it is
    something to do with the latest version, it could be the security
    changes but I have no idea how to fix this and this is driving me
    crazy! : (
    Any heros could help me please? Thanks in advance!
    Jen

    Please continue to work with your support agent on this one..
    Also, please read:
    "Security changes in Flash Player 9"
    http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security.html
    That should give you an understanding of the changes.

  • ExternalInterface.call Causes JAVASCRIPT ERROR??

    my AS3.0 is this:
    btn_mc.addEventListener(MouseEvent.CLICK,journey_popup);
    function journey_popup(e) {
    ExternalInterface.call("journey_wow_popup");
    my javascript is this:
    function journey_wow_popup () {
    window.open('journey_pricing.php','_blank',
    'height=200,width=350,status=yes,toolbar=no,menubar=no,location=no');
    My flash OBJET ID and movie name is "journey_wow"
    I get this javascript error when I click btn:
    Error: "journey_wow" is undefined
    I tried this on 4 computers, I never get the the error in FF,
    I got the error on 2/4 of the computers in IE and didnt get the
    Error in the other 2.
    So sometimes it works in IE and sometimes it doesn't. Also my
    flash element is not in a form.
    you can view it here:
    http://www.sussexjewelers.com/product.php?pid=1390
    (its the big red box with yellow star)
    Please help!!
    Thanks!

    Below is my embeding script, thanks.
    <script language="javascript">AC_FL_RunContent =
    0;</script>
    <script src="AC_RunActiveContent.js"
    language="javascript"></script>
    <script language="javascript">
    if (AC_FL_RunContent == 0) {
    alert("This page requires AC_RunActiveContent.js.");
    } else {
    AC_FL_RunContent(
    'codebase', '
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
    'width', '626',
    'height', '115',
    'src', 'journey_wow',
    'quality', 'high',
    'FlashVars',
    'journey_price=<?=round($prod_field['prod_price'][0])?>',
    'pluginspage', '
    http://www.macromedia.com/go/getflashplayer',
    'align', 'middle',
    'play', 'true',
    'loop', 'true',
    'scale', 'showall',
    'wmode', 'transparent',
    'devicefont', 'false',
    'id', 'journey_wow',
    'bgcolor', '#ffffff',
    'name', 'journey_wow',
    'menu', 'true',
    'allowFullScreen', 'false',
    'allowScriptAccess','always',
    'movie', 'journey_wow',
    'salign', ''
    ); //end AC code
    </script>

  • ExternalInterface.call URL string limit

    I am using ExternalInterface.call and i found out that
    recursive calling will not work .........and passing all the data
    in one call
    is also giving me a problem with string limits...........ANY
    IDEAS please?

    Yes. Make a function in JavaScript that uses the
    "GetVariable" method.
    (READ HERE:
    http://www.adobe.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03. html
    ...and call it from the external interface. Put your 'string
    data content' in a variable and read it from JavaScript.

  • AS 3.0 - using ExternalInterface.call to open a .pdf

    Hi - using Flash - AS 3.0:
    I am trying to use ExternalInterface.call to open a .pdf file - but it is not working - nothing is happening...
       ExternalInterface.call ("window.open","diagrams/v1/crh.pdf", "WindowName", params);
    but this line DOES work - call an .html file to open.
       ExternalInterface.call ("window.open","m5_quiz/v1/quiz.html", "WindowName", params);
    I can't find any information that says this should or shouldn't work - it seems to me it should open it.
    To get around this - I have been using 'navigateToURL' to open the pdf file - but that triggers the pop-up blocker - using the External Interface call does not.
    Any help/ideas?
    Thanks,
    Lisa

    I agree - that code - if it opens an html should open a pdf - but it doesn't.  And I don't know why..
    Why is the code screwy?  Could I do it better another way?
    Thanks

  • ExternalInterface.call String parameter length limit???

    Is there a String length limit to the amount of chars a
    String can contain when passed as a parameter to
    ExternalInterface.call()?
    Also, are there any chars that ExternalInterface.call()
    cannot serialize in a string?? Like \n, \t ...etc.
    The livedocs don't answer these questions.

    thanks for your reply but i just figured it out.
    ExternalInterface.call("jsFunc", longString);
    There is seems to be no char limit that i came across cause i
    was able to shove 2K in there.
    The problem is the newlines in the string, they must get
    messed up during serialization. Just make sure you clean the string
    of newlines like so:
    longString = longString.split("\r").join("
    ").split("\n").join(" ");
    ExternalInterface.call("jsFunc", longString);
    works fine......

  • ExternalInterface.call across domains?

    I'm using ExternalInterface.call in a swf file to call a
    javascript in the html container. The swf file is located in a
    different domain than the html container. Everything works fine if
    all files are within the same root directory, but as soon as I
    reference the swf file located in the other domain, the call stops
    working! What am I missing?
    swf file has this in frame 1:
    import flash.external.ExternalInterface;
    function clickListener(eventObj:Object):Void {
    ExternalInterface.call("sendToResponseForm");
    swf file has this on mc instance tracked as button:
    on(press){
    clickListener();
    html file/container has this in <head> tag:
    <script type="text/javascript">
    function sendToResponseForm(){
    window.location = "my.other.html.file";
    </script>
    html file has this embedded:
    <object
    classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="
    http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"
    width="700" height="550">
    <param name="movie" value="
    http://www.otherdomain.com/vid/my.SWFFile.swf"
    />
    <param name="quality" value="high" />
    <embed src="
    http://www.otherdomain.com/vid/my.SWFFile.swf"
    quality="high" pluginspage="
    http://www.macromedia.com/go/getflashplayer"
    type="application/x-shockwave-flash" width="700"
    height="550"></embed>
    </object>
    Hopefully, that's enough for you to chew on. Like I said if
    swf and html are in the same domain, it works. Just as soon as I
    point to second domain for swf file source it stops working.
    thanks
    deke

    Here's my mistake -- the swf file was fine and actually
    worked in IE6/IE7 but wouldn't work in Firefox. The process of
    including the swf file in the HTML was flawed. I originally
    published the HTML using Dreamweaver to write the <object> in
    the code. What fixed the problem was I published the swf file using
    Flash to a desktop folder which produced a javascript file
    (AC_RunActiveContent.js), the swf file and the HTML. The javascript
    dynamically determines which browser was being used and which
    player plugin was required. The script ultimately loads/writes the
    embed or object for the swf file appropriately for the content
    environment and everything communicates properly. It didn't have
    anything to do with cross domain communication at all.
    The main challenge was updating the Flash HTML/Javascript to
    use the proper swf resource which was located on a different server
    and move the js file to the appropriate directory updating the link
    in the HTML accordingly. My only concern was the added overhead of
    an external javascript source. But, at least I'm not concerned with
    whether it works or not anymore.
    Hope this helps somebody.
    deke

  • ExternalInterface.call() problem

    Hi,
    My first problem was the random activation of the pop up
    blocker in Fierfox when I use navigateToURL("url", "_blank").
    I found a solution
    there,
    but unfortunaly this solution didn't work for me.
    The solution is to use ExternalInterface.call for opening a
    new window without the popup blocker, but I cannot use the solution
    if I don't put in my HTML page <param name="allowScriptAccess"
    value="always" />. If I don't put this parametre I cannot use
    ExternalInterface.call.
    You'll say, why you don't put this parametre? It's because a
    lot of person use this application, and they are able to integrate
    it into there web site, unfortunaly I cannot control if they put
    the parametre allowScriptAccess.
    So I'd like to know if it's possible to use
    ExternalInterface.call without the parametre.
    Thanks
    Matthieu

    quote:
    Originally posted by:
    mattL_75_13
    Nobody has an axe of search ??
    I will trade you for a Sword of Reply

Maybe you are looking for

  • Please Help!! My Mac Pro (5.1) Can't upgrade to Yosemite

    Hi, I have a 12 core with Intel Xeon at 3.46 Ghz Mac Pro 2009 upgraded to 5.1 (Version 10.9.5) and I'm trying to upgrade to Yosemite and the OS X installer it's quitting unexpectedly every time I try to install, Preview it's also crashing the same wa

  • Adobe Reader won't display PDF in IE Browser Window

    I am using Adobe Reader XI and Internet Explorer v. 11.0.9600.17280. I have tried uninstalling and re-installing Adobe.  I've also checked IE Add-Ins and all Adobe Reader Add-Ins are enabled. However, you're poorly written software STILL WILL NOT dis

  • CONVERT A SCANNED .txt file to PDF

    I'm trying to edit a scanned document in .txt, but need to change it to PDF so I can edit it. Please advise

  • Keyboard and trackpad in macbook pro doesn´t work

    My keyboard and trackpad doesn´t work. I have a macbook pro 17" from 2008, and i upgraded the OS to Snow Leopard. I even tried with Lion, because i read somewhere that this could solve the problem, but so far, nothibg. Help!!

  • Error exporting to Excel

    Post Author: TASCAndy CA Forum: Exporting I have a user who keeps getting an error when exporting to Excel. The user dials in to his office over VPN. Navigates to the crystal server infoview, runs the report, exports to Excel. Chooses to Open the fil