-
anyone else hear that?
Duplicate MC and slide??
I've got a clip that I want to duplicate and then slide onto the stage into a certain position, then duplicate again and slide next to the previous clip.
I've got the clips duplicating and positioning in their final location using:
// Change value of "clipName" to non-numeric portion of movieClip instance name.
clipName = "card";
// Get the height and width of movie.
movieHeight = _root._height;
movieWidth = _root._width;
// Get width of movieClip to be duplicated.
clipWidth = eval(clipName+"1")._width;
// Get total number of clips.
totalClips = Number(5);
// Generate clips.
for (i=1; i<totalClips; i++) {
duplicateMovieClip(clipName+i, clipName+(i+1), i+1);
eval(clipName+(i+1))._x = (eval(clipName+(i+1))._x)+5+clipWidth;
}
// Get height and width of this movieClip.
totalClipHeight = this._height;
totalClipWidth = this._width;
// Reposition to the center of the stage.
this._x = (movieWidth-totalClipWidth)/2;
this._y = movieHeight/2;
How would I make each clip slide from a specific location (240,340) into their respective locations???
TIA
-
Keeper of Brooms and Jars
i would write a move function such as
code:
speed=.4;
function slide(){
var xDist=this.xTarget-this._x;
var yDist=this.yTarget-this._y;
this._x+=xDist*speed;
this._y+=yDist*speed;
if(xDist<.5){
delete(this.onEnterFrame);
}
}
then define xTarget and yTarget values for each mc and assign the slide function to it like so
code:
for(i=0;i<totalClips;i++){
clip=attachMovie("clip", "clip"+i, i);
clip.xTarget=i*(clip._width+20);
clip.yTarget=i*(clip._height+20);
clip.onEnterFrame=slide;
}
and i would suggest using the attachMovie method instead of duplicateMovieClip, as it is easier to create an instance and reference directly after for purposes of setting props and functions, etc.. good luck
-
anyone else hear that?
Cool!! Very close...
I just want them to slide out one at a time, not all at once...and I need to be able to put a slight pause between each slide...
do-able?
THANKS!!!
-
Keeper of Brooms and Jars
i havent done a lot of time based actionscripting so there might be a better way to do this but... here is all of the code including that which i already posted:
code:
speed=.2;
function slide(){
var xDist=this.xTarget-this._x;
var yDist=this.yTarget-this._y;
this._x+=xDist*speed;
this._y+=yDist*speed;
if(xDist<.5){
delete(this.onEnterFrame);
}
}
totalClips=5;
clips=0; //similar to the variable 'i' in the 'for' loop
frameRate=20;
delay=1; //seconds
//init is an empty movieclip on stage that this code can be run on
//this replaces the 'for' loop and instead duplicates the movies based on the framerate and delay variables
init.onEnterFrame=function(){
frames++;
if(frames%(delay*framerate)==0){
if(clips<totalClips){
clip=attachMovie("clip", "clip"+clips, clips);
clip.xTarget=clips*(clip._width+20);
clip.yTarget=clips*(clip._height+20);
clip.onEnterFrame=slide;
clips++;
}
}
}
that should do it!
-
eveningtidemusic.com
hate to revive an old post like this but...
This sounds exactly like what I need but I can't get it to work. I have a bunch of diamonds I want to slide in next to each other but with the script above I can't even get anything to move.
Thanks for the help.
-
Keeper of Brooms and Jars
could you be a little more specific about how you want your clips to move? where do they start/end up, when do they move.. etc. that will help us help you.
-
eveningtidemusic.com
I want to have some duplicated diamond shaped (10px x 10px) mc's slide onto the stage. So the first mc would slide in from off stage to say about an x value of 700. Then right after that the second dulicated mc would slide in just to the left of the first one and so on. I hope this makes sense. Thanks again.
-
eveningtidemusic.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|