Hunting the yoyo blue box
Hello world,
As I said in an earlier post, I am ready to do some target shooting. I drew a box, gave it a name, and making it move in a yoyo manner horizontally. What I want to, is the following:
Every time I detect a collision, I will hear a different sound. Instead of my usual bang.mp3, it's going to be bang2. mp3. But I have a problem about the collision. Is it going to be between my movieclip_1 and my_box, or
boom( the impact hole) and the my_box. I understand the collision thing, but it is still a mystery, like the seasons and the tide of the sea. here the code:
import fl.transitions.Tween;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
var myTween = new Tween(my_box,"x",Strong.easeInOut,10,600,1,true);
myTween.addEventListener(TweenEvent.MOTION_FINISH, onFinish);
function onFinish(e:TweenEvent):void
{
e.target.yoyo();
}
var mySound1:Sound = new Sound();
var myChannel1:SoundChannel = new SoundChannel();
mySound1.load(new URLRequest("bang2.mp3"));
var mySound:Sound = new Sound();
var myChannel:SoundChannel = new SoundChannel();
mySound.load(new URLRequest("bang.mp3"));
stage.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
this.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
function fl_MouseClickHandler_2(event:MouseEvent):void
{
if (movieClip_1.hitBool)
{
mySound.play(1,1);
var boom:Boom=new Boom();
addChild(boom);
boom.x = mouseX;// not sure this is what you want form x,y
boom.y = mouseY;
}
}
stage.addChild(movieClip_1);
movieClip_1.mouseEnabled = false;
movieClip_1.addEventListener(Event.ENTER_FRAME, fl_CustomMouseCursor_2);
function fl_CustomMouseCursor_2(event:Event)
{
if (movieClip_1.hitTestPoint(stage.mouseX,stage.mouseY))
{
movieClip_1.hitBool = true;
}
else
{
movieClip_1.hitBool = false;
}
movieClip_1.x = stage.mouseX;
movieClip_1.y = stage.mouseY;
}
Mouse.hide();
