If mouse is moving horizontally back and forth over movieclip
I am a rookie flash developer, and I have a unique scenario I need to create. I need to put out a fire, only when the mouse is moving horizontally left and right overtop of the fire movieclip.
Right now I have some code that does the trick but if the mouse is going up and down the fire is supposed to grow. And my code is just sketchy.
function everything () {
controlMC.buttonMode = true;
Mouse.hide();
controlMC.startDrag(true);
var prevX:int = 0;
var prevY:int = 0;
var curX:int = 0;
var curY:int = 0;
import flash.net.*;
function Start()
{
stage.addEventListener(MouseEvent.MOUSE_MOVE, CheckDirection);
}
Start();
function CheckDirection(e:MouseEvent)
{
setChildIndex(controlMC,numChildren - 1);
getDirection();
e.updateAfterEvent();
}
function getDirection(){
prevX = curX;
curX = stage.mouseX;
fireMC.scaleX = fireMC.scaleY;
prevY = curY;
curY = stage.mouseY;
success();
if (prevX > curX || prevX < curX && fireMC.hitTestPoint(mouseX,mouseY,true)) {
fireMC.height = fireMC.height - 5;
}
else if (prevY > curY || prevY < curY && fireMC.hitTestPoint(mouseX,mouseY,true)) {
fireMC.height = fireMC.height + 5;
}
function success()
{
if (fireMC.height <= 200) {
myTimer.stop();
myTimer.removeEventListener(TimerEvent.TIMER, countdown);
Mouse.show();
controlMC.stopDrag();
TweenLite.to(fireMC, 1, {alpha: 0});
TweenLite.to(yesMC, .5, {alpha: 1});
setChildIndex(yesMC,numChildren - 1);
controlMC.visible = false;
yesMC.continueMC.addEventListener(MouseEvent.MOUSE_DOWN, fin);
yesMC.continueMC.buttonMode = true;
function fin () {
yesMC.continueMC.buttonMode = false;
yesMC.continueMC.removeEventListener(MouseEvent.MOUSE_DOWN, fin);
TweenLite.to(yesMC, .5, {alpha: 0});
setChildIndex(yesMC, 0);
gotoAndStop(1);
}
}
}
}
}
Feel free to tell me I'm a terrible as3 coder. I don't even understand classes
