Slowing Down and Layering a Sliding _mc clip

Trouble finding the right code for slowing down a movie clip on rollov

Page 1 of 1

0 Replies - 742 Views - Last Post: 04 January 2009 - 04:43 PM

#1 cr_amh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 04-January 09

Slowing Down and Layering a Sliding _mc clip

Posted 04 January 2009 - 04:43 PM

Hi, I've been having a hard time figuring out the right code to slow down my movie clip, when cursor is placed hard right/left on the stage.

I've tried about everything I thought would slow it but it seems like I end up causing it to stop or not show up on stage.

I've also been trying to figure out how to layer this _mc in the flash document under another layer. (Basically to add a skin layer above it). Would I need to make it a child?


Any help would be seriously appreciated.

Thanks so much for any (much needed) help!







kNbrPictures = 4;

kPictureWidth = 258
kPictureHeight = 294

//Images Y coordinate (top)
var kPictureY=735  //Center on stage
// var kPictureY=100

// Array to hold pictures
pix = [];

for (a=1;a<=kNbrPictures;a++){
	var ID:String="img"+a

	var Clip=_root.attachMovie(ID,ID,this.getNextHighestDepth())
	Clip._y=kPictureY

	Clip.onRollOver=function(){
		this._alpha=70
	}
	Clip.onRollOut=function(){
		this._alpha=100
	}
	
	pix.push(Clip)
}

kCellWidth = kPictureWidth + 20;

// These numbers affect positioning and mouse
// sensitivity
kStretchFactor	= 2;
kStretchSensitivity = 0.8;
kMouseSensitivity = .001;

CX = Stage.width/2;

pixPos = 0;

ppToX = function(pixPos, i)
{
  // pixpos is the current position on the wheel
	// i is the slot number of this particular image

	// wrap i around to fall on either side of pixPos
	if (i < pixPos-kNbrPictures/2)
	{
		i += kNbrPictures;
	}
	else if (i > pixPos+kNbrPictures/2)
	{
		i -= kNbrPictures;
	}

	var di = i - pixPos;

	// di represents a linear scaling index for the picture
	// position (-3,-2,-1,0,1,2,3)
	// Here we add an additional amount to get the stretching effect
	// Omit this line for linear positioning
	di *= Math.pow(kStretchFactor,Math.abs(di*kStretchSensitivity));

  // CX-kCellWidth/2 represents the center position...
  return (CX-kCellWidth/2)+di*kCellWidth;
}


/*
// stub function to create colored rectangle
getColor = function(t)
{
	r = (t*256) % 256;
	g = ((t+1/3)*256) % 256;
	b = ((t+2/3)*256) % 256;
	return (r << 16) + (g << 8) + b;
}

makePicture = function(i)
{
	var mc = _root.createEmptyMovieClip("pic_" + i, i+1);
	mc.clear();
	mc.beginFill(getColor(i/kNbrPictures),100);
	mc.moveTo(0,0);
	mc.lineTo(kPictureWidth, 0);
	mc.lineTo(kPictureWidth, kPictureHeight);
	mc.lineTo(0, kPictureHeight);
	mc.lineTo(0, 0);
	mc.endFill();
	mc._y = 10;
	return mc;
}


// Initialization - setup the pictures
for (var i = 1; i < kNbrPictures; ++i)
{
	pix[i] = makePicture(i);
}
*/

// Animation routine
_root.onEnterFrame = function(){
  // Use mouse to effect pixPos (the wheel position)
	pixPos += (_xmouse - CX)*kMouseSensitivity;
	if (pixPos < 0)
		pixPos += kNbrPictures;
	else if (pixPos > kNbrPictures)
		pixPos -= kNbrPictures;

	// Reposition each picture
	for (var i = 0; i < kNbrPictures; ++i) {
		pix[i]._x = ppToX(pixPos, i);
	}
}




Is This A Good Question/Topic? 0
  • +

Page 1 of 1