When using the class listed below, I am unable to add a CLICK function that will not break the piece. I want to add another tween on CLICK that clears all mcs off of the stage except the e.target, which will have a zoom applied to it… I get my trace fine, but then I am unable to CLICK again on that particular mc, and the proximity begins to break. Any suggestions?
Thanks!
package {
// Import Flash classes
import flash.display.*;
import flash.events.*;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
import com.greensock.*;
import gs.easing.*;
import gs.*;
public class ProximityMenu extends MovieClip {
private var ia:Array;
public function ProximityMenu():void {
ia = [im1, im2, im3, im4, im5];
for (var i:uint=0; i<5; i++) {
ia*.buttonMode = true;
ia*.ox = ia*.x;
ia*.oy = ia*.y;
ia*.tx = ia*.ox;
ia*.ty = ia*.oy;
ia*.addEventListener(MouseEvent.ROLL_OVER, onOver);
ia*.addEventListener(MouseEvent.ROLL_OUT, onOut);
//ia*.addEventListener(MouseEvent.CLICK, overAndOut);
}
stage.addEventListener(Event.ENTER_FRAME, onMove);
}
private function onOver(e:MouseEvent):void {
addChild(MovieClip(e.target));
TweenMax.to(e.target, .3, {scaleX:1.5, scaleY:1.5, overwrite:0, ease:Strong.easeOut});
}
private function onOut(e:MouseEvent):void {
addChild(MovieClip(e.target));
TweenMax.to(e.target, .3, {scaleX:1, scaleY:1, overwrite:0, ease:Strong.easeOut});
}
/*private function overAndOut(e:MouseEvent):void {
addChild(MovieClip(e.target));
trace("clicked");
}*/
private function onMove(e:Event):void {
for (var i:uint=0; i<5; i++) {
var dist:Number = getDist(mouseX, mouseY, ia*.ox, ia*.oy);
if (dist < 100) {
ia*.tx = mouseX;
ia*.ty = mouseY;
} else {
ia*.tx = ia*.ox;
ia*.ty = ia*.oy;
}
ia*.x += Math.round((ia*.tx - ia*.x) * 0.3);
ia*.y += Math.round((ia*.ty - ia*.y) * 0.3);
}
}
private function getDist(x1:Number, y1:Number, x2:Number, y2:Number):Number {
var dx:Number = x2 - x1;
var dy:Number = y2 - y1;
return Math.sqrt(dx * dx + dy * dy);
}
}
}