-
Hi all,
It's been a long, long while since I posted here. I would like your help on controlling a movieclip through action script.
My problem is:
My movieclip is a car, it is called "mycar". The only thing that is animated are the car wheels which spins 360 degrees, as if it is on the move. I would put the movie clip outside the Movie stage on the right, then I would make it move to the left. It would give the effect of a car driving to the centre.
In the centre, the car would stop. The prob is the car wheels won't stop spinning. I thought my solution would be putting a script in a frame, at the point where the car stops. It was in frame 40 of the main movie timeline. There are no scripts in "mycar" movieclip.
This was the first script I put in frame 40, to stop the movieclip playing.
mycar.stop()
It didn't work, so I tried the following steps. In "mycar" movie clip, I placed static wheels in frame 11. Then I put the following script in frame 40.
mycar.goandstop(11)
It didn't work, either. The car wheels keeps spinning no matter what.
Am I able to control movieclips through actions in a frame, when the playhead enters? It is a bit like Director, e.g.:
on exitframe
do this
do that
end exitframe
Can you, please, help me out? Apologises for the long post!
-
Hi,
yes - you can do exactly what you wanted. The best way is probably your 'code in frame 40' plan.
The problem probably comes from not targetting the correct movie clip with your code.
Presumably (hopefully ) you have a single movie clip symbol with the spinning wheel and have then placed it 4 times into the car movie clip? (or perhaps twice)
If so, first make sure each wheel has an instance name. A good choice would be 'wheel0', 'wheel1', etc. If the layer on which a wheel resides has a keyframe, you have to rename the wheel again (at each keyframe).
The stop the wheels, put this code into frame 40: (based on 4 wheels):
Code:
wheels = 4;
for(i=0;i<wheels;i++)
this["wheel" + i].stop();
That should do it. It's a little tricky to get right without seeing the exact structure of your movie clip + animations but perhaps you can take it from here...
- n.
-
Hmm....
I'm sure I didn't duplicate the wheels or the movie clips.
I think I'll upload a quick demo tonight, just to show what I'm talking about.
Thanks for your help.
-
ok
if you do post a demo, maybe post the FLA as well - that would be useful to see the structure and determine how to target the wheels.
good luck - n.
-
YAYYYY!!!!
I finally got it working!! My mistake was naming the movieclip's instance name.
What happened was I dragged the movieclip onto the stage, and made a keyframe thus splitting them into two. In Frame terms, one was set to Motion and the other was set to none. In the 'Motion' version, it had the instance name but the other one did NOT have one. I think it somehow affected the Actionscript I made.
I started all over again, this time naming the instance as a whole. That's what got it working.
I've learnt a lesson!
-
---------------
if you do post a demo, maybe post the FLA as well - that would be useful to see the structure and determine how to target the wheels.
-----------------
I won't posting the demo now, I've managed to fix the problem, but thanks for your help. You gave me an idea about the instance name. Just a few mins after reading your post, the demo was working.
Cheers!
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|