Copy link to clipboard
Copied
I am trying to get a Movie Clip to crawl back and forth, stopping at 12 specific points controlled by 12 separate buttons.
In other words when you click on button 3 the Movie Clip slides to position 3 (X position or frame number), then click button 9 it slides to position 9, click on button 1 it slides back to position 1 etc.
I can make jump to the positions and stop but I can’t make it crawl (slide) to the next x position or to go back to a previous x position.
I am very new to flash and I thank you for any help.
Found this in a tutorial but I don’t know how to modify it to do what I want.
stop();
button1_btn.addEventListener(MouseEvent.CLICK, Shoot_1)
function Shoot_1(event:MouseEvent):void
{
gotoAndPlay(1)
}
Using flash cs5, ActionScript 3 on a PC. This is for a presentation shown in a conference room.
Thanks again,
Pablo
no, you're not setup correctly for that code.
that code uses no timeline tweening. it uses tweenlite to tween you object and includes all that's needed to do what you want.
Copy link to clipboard
Copied
// use a decent tweening engine like TweenLite:
import gs.TweenLite;
var positionA:Array=[[x1,y1],[x2,y2],...,[x12,y12]];
for(var i:int=0;i<positionA.length;i++){
this["button"+(i+1)].addEventListener(MouseEvent.CLICK,clickF);
}
function clickF(e:MouseEvent):void{
var index:int = int(e.currentTarget.name.split("button")[1]);
TweenLite.to(yourmovieclip,.5,{x:positionA[index][0],y:positionA[index][1]});
}
Copy link to clipboard
Copied
Thanks I'm so new to flash I really am lost.
Never even heard of TweenLite.
Copy link to clipboard
Copied
get it here: http://www.greensock.com/tweenlite/
open TweenLite.as to see how to use it though you can just copy and paste the code i suggested for this project.
Copy link to clipboard
Copied
kglad, Thanks again.
I can't make it work because I'm such a noob I don't know exactly where to enter my instance names for my 12 buttons and my 1 sliding movie clip.
I have been experimenting but to no avail. Actually I have spent 4 days searching for a tutorial explaining this and reading everything I could find before I finally stopped the truck and asked for directions.
I'm not sure I have it set up correctly to do this in the first place.
What I have is 100 frames, 12 button instances named button1_btn, button2_btn, etc. on 12 different layers. 1Movie Clip instance named big_tl, size W:2879.95 x H:259.20 Starting position is off stage at X552 Y47.
It crawls from X552 Y:47 to X -2430 Y47 using classic tween in 100 frames.
The movement I’m trying to achieve is:
button1 slides from wherever it is currently to X185 Y47 or frame 13,
button2 X39 Y47 or frame 18 etc.
So my questions are too many but, Am I set up correctly for this code? And could you please instruct me further as to how I fill out the code?
Thank you again for your time and patience.
Copy link to clipboard
Copied
no, you're not setup correctly for that code.
that code uses no timeline tweening. it uses tweenlite to tween you object and includes all that's needed to do what you want.
Copy link to clipboard
Copied
I finally got it to work. Thanks kglad!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now