Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

stopping a mc and getting the current frame 1

Status
Not open for further replies.

polyglot

Programmer
Nov 28, 2007
11
0
0
Hello-

I have posted before and have been able to solve my previous problems... but now I have a new one:

I am creating a game in which I have a movie clip serving as an aimer mechanism so that the player can hit a bullseye target. In the movie clip I have a dot moving back and forth serving as the aiming sight; ideally this is what I want:

The player will click a button. When they click the button, I want the following to happen:

1. The aimer movie clip stops.
2. The program gets the frame number where the movie clip stopped.
3. The program does 3 different things, depending on the frame number of the stopped movie clip (Say - if the frame number is between 1 and 2 or between 10 and 11, the player has missed the target and a dynamic text box tells them "You missed." If the frame number is between 3 and 5 or between 7 and 9, the dynamic text box displays something like "You have hit the periphery." If the frame number is 6, the dynamic text box displays "BULLSEYE!").


I am using the following code, but my game goes beserk and jumps to other frames rapidly and erratically when the button is clicked. The code is not inside the movie clip, but rather on the level on which I have put the clip (level 0?). Can anyone offer any insight? Sorry if the code looks clunky and junky - I am new to Flash and Actionscript.


btnThrow.onRelease = function() {


_root.aimerslow.stop("aimerslow");
_root.sframe = _root.aimerslow._currentframe;
if (_root.sframe <= 24) {
gotoAndStop("victim");
}
}


Thanks,
Monica
 
Hello-

I am re-posting with the same problem I described previously, but I am posting the code and the fla file in hopes that someone will have a looky at it and be able to help me. (The fla file is at and it is called "test.fla"). This is actually not my game fla - it is a new fla that I created to try to isolate the problem with the code, but I have still had no luck fixing it. To simplify things, I have instructed the code to get the current frame number of the aimerslow movie clip, and then I have instructed the code to go to a certain frame in the root timeline (frame label "miss") if the frame number in the aimerslow movie clip is below 13 and to go to another frame in the root timeline (frame label "bullseye") if the frame number in the aimerslow movie clip is 13 or higher. The code works beautifully when the frame number is 13 or higher and it goes to the "bullseye" frame label in the main timeline, but when the frame number is below 13, the program goes to the "miss" frame for a split second and then stops on the "bullseye" frame. I have stop(); statements on both the "miss" frame and the "bullseye" frame, so I do not know why the program is jumping to the bullseye frame when it should stop on the "miss" frame. Please help!!! Here is my code, which is on the root timeline:


stop();

btnThrow.onRelease = function() {
trace("Frame:" + aimerslow._currentframe);

frame = _root.aimerslow._currentframe;


if (frame > 13) {
_root.gotoAndStop("bullseye");
}
if (frame < 14) {
_root.gotoAndStop("miss");
}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top