Let's go straight to the question I want to do this in Adobe Animation and whit Action Script language,please help me write code
Rules of the game: Each colored circle will hit its color rectangle and the circle will disappear and the will be Change to Predefined rectangle and traced "warning" or do some action for other rectangle hit or black rectangles hit
Schematic image uploaded to better clarify what I want there is no problem if you change it all my code
Attention:I am a beginner, try with complete explanations
Challenges I have:
1- I don't know how to warn if the circle collides with irrelevant colors or black rectangles.
2- I want to warn at the moment of the collision, but the code I wrote delays, for example, the red circle disappears exactly when it hits the red rectangle (this is delayed in my code).
my fla code:
redCirc_mc.target = redRec_mc;
yelCirc_mc.target = yelRec_mc;
greenCirc_mc.target = greenRec_mc;
my class code:
package {
import flash.events.MouseEvent
import flash.display.MovieClip
import fl.transitions.Fade;
public class DragDrop extends MovieClip {
public var target:MovieClip;
private var originalX:Number;
private var originalY:Number;
public function DragDrop(){
originalX=this.x;
originalY=this.y;
this.addEventListener(MouseEvent.MOUSE_DOWN,drag);}
private function drag(event:MouseEvent):void{
this.startDrag();
this.parent.addChild(this);
this.addEventListener(MouseEvent.MOUSE_UP,drop);
}
private function drop(event:MouseEvent):void{
this.stopDrag();
this.removeEventListener(MouseEvent.MOUSE_UP,drop);
if (this.hitTestObject(target)){
trace("hit!");
this.visible=false;
}
else{
this.x=originalX;
this.y=originalY;
}
}
}
}