Hello there!
I’m not the most savvy person when it comes to programming, so please forgive me if this is a really silly question.
I want to make a ball move across the stage, but you can create up to five points on the screen that the ball will go to first.
So far I’ve been able to figure out how to get the coordinates defined, but getting the ball to move to them is driving me nuts! I’m trying to use the tween command but so far, no luck.
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import flash.events.MouseEvent;
import flash.display.MovieClip;
var count:Number = 0;
var mark_mc:Array = new Array();
var xPosArray:Array = new Array();
var yPosArray:Array = new Array();
stage.addEventListener(MouseEvent.CLICK, stagePoints);
function stagePoints(e:Event):void{
count++;
if(count > 5){
trace(“no more points please”);
}
else{
var waypoint:Waypoint = new Waypoint();
addChild(waypoint);
var xPos:Number;
var yPos:Number;
xPos = mouseX;
yPos = mouseY;
xPosArray.push(xPos);
yPosArray.push(yPos);
trace("xPosArray = " + xPosArray);
trace("yPosArray = " + yPosArray);
waypoint.x = xPos;
waypoint.y = yPos;
}
}
start_btn.addEventListener(MouseEvent.CLICK, playCode);
function playCode(e:MouseEvent):void{
var ballTween:Tween = new Tween(ball_mc, “x”, None.easeInOut, ball_mc.x ,510, 10, true);
Thanking you in advance.