Turn A Combination Lock In AS2?
A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Turn A Combination Lock In AS2?

  1. #1
    Junior Member
    Join Date
    Apr 2013
    Posts
    3

    Turn A Combination Lock In AS2?

    Hey, guys. I'm upgrading my portfolio with new graphics and flash navigation. I'm out of ideas to make a "combination lock" type of animation work using AS2.

    I need a movie clip of a lock dial to move upwards or downwards based on button clicks. So far, I can only get the movie clip to move in forward order from A to B but not from B to A. I'm using a movie clip that goes to markers A to B to C and then to D. I need to make this clip move in a non-linear to each letter.

    My AS skills are limited. I think I need to set a "current letter" variable and then have the animation move from this "current letter" point either up or down the number range based on the click. Do you guys have any ideas how to do this?

    My source files are here: FLA (16mb), the SWF (1MB) and a zipped file (15mb) with both files.

  2. #2
    Junior Member
    Join Date
    Apr 2013
    Posts
    3
    The source files appear to be difficult to download. I am unable to edit my previous post. I am re-posting the source file links here:
    FLA
    SWF
    ZIP

  3. #3
    Senior Member
    Join Date
    Nov 2012
    Posts
    106
    I figured out one way to do what you are asking... My solution is to use greensock.com free tween engine to create a tween to your desired frame...

    You will need to do 3 things:
    1) go to www.greensock.com and download the as2 version of the latest tween engine and follow directions to get it to work with your flash document.

    2) in your main timeline, you will need to put this following code:
    Code:
    import com.greensock.TweenLite;
    import com.greensock.plugins.*;
    TweenPlugin.activate([FramePlugin]);
    
    function updatePosition(number)
    {
    	TweenLite.to(windmill_mc,1,{frame:number});
    }
    this function accepts a number and will navigate to that frame.

    3) you will need to put this code on each of your buttons.
    Code:
    on (release) {
    	_root.updatePosition(50);//you will need to modify this number to go to the exact space you want.
    }

  4. #4
    Junior Member
    Join Date
    Apr 2013
    Posts
    3

    Thumbs up Thank You, Problem Solved.

    Thank you for such a precise answer. This SWF works great now. Greensock is a very nice app for Flash. It's simplified my task of complex coding down to knowing which frame I want to send the movie clip to.

    I implemented your answer by placing all the code in the first frame of the main timeline and referring to each button instance (btn1,btn2, btn3...) to drive the clip.

    import com.greensock.TweenLite;
    import com.greensock.plugins.*;
    TweenPlugin.activate([FramePlugin]);

    function updatePosition(number) {
    TweenLite.to(windmill_mc,1,{frame:number});
    }

    this.btn_1.onRelease = function() {
    _root.updatePosition(1); //refers to the A position of the windmill movie clip
    };

    this.btn_2.onRelease = function() {
    _root.updatePosition(26); //refers to the B position of the windmill movie clip
    };

    this.btn_3.onRelease = function() {
    _root.updatePosition(47); //refers to the C position of the windmill movie clip
    };

    this.btn_4.onRelease = function() {
    _root.updatePosition(71); //refers to the D position of the windmill movie clip
    };
    Thanks, again.

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

Poll by Flashkit.com