im currently working on my own version of bejewelled for those of you who know the game.
i have a 6x6 grid of 50x50px colored blocks.
i have a function which simply, takes two blockes, switches their positions, then switched them back. it works fine as long as i dont attempt to switch the same two blocks a second time, if i do the aimation breaks up, skips or just dosent happen at all. Any ideas?
/* ********************************************
* Swap Adjacent Block
* - From (x, y)
* - To (x, y)
* ******************************************** */
function playTweenBack(x1:Number, y1:Number, x2:Number, y2:Number):Void{
var block1:String = "B" + String(x1) + String(y1);
var block2:String = "B" + String(x2) + String(y2);
var ox1:Number = this[block1]._x;
var ox2:Number = this[block2]._x;
var oy1:Number = this[block1]._y;
var oy2:Number = this[block2]._y;
if(x1 == x2){
var blockTween1:Tween = new Tween(_root[block1], "_y", None.easeNone, oy1, oy2, .5, true);
var blockTween2:Tween = new Tween(_root[block2], "_y", None.easeNone, oy2, oy1, .5, true);
blockTween1.onMotionFinished = function() { blockTween1.continueTo(oy1, .5); }
blockTween2.onMotionFinished = function() { blockTween2.continueTo(oy2, .5); }
}else if(y1 == y2){
var blockTween1:Tween = new Tween(_root[block1], "_x", None.easeNone, ox1, ox2, .5, true);
var blockTween2:Tween = new Tween(_root[block2], "_x", None.easeNone, ox2, ox1, .5, true);
blockTween1.onMotionFinished = function() { blockTween1.continueTo(ox1, .5); }
blockTween2.onMotionFinished = function() { blockTween2.continueTo(ox2, .5); }
}
}
each block is a move clip which is an instance of a “Block” class which have onRollOver, onRollOut and onPress behaviours.