Guys please help! I can only make circ(name of the movieclip in library) move horizontally and vertically using the .x and .y. How do I make it move diagonally?
Here are the codes I used: (I’ve also attached the AS and FLA files)
package
{
import flash.display.MovieClip;
import flash.events.*;
public class ex03 extends MovieClip
{
public var circ:circleClass;
public var dir:String = 'right';
public function ex03()
{
stop();
displayCircle();
stage.addEventListener(Event.ENTER_FRAME,moveCircle);
}
public function displayCircle()
{
circ = new circleClass();
circ.x = stage.stageWidth/2;
circ.y = stage.stageHeight/2;
circ.width = 100;
circ.height = 100;
addChild(circ);
}
public function moveCircle (event:Event)
{
if(circ.x >= stage.stageWidth - (circ.width/2))
{
dir='left';
}else if(circ.x<= circ.width/2){
dir='right';
}
if(dir=='left')
{
circ.x-=15;
}else{
circ.x+=15;
}
}
}
}