Frame Actions not firing when GotoFrame() invoked from JavaScript

Hello,

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:

mc_image.LoadMovie(image_url)

----

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

Regards

Stephen

LVL 1
p_loveAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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

Important:
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

Rgds
Aneesh
0
p_loveAuthor Commented:
Hi,

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.

Thanks
Stephen
0
Aneesh ChopraCommented:
Hi,

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)
{
     doAction(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
_root.watch("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.

Rgds
Aneesh
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.