Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 09-16-2003, 05:16 AM   #1
3mpathy
Registered User
 
Join Date: Sep 2003
Location: Above a chip shop in London
Posts: 16
Default Quick question about Animation using Actionscript

Found this excellent Tutorial here on AS.org Animation using Actionscript

Can anyone tell me how I would implement this for multiple buttons and animations. i.e. In the tutorial it works great for 1 button and one ball, but what about 5 buttons and 5 balls?

Cheers and grassy arse
3mpathy is offline   Reply With Quote
Old 09-16-2003, 06:12 AM   #2
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

so what??
u need 5 buttons and 5 balls with unique names for each
__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 09-16-2003, 07:38 AM   #3
3mpathy
Registered User
 
Join Date: Sep 2003
Location: Above a chip shop in London
Posts: 16
Default

Ok, maybe I didn't explain it properly. What I'm asking is, where in the code do I put the unique names for each:

onClipEvent (load) {
//this sets the initial target x position for our clip
_root.targX = 50;
}
onClipEvent (enterFrame) {
//this variable stores the current x position of the clip
cX = this._x;
//this variable stores the distance between the clips current x position
//and where we want it to go
//I am setting the targX variable in the root so that it is easy to target with our button
difX = cX-_root.targX;
//this moves the clip 1/5 of the distance every frame.
//Because the difference between the clips current location and its destination
//will get smaller each frame, so will the amount the clip travels each frame.
//This is what makes the clip appear as though it "eases into" it's final destination
setProperty(this, _x, cX-(difX/5));
//check the flash manual to learn more about the setProperty action
}

and your button this action -

on (release) {
//this sets the targX variable to a random number between 0 and 500
_root.targX = random(500);
}


I'm still learning and can't see anywhere to put it.

Cheers
3mpathy is offline   Reply With Quote
Old 09-16-2003, 07:57 AM   #4
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

ahhhhh, ehem
ok, the way this code can be used with is to be attached to the instances (the ball movie clip), so u don't need to give each ball a name as u r not going to call it from other place
but all u need is to set a different target X or Y position for each one
so, in the onClipEvent(load), u give a different name and value for the targX, like
ActionScript Code:
onClipEvent(load){ //for the first ball _root.targ[b]1[/b]X = 50; } onClipEvent(load){ //for the second ball _root.targ[b]2[/b]X = 60; } //and so on
and also to change that on the buttons
__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Old 09-16-2003, 08:12 AM   #5
3mpathy
Registered User
 
Join Date: Sep 2003
Location: Above a chip shop in London
Posts: 16
Default

Ahh, now thats more like it.

Many thanks Farafiro.
3mpathy is offline   Reply With Quote
Old 09-16-2003, 08:18 AM   #6
farafiro
Addicted To FLASH
 
farafiro's Avatar
 
Join Date: Dec 2001
Location: Egyptian in UAE
Posts: 12,436
Send a message via MSN to farafiro Send a message via Yahoo to farafiro
Default

welcome
__________________
‚€* GOD Is Near ‚€*
Questions Don't PM for Questions . Thanks
An eye for an eye, make the whole world blind
_____________________________________________GHANDI
farafiro is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:34 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.