LEvent Class
LEvent 类作为创建 Event 对象的基类,当发生事件时,Event 对象将作为参数传递给事件侦听器。
Constructor
LEvent
()
public
Item Index
Properties
- COMPLETE static
- ENTER_FRAME static
- ERROR static
- ERROR static
- INIT static
- LEvent.ADDED static
- LEvent.ADDED_TO_STAGE static
- LEvent.REMOVED static
- LEvent.REMOVED_FROM_STAGE static
- WINDOW_ORIENTATIONCHANGE static
- WINDOW_RESIZE static
Properties
COMPLETE
String
public
static
[静态] 定义加载完成事件对象的 type 属性值。
此事件可以在下列对象中使用:
对象 | 说明 |
---|---|
LLoader | 图片加载完成事件。 |
LURLLoader | js文件或者文本文件加载完成事件。 |
LMedia | 多媒体文件加载完成事件。 |
LAnimation | 一组动画播放完成事件。 |
LStageWebView | 网页加载完成事件。 |
ENTER_FRAME
String
public
static
[播放事件] 播放头进入新帧时调度。如果播放头不移动,或者只有一帧,则会继续以帧速率调度此事件。此事件为广播事件,这意味着具有注册了此事件的侦听器的所有显示对象都会调度此事件。
LEvent.ENTER_FRAME 常量定义 enterFrame 事件对象的 type 属性值。
此事件具有以下属性:
属性 | 值 |
---|---|
currentTarget | 当前正在使用某个事件侦听器处理 Event 对象的对象。 |
target | 在此事件中等同于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;
}
}
ERROR
String
public
static
[静态] 定义 加载异常事件对象的 type 属性值。
此事件可以在下列对象中使用:
对象 | 说明 |
---|---|
LLoader | 图片加载异常事件。 |
LURLLoader | js文件或者文本文件加载异常事件。 |
LMedia | 多媒体文件加载异常事件。 |
ERROR
String
public
static
[静态] 定义 加载进度事件对象的 type 属性值。
此事件可以在下列对象中使用:
对象 | 说明 |
---|---|
LLoader | 图片加载进度事件。 |
LURLLoader | js文件或者文本文件加载进度事件。 |
LMedia | 多媒体文件加载进度事件。 |
INIT
String
public
static
[静态] 定义 lufylegend.js引擎初始化 事件对象的 type 属性值,当引擎初始化是在window.onload事件之后,需要使用此属性。
LEvent.INIT在1.10.1之后已经废弃。
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>
LEvent.ADDED
String
public
static
[静态] LEvent.ADDED 常量定义 added 事件对象的 type 属性值。
使用时需要引入lufylegend.LEvent.added-x.x.x.min.js文件。
LEvent.ADDED_TO_STAGE
String
public
static
[静态] LEvent.ADDED_TO_STAGE 常量定义 addedToStage 事件对象的 type 属性值。
使用时需要引入lufylegend.LEvent.added-x.x.x.min.js文件。
LEvent.REMOVED
String
public
static
[静态] LEvent.REMOVED 常量定义 removed 事件对象的 type 属性值。
使用时需要引入lufylegend.LEvent.added-x.x.x.min.js文件。
LEvent.REMOVED_FROM_STAGE
String
public
static
[静态] LEvent.REMOVED_FROM_STAGE 常量定义 removedFromStage 事件对象的 type 属性值。
使用时需要引入lufylegend.LEvent.added-x.x.x.min.js文件。
WINDOW_ORIENTATIONCHANGE
String
public
static
当屏幕旋转时,发生orientationchange 事件。
Example:
LInit(1000/60, "legend", 400,400, main);
var label;
function main () {
label = new LTextField();
label.x = label.y = 20;
label.text = "orientationchange test";
addChild(label);
LGlobal.stage.addEventListener(LEvent.WINDOW_ORIENTATIONCHANGE,orientationIsChange);
}
function orientationIsChange(e){
label.text = e.orientation;
}
WINDOW_RESIZE
String
public
static
当调整浏览器窗口的大小时,发生resize 事件。
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");
}