Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Frame Actions not firing when GotoFrame() invoked from JavaScript

Posted on 2006-04-20
5
Medium Priority
?
253 Views
Last Modified: 2008-03-04
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

0
Comment
Question by:p_love
  • 2
3 Comments
 
LVL 34

Expert Comment

by:Aneesh Chopra
ID: 16504389
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
 
LVL 1

Author Comment

by:p_love
ID: 16512495
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
 
LVL 34

Accepted Solution

by:
Aneesh Chopra earned 2000 total points
ID: 16513494
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

579 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