# Flash MX 2004...problem with an elastic effect code

**URL:** <https://forum.kirupa.com/t/flash-mx-2004-problem-with-an-elastic-effect-code/244151>\
**Category:** flash\
**Created:** [November 14, 2007, 6:25pm UTC](https://forum.kirupa.com/t/flash-mx-2004-problem-with-an-elastic-effect-code/244151 "2007-11-14T18:25:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![max999](https://avatars.discourse-cdn.com/v4/letter/m/ac91a4/32.png) [@max999](https://forum.kirupa.com/u/max999)\
**Post date:** [November 14, 2007, 6:25pm UTC](https://forum.kirupa.com/t/flash-mx-2004-problem-with-an-elastic-effect-code/244151/1 "2007-11-14T18:25:43Z")

</div>

Hi I am trying to change the code to this effect , it’s an elastic effect(photogallery) with masking and i have movie clips inside the library linked with the code and all i would like to do is to just do a vertical up and down effect (with 2 bottons) kind of like prev and next (left and right) that i alreadt have in this code but i am a beginner in AS and i can’t figiure it out…here’s the code:  
import mx.transitions.Tween;  
import mx.transitions.easing._;  
var w=800  
var h=600  
num = 5  
function drawSquare(clip, depth, colour, x, y, w, h) {  
var mc = clip.createEmptyMovieClip(“clip”+depth, depth);  
mc.\_x = x;  
mc.\_y = y;  
mc.lineStyle(0);  
mc.beginFill(colour);  
mc.lineTo(w, 0);  
mc.lineTo(w, h);  
mc.lineTo(0, h);  
mc.endFill();  
return mc;  
}  
function drawTriangle(clip, depth, colour, x, y, w, h) {  
var mc = clip.createEmptyMovieClip(“clip”+depth, depth);  
mc.\_x = x;  
mc.\_y = y;  
mc.lineStyle(0);  
mc.beginFill(colour);  
mc.lineTo(w, 0);  
mc.lineTo(w/2, h);  
mc.endFill();  
return mc;  
}  
cliparray = [];  
current = 1;  
currentv=0  
this.createEmptyMovieClip(“holder”, 1);  
holder.\_y =0  
holder.startx = holder.\_x=-600  
for (var i = 0; i\<num; i++) {  
var hh = holder.createEmptyMovieClip(“h”+i, i);  
hh.attachMovie(“p”+i, “p”, 1);  
var t = hh.attachMovie(“t”+i, “t”, 2);  
t.\_y = h;  
//add more here but increae jvar by 1 for each + \_y =2_h,\_y =3_h increase each time  
hh.jvar = 1  
hh.\_x = i_w;  
hh.starty = hh.\_y;  
hh.ivar = i;  
hh.up = false;  
cliparray.push(hh);  
hh.endy = h-hh.\_height;  
}  
holder.endx =w+600-holder.\_width;  
function tweener(tx) {  
var s = new Tween(holder, “\_x”, Elastic.easeOut, holder.\_x, tx, 2, true);  
s.onMotionFinished = function() {  
disableall(true);  
};  
}  
function vertmove(ty,target,callback) {  
onEnterFrame = function () {  
target.\_y += (ty-target.\_y)/3;  
if (Math.abs(ty-target.\_y)\<2) {  
target.\_y = ty;  
delete this.onEnterFrame  
callback()  
}  
};  
}  
function moveleft(){  
if(w-current_w -600\>holder.endx){  
currentv = 0  
current++;  
tweener(w-current_w-600);  
}  
}  
function moveright(){  
if(w-current_w-600\<holder.startx+600){  
currentv = 0  
current–;  
tweener(w-current_w-600);  
}  
}  
function leftF() {  
vertmove(0,cliparray[current],moveleft)

}  
function rightF() {  
vertmove(0,cliparray[current],moveright)  
}  
function upF() {  
if(currentv\<cliparray[current].jvar){  
currentv++  
vertmove(-h\*currentv,cliparray[current])  
}

}  
function downF() {  
currentv=0  
vertmove(-h\*currentv,cliparray[current])  
}

left.onPress = leftF;  
right.onPress = rightF;  
up.onPress = upF;  
down.onPress = downF;  
function disableall(t) {  
left.enabled = t;  
right.enabled = t;  
up.enabled = t;  
down.enabled = t;  
}  
up.swapDepths(10000)  
down.swapDepths(10001)  
left.swapDepths(10002)  
right.swapDepths(10003)  
/_to mask  
var mask = this.createEmptyMovieClip(“m”,100)  
drawSquare(mask, 1000, 0, 0, 100,w_3,h);  
holder.setMask(mask)  
\*/
