Not yet rated

Problem

I am making a simple slideshow for photos. I have a play button that uses "go to frame and play". On the timeline I've placed a large photo in a keyframe. I have a keyframe with the photo's alpha at 0, classic tweened for 9 frames to the end keyframe which is at alpha 100. On the next frame is a keyframe of the photo with a stop () and then the next frame is a keyframe to start a tween back to 0 alpha. Then I begin with another photo. Photos fading in and out using a next button to "fl_ClickToGoToAndPlayFromFrame_12". I need "fl_ClickToGoToAndPlay Reverse FromFrame_12" so I can send the playhead back through the tweens to the previous photo fading in and out ! It seems the only way to do it is to AS3 code it and I am a newbe graphic artist that can't understand computer code at all. HELP!

Solution

There isn't a built in solution no real back button to animate back what you did but fear not there are solutions ;)

Detailed explanation

All timeline aniamations without any extra code on the timeline:

That's easy i built out for you quickly a sample here it is and i'll explain it after:

import flash.events.Event;

reverseAndStop('label-name2');

var lbl:*;
function reverseAndStop(lbl:*):void{
    this.lbl = lbl;
    addEventListener(Event.ENTER_FRAME,onStepBack);
}

function onStepBack(e:Event):void{
    if(currentFrameLabel==lbl || currentFrame ==lbl){
        removeEventListener(Event.ENTER_FRAME,onStepBack);
    }else{
        gotoAndStop(currentFrame==1?totalFrames:currentFrame-1);
    }
}

What this quick code snippet does is uses an ENTER_FRAME to go back and test to see if it hit the current frame you waned to get to , it can be a label(string) or an integer for a frame number both would work. there i built it right now so there is a few issues such as the name of the function probably is just funny and not a good one and if you send an invalid label there is no management to it so it would just continue going back until the start if you don't send the right value it will just continue to the start and then back to the last frame and never end until it hits a new command. and the worst part is the removal of the event never will happen if it doesn't hit a valid value a good extra to add to this is an error manager that would throw an error if you ask for a frame that doesn't exist.

Now if your working with code and time line together i really recommend you check out Jack Doyle's TimelineLite http://www.greensock.com/timelinelite/

if any one has more goodie ideas please feel free to add them up here ;)

Thanks in advance to you if you twitter/comment/link/give a good score ;)

_
Ben Fhala

Flash/AS3 School  || Follow  @02geek ||  Youtube Channel || EventController  || More Recipes

In the spotlight: Learning How to develop is not hard - 11 hours focused on breaking into the basic as3 development skills

P.S. If you want to call my attention to a request
add @02geek to the title or twitter
my nickname and a link to your post.


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes