Get Adobe Flash player

Action Script 3.0 Check Mouse Direction

July 15th, 2010 | Comments Off
category: Software

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This code is for action script 3.0
function Start()
{
    stage.addEventListener(MouseEvent.MOUSE_MOVE, CheckDirection);
}
Start();

var prevX = 0;
var prevY = 0;
var curX = 0;
var curY = 0;


var dirX:String = "";
var dirY:String = "";

function CheckDirection(e:MouseEvent)
{

    trace("X movement: " + GetHorizontalDirection() + ", Y movement: " + GetVerticalDirection());

    e.updateAfterEvent();
}

function GetHorizontalDirection():String
{
    prevX = curX;
    curX = stage.mouseX;

    if (prevX > curX)
    {
        dirX = "left";
    }
    else if (prevX < curX)
    {
        dirX = "right";
    }
    else
    {
        dirX = "none";
    }

    return dirX;
}

function GetVerticalDirection():String
{
    prevY = curY;
    curY = stage.mouseY;

    if (prevY > curY)
    {
        dirY = "up";
    }
    else if (prevY < curY)
    {
        dirY = "down";
    }
    else
    {
        dirY = "none";
    }

    return dirY;
}
GD Star Rating
loading...
Action Script 3.0 Check Mouse Direction, 4.0 out of 5 based on 1 rating


Comments are closed.



Content

Need to pay for services?


Banner    

Contact me


  

Socially you can find me here


                 

        


Need to pick up a few things before you leave?


Grasshopper - The Entrepreneur's Phone System   Affordable Premium Custom Flash Photo and Video Gallery Templates
2010 Copyright © Todd Vaughn. All rights reserved. Register