LEvent Class
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
Item Index
Properties
- COMPLETE static
- ENTER_FRAME static
- INIT static
- WINDOW_RESIZE static
Properties
COMPLETE
String
public
static
[static] Defines the value of the type property of a mouseDown event object.
This event can be used in the classes:
Object | Explanation |
---|---|
LLoader | when the image is loaded |
LURLLoader | when the text file or js file is loaded |
LMedia | when the media is loaded |
LAnimation | when the animation is on the last frame |
LStageWebView | when the web page is loaded |
ENTER_FRAME
String
public
static
[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:
Property | Value |
---|---|
currentTarget | The object that is actively processing the Event object with an event listener. |
target | In 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
[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
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");
}