PDA

View Full Version : IF / ELSE IF / _currentframe / Playhead Location



jaredburns
June 29th, 2004, 02:47 PM
I am having difficulty determining where the playhead is located in the timeline. Let me give you an idea of what I am trying to accomplish. I have 3 buttons. onRelease the playhead will go to a specified frame depending on the current location of the playhead.

See if this image helps.

http://clearchannelsatellite.com/_jjb/flash.jpg

Basically what will happen is this.

1. If button 1 is clicked, if the playhead is at frame 1 ("B1"), nothing will happen, if the playhead is at frame 6 ("B2"), it will gotoAndPlay("2to1"), if the playhead is at frame 11 ("B3"), it will gotoAndPlay("3to1").

2. If button 2 is clicked, if the playhead is at frame 6 ("B2"), nothing will happen, if the playhead is at frame 1 ("B1"), it will gotoAndPlay("1to2"), if the playhead is at frame 11 ("B3"), it will gotoAndPlay("3to2").

3. If button 3 is clicked, if the playhead is at frame 11 ("B3"), nothing will happen, if the playhead is at frame 1 ("B1"), it will gotoAndPlay("1to3"), if the playhead is at frame 6 ("B2"), it will gotoAndPlay("2to3").

After it plays, there is a gotoAndStop action to go to the appropriate frame, B1, B2, or B3.

The following script is how I had hoped to achieve this, but its obviously not working. It is located on layer actions_btns.

button1_btn.onRelease = function () {
if (_currentframe = 1) {
gotoAndStop("B1");
} else if (_currentframe = 6) {
gotoAndPlay("2to1");
} else if (_currentframe = 11) {
gotoAndPlay("3to1");
}
}
button2_btn.onRelease = function () {
if (_currentframe = 6) {
gotoAndStop("B2");
} else if (_currentframe = 1) {
gotoAndPlay("1to2");
} else if (_currentframe = 11) {
gotoAndPlay("3to2");
}
}
button3_btn.onRelease = function () {
if (_currentframe = 11) {
gotoAndStop("B3");
} else if (_currentframe = 1) {
gotoAndPlay("1to3");
} else if (_currentframe = 6) {
gotoAndPlay("2to3");
}
}

Please help!!!

Chow!

claudio
June 29th, 2004, 02:50 PM
Please do not crosspost jaredburns.

Prophet
June 29th, 2004, 07:22 PM
ok first thing i noticed is that you signed off with chow - that means food rather than ciao which means good bye ;)
second thing i noticed is that you have oh so many motion tweens... just out of interest... have a search on "easing" and see if that helps you do all of the above in one frame... coz thats similar to what i used to do... but then i found easing and all was right with the world ;) lol

Prophet.

jaredburns
June 30th, 2004, 10:49 AM
Chow...ha...thats funny. Who knows maybe I was hungry. Thanks.

At any rate, I think you may be confused at what I am trying to do. At the end of each tween there is an action that redirects the playhead to a specific frame. For example: If frame "21" is played, once it reaches the the frame before "31", it will gotoAndStop "B1". Basically what needs to happen is when button 1 is clicked, I must find out where the playhead is (it can only be at B1, B2, or B3) and if its at B1, nothing happens, if its at B2 the gotoAndPlay "21" in which it will then be directed to frame "B1", or finally if the playhead is at "B3" then a gotoAndPlay "31" action will occur and again at the end of the tween, be directed to frame "B1".

By the way, virtually all the frames have easing effects.

Thanks! CIAO! =)

jb

Prophet
June 30th, 2004, 05:41 PM
i meant AS easing methods - can you check as to where the _x and/or _y values are within a certain area rather than check for the playhead position? i dunno coz i dunno wat ur project is... an fla/swf might help?

Ciao ;)

Prophet.