Frame Actions not firing when GotoFrame() invoked from JavaScript

Posted on 2006-04-20
Last Modified: 2008-03-04

I have a movie with two frames.  The first frame has a stop action, and a variable called image_url declared.  

There is an empty movies clip called mc_image on both frames, into which I want to load an image.

I added a button which advances to frame 2.

Frame 2 has some actionscript which states simply:



This works fine.  I can hardcode the image name into the variable:

var image_url="image.jpg";

And when I press the button, it works and loads the image. i.e. the action in the second frame kicks in and performs LoadMovie.

However I am trying to set the value of image_url outside of flash, in HTML, and then pass in the value of the variable image_url via javascript.

I can set the variable (i think), but when I use GotoFrame(2), the frame action doesnt seem to fire, and the image doesnt get loaded.

I tired using TCallFrame to call the code in the frame, but that didnt work either.

Any ideas



Question by:p_love
    LVL 34

    Expert Comment

    by:Aneesh Chopra
    problem is 100% that; variable is not being set from outside..

    if you are setting variable from outside, then don't even declare it on first frame..

    secondly, don't know how you are setting the variable, a simple way is

    just send it using flashVars

    LVL 1

    Author Comment


    THanks for the reply.  I dont just want to set variables into the swf once, so using FlashVars isnt appropriate I dont think.  

    THe while thing I am trying to achieve is for a user to type an image name in a form field (or for me to store an image name in a hidden form field in a web page), and to pass that in as a variable.  So if the movie clip is parked at Frame 1, I can call a javascript function when a button is clicked which passes into the swf the image url, and then advance the swf to frame 2 where there is a LoadMovie frame action to load the images url.

    I can pass variables in using SetVariable - i.e. I tested it to set a dynamic tect box variable and that works, but when it advnces to frame 2 none of the actions seem to fire.  This is when I invoke "movieclip.GotoFrame(2)" from Javascript.  It goes to frame 2 but none of the frame actions seem to occur.

    I then want to provide buttons to allow them to scale and postion the image within the flash movie.

    LVL 34

    Accepted Solution


    you should add a watch on the variable you want to listen on......
    so that your flash can react on as you receive a new value.

    example code here:
    //this is the variable which receives the variable value..
    var myVar;

    messageReceived = function (prop, oldVal, newVal)
         return newVal;

    //add watch on the variable.. we have attached "messageReceived" function to it, as it received new value...
    //this function will run automatically"myVar", messageReceived);

    //function to react on new value
    doAction= function (newColor)
         //code to run on receiving new value for var

    I hope all would be clear.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
    I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
    The goal of the tutorial is to teach the user how to how to record live broadcast.
    This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now