Friday, 25 September 2009

action script for making a sliding effect portfolio

//note when building this you will need, to build your images - buttons, inside (mc)
var cuurobj;
var easing = 6;
var hmiddle = Stage.width/2;
var vmiddle = Stage.height/2;
stop();
onEnterFrame = function () {
objh_v = _root.objholder_mc._y;
objh_h = _root.objholder_mc._x;
vdiff = vmiddle-objh_v;
hdiff = hmiddle-objh_h;
obj_h = _root.objholder_mc["object"+currobj+"_mc"]._x;
obj_v = _root.objholder_mc["object"+currobj+"_mc"]._y;
finalvdiff = vdiff-obj_v;
finalhdiff = hdiff-obj_h;
_root.objholder_mc._y += finalvdiff/easing;
_root.objholder_mc._x += finalhdiff/easing;
};
_root.objholder_mc.object1_mc.onPress = function () {
currobj = 2;

};
_root.objholder_mc.object2_mc.onPress = function () {
currobj = 3;
};
_root.objholder_mc.object3_mc.onPress = function () {
currobj = 4;
};
_root.objholder_mc.object4_mc.onPress = function () {
currobj = 1;
};
_root.objholder_mc.butt1_btn.onPress = function () {
currobj = 1;
}


//have fun!

No comments: