A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Click to move + When click image, go to frame in a movie clip

  1. #1
    Junior Member
    Join Date
    Aug 2010
    Posts
    4

    Question Click to move + When click image, go to frame in a movie clip

    1. I would like to know how to make it so when you click somewhere on the screen, your object will move to that place. it doesn't matter if constant speed or not. I just want to know. ANYTHING will help.

    2. I would like to know how to make it so when you click a button, it goes to a different frame within a MOVIE CLIP. Kind of like gotoAndPlay but not a frame in the timeline. I would like it to move to a different frame in a movie clip. Again, ANYTHING will help.

    THANK YOU VERY MUCH!
    Last edited by vivyo; 08-27-2010 at 09:58 PM.

  2. #2
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    hi..

    for #1.

    I suggest you look into using greensock's TWEENMAX (or TWEENLITE) classes

    www.tweenmax.com

    its a GREAT, easy & powerful tweening class/engine with 1000's of practical uses.

    and here is the code:

    //import the GreenSock classes
    import com.greensock.*;
    import com.greensock.easing.*;

    var tweenDuration:Number = .7;
    var newX:Number = 0;
    var newY:Number = 0;

    var mouseListener:Object = new Object();
    mouseListener.onMouseDown = function () {
    newX = _xmouse;
    newY = _ymouse;
    TweenMax.to(circle_mc,tweenDuration,{_x:newX, _y:newY, ease:Elastic.easeOut});
    };
    Mouse.addListener(mouseListener);


    basically everytime you click the louse down,, you record the X/Y values..

    on the same mouse click..you start a tween to the newly recorded X & Y positions..


    attached an example
    Attached Files Attached Files

  3. #3
    Senior Member whispers's Avatar
    Join Date
    Mar 2001
    Location
    CFA2h (respect the HEX)
    Posts
    12,756
    for your second question..

    you just need to use the object/instance's name in the path

    say you have a circle movieClip on the stage.. called: cirlce_mc..

    (inside of this movieClip you have 5 frames.. each having the same circle.. in the same spot..but a different color)

    I made three buttons to control that clips internal timeline:

    button1_btn.onPress = function(){
    circle_mc.gotoAndStop(random(circle_mc._totalframe s));
    }

    button2_btn.onPress = function(){
    circle_mc.gotoAndStop(circle_mc.nextFrame());
    }


    button3_btn.onPress = function(){
    circle_mc.gotoAndStop(3);
    }
    Attached Files Attached Files

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