all groups > flash actionscript > september 2004 >
You're in the

flash actionscript

group:

button in a movie clip



button in a movie clip confusedAgain
9/6/2004 5:29:08 PM
flash actionscript: Hi, I have a movie clip with 3 keyframes of code that allows it to move around
randomly on the stage. I want the main movie to advance to a particular part
of the timeline when the mc is clicked. I put a button inside the mc with this
code on it.

on(release) {
_root.gotoAndPlay(141);
}

My button is not working however. Any theories or do you need more info?
Thanks.

tc
Re: button in a movie clip _jrh_
9/6/2004 5:34:30 PM
Re: button in a movie clip confusedAgain
9/6/2004 6:02:32 PM
Re: button in a movie clip _jrh_
9/6/2004 6:04:13 PM
Re: button in a movie clip confusedAgain
9/6/2004 6:09:20 PM
Thanks. Here is the code that's on the movie clip.
First keyframe:
speed = 5;
craziness = 5 + random(5);

movie_width = 650;
movie_height= 500;

radians_per_degree = (2 * Math.PI) / 360;

counter = 0;

2nd keyframe:
if (counter >= craziness) {
// change direction
//bug._rotation += (90 - random(180));
rotation_amount = (90 - random(180)) / craziness;
counter = 0;
}

// Get the bugs global position
globalBugPoint = new Object;
globalBugPoint.x = bug._x;
globalBugPoint.y = bug._y;
localToGlobal(globalBugPoint);

if (globalBugPoint.x <= 0) {
bug._rotation = 45 + random(90);
counter = 0;
} else if (globalBugPoint.x >= movie_width) {
bug._rotation = 225 + random(90);
counter = 0;
} else if (globalBugPoint.y <= 0) {
bug._rotation = 135 + random(90);
counter = 0;
} else if (globalBugPoint.y >= movie_height) {
bug._rotation = 315 + random(90);
}

bug._rotation += rotation_amount;
dx = Math.cos((bug._rotation+270) * radians_per_degree) * speed;
dy = Math.sin((bug._rotation+270) * radians_per_degree) * speed;
bug._x += dx;
bug._y += dy;
counter++;

3rd keyframe:
gotoAndPlay (2);

Does this help at all?
Re: button in a movie clip _jrh_
9/6/2004 6:14:20 PM
Re: button in a movie clip confusedAgain
9/6/2004 6:20:46 PM
no, it doesnt even look like the button is being recognized at all(i.e. cursor
doesnt change when it is moved over mc).
It worked fine before when I had a simpler mc with the button in it. I dont
know if something in the new code is overriding the button code or what.
Re: button in a movie clip _jrh_
9/6/2004 6:39:58 PM
Re: button in a movie clip confusedAgain
9/6/2004 7:18:05 PM
Thanks for your help jrh. I think I figured out what the problem is.
Somewhere along the line it looks like a 2nd mc was put in that was more or
less between the mc and the button. Not sure how this happened but anyhow it
works fine now. Thanks again!!!
Re: button in a movie clip _jrh_
9/6/2004 7:39:12 PM
AddThis Social Bookmark Button