Hi,
I was reading through one of the tutorials from kirupa found here http://www.kirupa.com/developer/flashcs3/movieclips_classes_AS3_pg2.htm
I got a lot out of it =]
but when i tried modifying the code to add a hitTest on it, it became “weird”
here is my .as file
[COLOR=Red]package {
import flash.display.;
import flash.events.;
import flash.geom.Point;
public class Sq extends MovieClip {
var radians =0;
var speed =0;
var radius =0;
var randomValue=0;
public function Sq() {
speed =.01+.5*Math.random();
radius =2+10*Math.random();
randomValue= Math.random()*1;
this.x = Math.random()*550;
this.y = Math.random()*400;
this.rotation = Math.random()*360;
this.scaleX = this.scaleY = randomValue;
this.alpha = 1-randomValue;
this.addEventListener(Event.ENTER_FRAME, rotateSq);
}
[COLOR=Blue]function rotateSq(e:Event) {
if (this.hitTestPoint(mouseX,mouseY,true)) {
radians+=speed;
//trace("test works");
this.x+=Math.round(radius*Math.cos(radians));
this.y+=Math.round(radius*Math.sin(radians));
}else{
trace("nope");
}
}
}[/COLOR]
}[/COLOR]
the effect i’m trying to accomplish is when the user rolls over one of the MC’s added
by the following function inside the .fla
[COLOR=Red]function AddSq() {
for (var i:int =0; i<50; i++) {
var newSq:Sq = new Sq();
this.addChild(newSq);
}
}
AddSq();[/COLOR]
is that the MC(which is a square) starts moving in a circle. but it seems that the hit area is in a different location and the square is in another.
is there something i’m doing wrong?
Thanks!