A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Buttons whos Actions Depend on States of other Buttons -HOW?

  1. #1
    Junior Member
    Join Date
    Nov 2007
    Posts
    7

    Question Buttons whos Actions Depend on States of other Buttons -HOW?

    Hi,

    I’ve made a 3D animation as a background to my homepage, and have imported it into Flash CS3 as a series of still TIFF images (one image on each frame).

    Now I am looking to control this animation using a series of 9 buttons. At the moment each button does the following:

    Button1: Play frames 0120. Stop.
    Button2: Play frames 2130. Stop.
    Button3: Play frames 3140. Stop.
    …etc.

    However, I want to make each button’s action dependant on the states of the other buttons:

    When the user presses any of the 8 buttons other than the one that is currently engaged, I want the animation relating to the button that is currently engaged to be played in reverse, and then the animation belonging to the button that has just been pressed to be played!

    For example, if Button 1 has been pressed, then the user presses Button 2, I want frames 2001 and then frames 2130 to be played. Another example; Button 3 is engaged, user presses Button 1 – frames 4031 should be played and then frames 0120.

    If anyone could help me with the ActionScript to perform this (ideally AS3 but AS2 is fine) then I would be extremely, extremely grateful.

    Thanks in advance for any comments.
    Ben.

  2. #2
    Junior Member
    Join Date
    Mar 2001
    Posts
    6
    Ya know...There is a way to do this without knowing a ton of action script.
    You can fake it..Create movies that are the reverse of your current movies so it only "looks" like its going in reverse...

    Then..you can use variables, if statements and functions to find out what the user has pressed and where they want to go. In fact the functions don't even have to be functions but can be movies that act like functions.

    My point is. Someone here will provide you with some hardcore action script that you most likely wont understand but will work..Or you can easily attack this on your own and learn how flash "thinks" by doing it the rudimentary way...

    My 2

    If you would like this plan..i can help walk you through it.
    Last edited by JBOMB; 11-02-2007 at 05:54 PM.

  3. #3
    Senior Member
    Join Date
    Oct 2003
    Posts
    1,354
    I agree with JBOMB, the coding is alot easier if you have a transition out. I also prefer to have each transition in its own movieClip. This way you can have more than one movieClip playing. In the attached example, I begin the transition in, before the transition out is complete.

    There are four movieClips that are not visible on the main timeline, if you unlock one of the layer and click ithe center of the stage, you will find them. They have a movieClip with alpha set at 0 to begin with. Inside each of those movieclips, you will see that i have the playIn() function on frame 30 instead of at the end of the timeline in order to overlap the transitions.

    http://rapidshare.com/files/67085776/inOut.fla.html
    (to use rapidshare, just click on the 'free' button, then enter the code shown)

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    For a start this will reverse your MovieClip:
    PHP Code:
    var traceFrame:Boolean=false;
    function 
    everyFrame (event:Event):void
    {
        if (!
    traceFrame)
        {
            if (
    clip.currentFrame <clip.totalFrames)
            {
                
    trace (clip.currentFrame);
                
    clip.gotoAndStop (clip.totalFrames);
                if (
    clip.currentFrame == clip.totalFrames)
                {
                    
    traceFrame true;
                }
            }
        }
        else
        {
            
    clip.prevFrame ();
            if (
    traceFrame)
            {
                if (
    clip.currentFrame == 1)
                {
                    
    clip.stop ();
                }
            }
        }
    }
    clip.addEventListener (Event.ENTER_FRAMEeveryFrame); 
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center