Solved not doing anything

Posted on 2009-05-01
Last Modified: 2013-11-11

Here is my issue.  I am trying to use with Javascript injection to change the size of a DIV containing a flash movie every time the menu expands.  However, I am having extreme amounts of trouble with ExternalInterface.  I have set up a test file to check if I was just writing it wrong, but even that doesn't work.  Please take a look at my code and tell me what stupid mistake I am making.  The code I posted is EVERYTHING in my test file.  This is a very big problem for me (delaying production) and is thus worth 500 points to the person with the working answer.

Thanks! - Josh-


<html xmlns="" xml:lang="en" lang="en">


<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />





<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase=",0,28,0" width="550" height="400">

    <param name="movie" value="test.swf">

    <param name="quality" value="high">

    <embed src="test.swf" quality="high" pluginspage="" type="application/x-shockwave-flash" width="550" height="400"></embed>










import flash.external.ExternalInterface;"alert","hello");



Open in new window

Question by:Deester4x4jr
    LVL 8

    Expert Comment

    You are missing the javascript code that is generated by the external interface constructor. Publish you Actionscript file and make sure you generate the HTML that goes with it when publishing. Then either use that HTML code or at least grab the important parts and put them in your HTML page.

    The part you are missing looks like this:

    But you have to generate your own "AC_RunActiveContent.js" file and have it in the same directory as your actionscript file. The AC file is generated when you publish your AS file.

    <script src="AC_RunActiveContent.js" language="javascript"></script>
    <script language="javascript">
       if (AC_FL_RunContent == 0) {
          alert("This page requires AC_RunActiveContent.js.");
       } else {
             'codebase', ',0,0,0',
             'width', '900',
             'height', '700',
             'src', 'javascript_test',
             'quality', 'high',
             'pluginspage', '',
             'align', 'middle',
             'play', 'true',
             'loop', 'true',
             'scale', 'showall',
             'wmode', 'window',
             'devicefont', 'false',
             'id', 'javascript_test',
             'bgcolor', '#ffffff',
             'name', 'javascript_test',
             'menu', 'true',
             'allowFullScreen', 'false',
             'movie', 'javascript_test',
             'salign', ''
             ); //end AC code
    LVL 8

    Expert Comment

    Don't use my code. It will only work for me. You have to generate your own (by publishing your Actionscript file). Then cut and paste the code that gets generated in the HTML output file into your HTML file (the one you are using to display the page).

    LVL 22

    Expert Comment

    You need a few more things that what you have right now...

    - an "import flash.external.ExternalInterface;" line of code in your AS3
    - you need to make sure that your flash embed code specifies an ID so that your javascript can reference it
    - you need some javascript functions to do something on the page

    something like this...


    function thisMovie(movieName){
    if(navigator.appName.indexOf("Microsoft") != -1){
    return window[movieName];
    } else {
    return document[movieName];

    function sendBackToFlash( value {
    thisMovie("FlashIDName").functionNameInFlash( value );

    function helloWorld( value ){
    alert( value );
    sendBackToFlash( "hello back" );


    the above assumes that you have a function in your Flash document that is named "functionNameInFlash", and also that you have given your embed code an ID of "FlashIDName"

    rp / ZA


    Author Comment

    section25: I am using Dreamweaver to build my HTML, and it automatically spits out the appropriate AC_RunActiveContent script, however the ExternalInterface API still does not launch an alert window on load of the webpage.

    rascalpants: Your example seems to slightly over complicate the situation.  Why would I need to call back to Flash when I want Flash to control the Javascript.  Also, why would I create a function to do an alert, when the object is to inject an alert command into my html page with no pre-existing javascript?

    LVL 22

    Expert Comment

    I think you are misunderstanding what ExternalInterface does, or more importantly the power of the class...  it is not a way to avoid having javascript in the HTML... it is a way to talk back and forth between Flash to JS...

    the first parameter in the ExternalInterface call is the name of the Javascript function, and the second is the value passed...   so this means you need to have a function with that first parameters name in the HTML or it will not work.  Obviously "alert" works fine without setting up any custom fuction because it is a native javascript method... but I am pretty sure you are going to do a lot more than just call an alert box right?

    my example is the basic controls that allow for a "round trip" execution...  I added the other part, just in case you needed to talk back to the Flash player...  call it a bonus ;)

    rp / Zone Advisor

    Author Comment

    I appreciate the "bonus" and your input.  But the fact of the matter is, alert isn't working.  It's not doing anything.  I can't get a box to pop-up or anything.  I tried linking it to a button click in the flash movie,and still nothing.  I can't get my Flash ExternalInterface command to call alert AT ALL.  Does this only work when executed over an HTTP connection?  Or should it be working locally like I am trying it?

    Thanks again!
    LVL 8

    Accepted Solution

    What do you mean by locally? It probably won't work outside of a web page if that is what you mean? It doesn't have to go over a network, but if you are testing the page inside of dreamweaver, then it probably won't work. I don't use DW, so I don't know how it interacts with the browser when testing a page, but try this:

    Forget about Dreamweaver for a minute. Create the flash file in the Flash IDE (authoring environent). Inside your AS code, have the call to the alert box in javascript. Publish your flash file along with the HTML code. Run the HTML code that is produced from the Flash publishing exactly as it is (except you need to add the function for the alert call). The javascript should work. Then take that and start with that as the base for your HTML page. You will have it working with everything you need. Then you can just add to it. Just don't change or remove the stuff that was put in there by Flash.
    LVL 22

    Assisted Solution

    so all u wanted was to have an alert box say hello???  

    then yeah...  just use ur exact code you have, and publish from the IDE...

    i am suprised you have not tried that already...  

    also, yes you will get a secureity sandbox error thrown(only can see with debug player) if u try to run it locally, without setting up a localhost web server first.

    if u need a quick solution for a local web server, google WAMP server... it is a one install solution.

    fyi...  i copied and pasted ur exact code above, published from flash, and viewed with wamp, and it worked fine.

    rp / za

    Author Closing Comment

    Sorry for the delay.  I am giving you both 250 points because you both basically had the same answers and you both put a decent amount of time into it.  I really appreciate the help.  I have decided, because of the uncertainty of ExternalInterface, that I am going to build the whole site in flash, and make the stage height dynamic.  Thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Course: HTML5 Mobile App Development with PhoneGap

    PhoneGap can help you leverage your already existing HTML5, JavaScript, and CSS skills in order to create and deploy cross-platform mobile apps.This program comprehensively covers HTML5 mobile app development from top to bottom.

    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now