API Docs for: 最后更新日期:2014年8月25日
Google搜索   
Show:

LEvent Class

Defined in: events/LEvent.js:1

Available since 1.9.0

The LEvent class is used as the base class for the creation of Event objects, which are passed as parameters to event listeners when an event occurs.

Constructor

LEvent

() public

Defined in events/LEvent.js:1

Available since 1.9.0

Item Index

Properties

Properties

COMPLETE

String public static

Defined in events/LEvent.js:44

Available since 1.0.0

[static] Defines the value of the type property of a mouseDown event object.

This event can be used in the classes:

ObjectExplanation
LLoaderwhen the image is loaded
LURLLoaderwhen the text file or js file is loaded
LMediawhen the media is loaded
LAnimationwhen the animation is on the last frame
LStageWebViewwhen the web page is loaded

ENTER_FRAME

String public static

Defined in events/LEvent.js:62

Available since 1.0.0

[broadcast event] Dispatched when the playhead is entering a new frame. If the playhead is not moving, or if there is only one frame, this event is dispatched continuously in conjunction with the frame rate. This event is a broadcast event, which means that it is dispatched by all display objects with a listener registered for this event.

The LEvent.ENTER_FRAME constant defines the value of the type property of an enterFrame event object.

This event has the following properties:

PropertyValue
currentTargetThe object that is actively processing the Event object with an event listener.
targetIn this Event, Equivalent to currentTarget.

Example:

LInit(1000/60, "legend", 800, 480, main);
var direction = 1;
function main () {
    var layer = new LSprite();
    addChild(layer);
    layer.graphics.drawRect(1, "#ff0000", [0, 0, 100, 100], true, "#880088");
    layer.addEventListener(LEvent.ENTER_FRAME,onframe);
}
function onframe(event){
    var layer = event.currentTarget;
    layer.x += direction;
    if(layer.x < 0){
        direction = 1;
    }
    if(layer.x > 700){
        direction = -1;
    }
}

INIT

String public static

Defined in events/LEvent.js:15

Available since 1.0.0

[static] If Engine initialization is after window.onload, you need to use this property.

Example:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="../lufylegend-x.x.x.min.js"></script> 
<title>demo</title>
</head>
<body>
<div id="mylegend">loading……</div>
<script>
window.onload = function () {
    LInit(50, "mylegend", 800, 480, main, LEvent.INIT);
};
function main(){
    alert("Hello lufylegend!");
}
</script>
</body>
</html>

WINDOW_RESIZE

String public static

Defined in events/LEvent.js:98

Available since 1.9.0

Execute a JavaScript when the browser window is resized.

Example:

LInit(1000/60, "legend", window.innerWidth,window.innerHeight, main);
var layer;
function main () {
    layer = new LSprite();
    addChild(layer);
    update();
    LGlobal.stage.addEventListener(LEvent.WINDOW_RESIZE,update);
}
function update(){
    LGlobal.resize(window.innerWidth,window.innerHeight);
    layer.graphics.clear();
    layer.graphics.drawRect(1, "#ff0000", [0, 0, 50, 50], true, "#880088");
    layer.graphics.drawRect(1, "#ff0000", [LGlobal.width - 50, 0, 50, 50], true, "#880088");
    layer.graphics.drawRect(1, "#ff0000", [0, LGlobal.height - 50, 50, 50], true, "#880088");
    layer.graphics.drawRect(1, "#ff0000", [LGlobal.width - 50, LGlobal.height - 50, 50, 50], true, "#880088");
}