|
-
Tween via Array?
Hi there;
I'm working on a for-fun project where I have a bunch of letters, in a row, that are jumbled. What is supposed to happen is that if you press one of the letters, then press another, and it is supposed to tween the two of them to the others position. For some reason though, the tween doesn't seem to be working (Since there are about 12 or 13 letters, I was planning on temporarily placing the two to be tweened into an array, and then tween them via the array)
Here is my code
PHP Code:
import flash.events.MouseEvent
import flash.geom.Point
import com.greensock.TweenLite;
import com.greensock.easing.*;
var tempPoint:Point = new Point(0,0);
var movePoint:Point = new Point(0,0);
var queue:Array = new Array;
var i:int = 1
hint_mc.visible = false;
trace(tempPoint);
hint.addEventListener(MouseEvent.MOUSE_UP, giveHint)
function giveHint(me:MouseEvent):void{
switch(hint_mc.visible){
case(false):
hint_mc.visible = true;
break;
case(true):
hint_mc.visible = false;
break;
}
}
a_text.addEventListener(MouseEvent.MOUSE_UP, switchA)
h_text.addEventListener(MouseEvent.MOUSE_UP, switchH)
function switchA(me:MouseEvent):void{
if(tempPoint.x == 0 && tempPoint.y == 0){
tempPoint.x = a_text.x
tempPoint.y = a_text.y
queue[0] = a_text
trace(tempPoint);
}else if(movePoint.x == 0 && movePoint.y == 0){
movePoint.x = a_text.x
movePoint.y = a_text.y
queue[1] = a_text
trace(movePoint)
i = 0
}else{
return;
}
}
function switchH(me:MouseEvent):void{
if(tempPoint.x == 0 && tempPoint.y == 0){
tempPoint.x = h_text.x
tempPoint.y = h_text.y
queue[0] = h_text
trace("The temporary point is " + tempPoint);
}else if(movePoint.x == 0 && movePoint.y == 0){
movePoint.x = h_text.x
movePoint.y = h_text.y
queue[1] = h_text
trace("The movement point is " + movePoint)
i = 0;
}else{
return;
}
}
while(i < 1){
TweenLite.to(queue[0], 1, {x:movePoint.x, y:movePoint.y, ease:Linear.easeNone, delay:0, overwrite:false});
TweenLite.to(queue[1], 1, {x:tempPoint.x, y:tempPoint.y, ease:Linear.easeNone, delay:0, overwrite:false});
tempPoint.x = 0
tempPoint.y = 0
trace("The tween should have worked. If it did not, then there is something fatally wrong with your coding. Eat a taco and then try again.")
movePoint.x = 0;
movePoint.y = 0;
i++;
}
Last edited by Bryguy; 02-08-2010 at 07:51 PM.
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
|