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

LSprite Class

Defined in: display/LSprite.js:1

Available since 1.0.0

Creates a new LSprite instance. The LSprite class is a basic display list building block: a display list node that can display graphics and can also contain children.

Constructor

LSprite

() public

Defined in display/LSprite.js:1

Available since 1.0.0

Example:

LInit(50, "legend", 800, 480, main);
function main () {
    var layer = new LSprite();
    addChild(layer);

    var bmd = new LBitmapData("#FF0000", 0, 0, 100, 100);
    var bm = new LBitmap(bmd);
    layer.addChild(bm);
}

Methods

addChild

(
  • child
)
LDisplayObject public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:77

Available since 1.0.0

Adds a child DisplayObject instance to this LDisplayObjectContainer instance. The child is added to the front (top) of all other children in this LDisplayObjectContainer instance. (To add a child to a specific index position, use the addChildAt() method.)

If you add a child object that already has a different display object container as a parent, the object is removed from the child list of the other display object container.

Parameters:

  • child LDisplayObject

    The LDisplayObject instance to add as a child of this LDisplayObjectContainer instance.

Returns:

LDisplayObject:

The LDisplayObject instance that you pass in the child parameter.

Example:

var bitmapdata = new LBitmapData("#FF0000",0,0,100,100);  
var bitmap = new LBitmap(bitmapdata);
var layer = new LSprite();
addChild(layer);
layer.addChild(bitmap);

addChildAt

(
  • child
  • index
)
LDisplayObject public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:106

Available since 1.8.0

Adds a child LDisplayObject instance to this LDisplayObjectContainer instance. The child is added at the index position specified. An index of 0 represents the back (bottom) of the display list for this LDisplayObjectContainer object.

For example, the following example shows three display objects, labeled a, b, and c, at index positions 0, 2, and 1, respectively:

If you add a child object that already has a different display object container as a parent, the object is removed from the child list of the other display object container.

Parameters:

  • child LDisplayObject

    child The LDisplayObject instance to add as a child of this LDisplayObjectContainer instance.

  • index Int

    The index position to which the child is added. If you specify a currently occupied index position, the child object that exists at that position and all higher positions are moved up one position in the child list.

Returns:

LDisplayObject:

The LDisplayObject instance that you pass in the child parameter.

Example:

var container = new LSprite();
var circle1 = new LSprite();
var circle2 = new LSprite();
container.addChild(circle1);
container.addChildAt(circle2, 0);
trace(container.getChildAt(0) == circle2); // true
trace(container.getChildAt(1) == circle1); // true

addEventListener

(
  • type
  • listener
)
public

Inherited from LEventDispatcher: events/LEventDispatcher.js:16

Available since 1.8.0

Registers an event listener object with an LEventDispatcher object so that the listener receives notification of an event. You can register event listeners on all nodes in the display list for a specific type of event, phase, and priority.

After you successfully register an event listener, you cannot change its priority through additional calls to addEventListener(). To change a listener's priority, you must first call removeListener(). Then you can register the listener again with the new priority level.

If you no longer need an event listener, remove it by calling removeEventListener(), or memory problems could result.

Parameters:

  • type String

    The type of event.

  • listener Function

    The listener function that processes the event.

addShape

(
  • type
  • arg
)
public

Defined in display/LSprite.js:568

Available since 1.9.0

Add a collider’s shape

a rectangle : addShape(LShape.RECT,[20,140,200,100])

a circle : addShape(LShape.ARC,[110,80,60])

a polygon : addShape(LShape.VERTICES,[[10,10],[50,100],[100,70]])

Parameters:

  • type String

    The shape's type.

  • arg Array

    The shape's parameters.

Example:

LInit(20,"legend",800,450,main);
function main () {
    LGlobal.setDebug(true);
    var loader = new LLoader();
    loader.addEventListener(LEvent.COMPLETE, loadBitmapdata); 
    loader.load("face.jpg", "bitmapData");
}
function loadBitmapdata (event) {
    var bitmapData = new LBitmapData(event.currentTarget);//width:240,height:240
    var bitmap01 = new LBitmap(bitmapData);
    var layer01 = new LSprite();
    addChild(layer01);
    layer01.addChild(bitmap01);
    var rect1 = new LSprite();
    rect1.x = 180;
    rect1.graphics.drawRect(2,"#FF0000",[0,0,100,100]);
    addChild(rect1);
    var bitmap02 = new LBitmap(bitmapData);
    var layer02 = new LSprite();
    layer02.x = 300;
    addChild(layer02);
    layer02.addChild(bitmap02);
    layer02.addShape(LShape.ARC,[110,80,60]);
    layer02.addShape(LShape.RECT,[20,140,200,100]);
    var rect2 = new LSprite();
    rect2.x = 480;
    rect2.graphics.drawRect(2,"#FF0000",[0,0,100,100]);
    addChild(rect2);
    var rect3 = new LSprite();
    rect3.x = 480;
    rect3.y = 120;
    rect3.graphics.drawRect(2,"#FF0000",[0,0,100,100]);
    addChild(rect3);
    trace(layer01.hitTestObject(rect1));//true
    trace(layer02.hitTestObject(rect2));//false
    trace(layer02.hitTestObject(rect3));//true
}

callParent

(
  • functionName
  • arguments
)
public

Inherited from LObject: main/LObject.js:22

Available since 1.6.0

call the method of parent。

Parameters:

  • functionName String

    function's name

  • arguments Array

    Fixed value : arguments

Example:

function funA(){
    LExtends(this,LObject,[]);
}
funA.prototype.myName = function(){
    return "AAA";
}
function funB(){
    LExtends(this,funA,[]);
}
funB.prototype.myName = function(){
    return "BBB";
}
function funC(){
    LExtends(this,funA,[]);
}
funC.prototype.myName = function(){
    return this.callParent("myName",arguments);
}
LInit(1000/50,"legend",800,150,main);
function main(){
    LGlobal.setDebug(true);
    var objB = new funB();
    trace(objB.myName());//BBB
    var objC = new funC();
    trace(objC.myName());//AAA
}

clearShape

() public

Defined in display/LSprite.js:625

Available since 1.9.0

Clear all the collider’s shape

Example:

var bitmapData = new LBitmapData(event.currentTarget);//width:240,height:240
var bitmap01 = new LBitmap(bitmapData);
var layer01 = new LSprite();
addChild(layer01);
layer01.addChild(bitmap01);
layer01.addShape(LShape.ARC,[110,80,60]);
layer01.addShape(LShape.RECT,[20,140,200,100]);
var rect1 = new LSprite();
rect1.x = 180;
rect1.graphics.drawRect(2,"#FF0000",[0,0,100,100]);
addChild(rect1);
trace(layer01.hitTestObject(rect1));//false
layer01.clearShape()
trace(layer01.hitTestObject(rect1));//true

clearShape

() public

Defined in display/LSprite.js:710

Available since 1.0.0

Frees memory that is used.Clear all the shapes and the events

clone

() LSprite public

Defined in display/LSprite.js:320

Available since 1.8.2

Returns a new LSprite object that is a clone of the original instance with an exact copy of the object.

Returns:

LSprite:

A new LSprite object that is identical to the original.

Example:

var circle1 = new LSprite();
circle1.graphics.drawRect(1,"#000000",[0,0,100,100],true,"#000000");
var circle2 = circle1.clone();
circle2.y = 120;
addChild(circle1);
addChild(circle2);

dispatchEvent

(
  • event
)
Boolean public

Inherited from LEventDispatcher: events/LEventDispatcher.js:59

Available since 1.8.0

Dispatches an event into the event flow. The event target is the LEventDispatcher object upon which the dispatchEvent() method is called.

Parameters:

  • event LEvent | String

    The Event object that is dispatched into the event flow. If the event is being redispatched, a clone of the event is created automatically. After an event is dispatched, its target property cannot be changed, so you must create a new copy of the event for redispatching to work.

Returns:

Boolean:

A value of true if the event was successfully dispatched. function MyEventObject(){ var self = this; LExtends(self,LSprite,[]); self.graphics.drawRect(1,"#000000",[0,0,100,100],true,"#000000"); self.graphics.drawRect(1,"#FF0000",[100,0,100,100],true,"#FF0000"); self.addEventListener(LMouseEvent.MOUSE_UP,self.onclick); self.addEventListener(MyEventObject.CLICK_LEFT,function(event){ trace("dispatchEvent"); }); self.addEventListener(MyEventObject.CLICK_RIGHT,function(event){ trace("dispatchEvent event.name = " + event.name); }); } MyEventObject.CLICK_LEFT = "click_left"; MyEventObject.CLICK_RIGHT = "click_right"; MyEventObject.prototype.onclick = function(event){ var self = event.clickTarget; if(event.selfX < 100){ self.dispatchEvent(MyEventObject.CLICK_LEFT); }else{ var event = new LEvent(MyEventObject.CLICK_RIGHT); event.name = "LEvent Test"; self.dispatchEvent(event); } }

getBounds

(
  • targetCoordinateSpace
)
LRectangle public

Inherited from LDisplayObject: display/LDisplayObject.js:258

Available since 1.7.7

Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.

Parameters:

  • targetCoordinateSpace LDisplayObject

    The display object that defines the coordinate system to use.

Returns:

LRectangle:

The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system.

getChildAt

(
  • index
)
LDisplayObject public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:181

Available since 1.8.0

Returns the child display object instance that exists at the specified index.

Parameters:

  • index Int

    The index position of the child object.

Returns:

LDisplayObject:

The child display object at the specified index position.

Example:

var container = new LSprite();
addChild(container);
var sprite1 = new LSprite();
var sprite2 = new LSprite();
var sprite3 = new LSprite();
container.addChild(sprite1);
container.addChild(sprite2);
container.addChildAt(sprite3, 0);
trace(container.getChildAt(0) == sprite3); // true
trace(container.getChildAt(1) == sprite1); // true
trace(container.getChildAt(2) == sprite2); // true

getChildByName

(
  • name
)
LDisplayObject public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:209

Available since 1.9.0

Returns the child display object that exists with the specified name. If more that one child display object has the specified name, the method returns the first object in the child list.

The getChildAt() method is faster than the getChildByName() method. The getChildAt() method accesses a child from a cached array, whereas the getChildByName() method has to traverse a linked list to access a child.

Parameters:

  • name String

    The name of the child to return.

Returns:

LDisplayObject:

The child display object with the specified name.

Example:

var container = new LSprite();
var sprite1 = new LSprite();
sprite1.name = "sprite1";
var sprite2 = new LSprite();
sprite2.name = "sprite2";
container.addChild(sprite1);
container.addChild(sprite2);
var target = container.getChildByName("sprite1");
trace(container.getChildIndex(target)); // 0

getChildIndex

(
  • The
)
Int public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:275

Available since 1.8.0

Returns the index position of a child LDisplayObject instance.

Parameters:

Returns:

Int:

The index position of the child display object to identify.

Example:

var container = new LSprite();
addChild(container);
var sprite1 = new LSprite();
sprite1.name = "sprite1";
var sprite2 = new LSprite();
sprite2.name = "sprite2";
container.addChild(sprite1);
container.addChild(sprite2);
trace(container.getChildIndex(sprite1)); // 0

getDataURL

() Base64 Image public

Inherited from LDisplayObject: display/LDisplayObject.js:306

Available since 1.7.7

Get a string of base64-encoded image.

Returns:

Base64 Image:

a string of base64-encoded image.

getHeight

() Float public

Defined in display/LSprite.js:250

Available since 1.0.0

Get the height of the display object, in pixels.

Returns:

Float:

the height of the display object.

Example:

var bitmapdata = new LBitmapData(event.currentTarget);  
var bitmap = new LBitmap(bitmapdata);
var layer = new LSprite();
addChild(layer);
layer.addChild(bitmap);
trace("height : " + layer.getHeight());

getRootCoordinate

() LPoint public

Inherited from LDisplayObject: display/LDisplayObject.js:237

Available since 1.7.7

Get the coordinates (Relative to the canvas).

Returns:

LPoint:

a LPoint object。

getWidth

() Float public

Defined in display/LSprite.js:201

Available since 1.0.0

Get the width of the display object, in pixels.

Returns:

Float:

the width of the display object.

Example:

var bitmapdata = new LBitmapData(event.currentTarget);  
var bitmap = new LBitmap(bitmapdata);
var layer = new LSprite();
addChild(layer);
layer.addChild(bitmap);
trace("width : " + layer.getWidth());

hasEventListener

(
  • type
)
Boolean public

Inherited from LEventDispatcher: events/LEventDispatcher.js:122

Available since 1.8.0

Checks whether the LEventDispatcher object has any listeners registered for a specific type of event. This allows you to determine where an LEventDispatcher object has altered handling of an event type in the event flow hierarchy.

Parameters:

  • type String

    The type of event.

Returns:

Boolean:

A value of true if a listener of the specified type is registered; false otherwise.

hitTestObject

(
  • obj
)
Boolean public

Defined in display/LSprite.js:495

Available since 1.9.0

Evaluates the bounding box of the display object to see if it overlaps or intersects with the bounding box of the obj display object.

Parameters:

Returns:

Boolean:

true if the bounding boxes of the display objects intersect; false if not.

Example:

LGlobal.setDebug(true);
var container = new LSprite();
addChild(container);
var circle1 = new LSprite();
circle1.graphics.drawRect(1,"#000000",[0,0,100,100],true,"#000000");
var circle2 = new LSprite();
circle2.x = 120;
circle2.graphics.drawRect(1,"#FF0000",[0,0,100,100],true,"#FF0000");
var circle3 = new LSprite();
circle3.x = 60;
circle3.y = 60;
circle3.graphics.drawRect(1,"#008800",[0,0,100,100],true,"#008800");
container.addChild(circle1);
container.addChild(circle2);
container.addChild(circle3);
trace(circle1.hitTestObject(circle2));//false
trace(circle1.hitTestObject(circle3));//true
trace(circle2.hitTestObject(circle3));//true

hitTestPoint

(
  • x
  • y
)
Boolean public

Defined in display/LSprite.js:434

Available since 1.9.0

Evaluates the display object to see if it overlaps or intersects with the point specified by the x and y parameters. The x and y parameters specify a point in the coordinate space of the Stage, not the display object container that contains the display object (unless that display object container is the Stage).

Parameters:

  • x Float

    The x coordinate to test against this object.

  • y Float

    The y coordinate to test against this object.

Returns:

Boolean:

true if the display object overlaps or intersects with the specified point; false otherwise.

Example:

LInit(20,"legend",800,450,main);
var backLayer;
var title;
function main(){
    backLayer = new LSprite();
    addChild(backLayer);
    backLayer.addEventListener(LEvent.ENTER_FRAME,onframe);
    title = new LTextField();
    title.size = 18;
    title.x = 10;
    title.y = 5;
    title.text = "hitTestPoint:false";
    addChild(title);
    var layer = new LSprite();
    layer.x = 20;
    layer.y = 50;
    layer.graphics.drawRect(0,"#880088",[0,0,100,40],true,"#880088");
    layer.addShape(LShape.RECT,[0,0,100,40]);
    backLayer.addChild(layer);
    layer = new LSprite();
    layer.x = 200;
    layer.y = 100;
    layer.graphics.drawArc(0,"#880088",[0,0,30,0,2*Math.PI],true,"#880088");
    layer.addShape(LShape.ARC,[0,0,30]);
    backLayer.addChild(layer);
    layer = new LSprite();
    layer.x = 120;
    layer.y = 150;
    layer.graphics.drawVertices(0,"#880088",[[10,10],[50,100],[100,70]],true,"#880088");
    layer.addShape(LShape.VERTICES,[[10,10],[50,100],[100,70]]);
    backLayer.addChild(layer);
}
function onframe(e){
    for(var i=0;i<backLayer.childList.length;i++){
        if(backLayer.childList[i].hitTestPoint(mouseX,mouseY)){
            title.text = "hitTestPoint:true";
            return;
        }
    }
    title.text = "hitTestPoint:false";
}

remove

() public

Inherited from LDisplayObject: display/LDisplayObject.js:379

Available since 1.7.7

Remove self from the parent container.

removeAllChild

()

Removes all the child LDisplayObject instance from the child list of the LDisplayObjectContainer instance.

removeAllEventListener

() public

Inherited from LEventDispatcher: events/LEventDispatcher.js:50

Available since 1.8.0

Removes all the listeners from the LEventDispatcher object.

removeChild

(
  • The
)
LDisplayObject public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:143

Available since 1.0.0

Removes the specified child LDisplayObject instance from the child list of the LDisplayObjectContainer instance. The parent property of the removed child is set to null , and the object is garbage collected if no other references to the child exist. The index positions of any display objects above the child in the LDisplayObjectContainer are decreased by 1.

Parameters:

Returns:

LDisplayObject:

The LDisplayObject instance that you pass in the child parameter.

Example:

function main () {
    var container = new LSprite();
    addChild(container);
    var circle1 = new LSprite();
    circle1.graphics.drawRect(1,"#000000",[0,0,50,50]);
    var circle2 = new LSprite();
    circle2.graphics.drawRect(1,"#000000",[100,100,50,50]);
    container.addChild(circle1);
    container.addChild(circle2);
    container.addEventListener(LMouseEvent.MOUSE_DOWN, clicked);
}
function clicked (event) {
    event.currentTarget.removeChild(event.target);
}

removeChildAt

(
  • index
)
LDisplayObject public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:241

Available since 1.8.0

Removes a child LDisplayObject from the specified index position in the child list of the LDisplayObjectContainer. The parent property of the removed child is set to null, and the object is garbage collected if no other references to the child exist. The index positions of any display objects above the child in the LDisplayObjectContainer are decreased by 1.

Parameters:

  • index Int

    The child index of the LDisplayObject to remove.

Returns:

LDisplayObject:

The LDisplayObject instance that was removed.

Example:

var container = new LSprite();
addChild(container);
var sprite1 = new LSprite();
sprite1.name = "sprite1";
var sprite2 = new LSprite();
sprite2.name = "sprite2";
container.addChild(sprite1);
container.addChild(sprite2);
trace(container.numChildren) // 2
container.removeChildAt(0); 
trace(container.numChildren) // 1
trace(container.getChildAt(0).name); // sprite2

removeEventListener

(
  • type
  • listener
)
public

Inherited from LEventDispatcher: events/LEventDispatcher.js:29

Available since 1.8.0

Removes a listener from the LEventDispatcher object. If there is no matching listener registered with the LEventDispatcher object, a call to this method has no effect.

Parameters:

  • type String

    The type of event.

  • listener Function

    The listener object to remove.

setChildIndex

(
  • child
  • index
)
Int public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:306

Available since 1.8.0

Changes the position of an existing child in the display object container. This affects the layering of child objects. For example, the following example shows three display objects, labeled a, b, and c, at index positions 0, 1, and 2, respectively:

When you use the setChildIndex() method and specify an index position that is already occupied, the only positions that change are those in between the display object's former and new position. All others will stay the same. If a child is moved to an index LOWER than its current index, all children in between will INCREASE by 1 for their index reference. If a child is moved to an index HIGHER than its current index, all children in between will DECREASE by 1 for their index reference. For example, if the display object container in the previous example is named container, you can swap the position of the display objects labeled a and b by calling the following code:

container.setChildIndex(container.getChildAt(1), 0);

This code results in the following arrangement of objects:

Parameters:

  • child LDisplayObject

    The child LDisplayObject instance for which you want to change the index number.

  • index Int

    The resulting index number for the child display object.

Returns:

Int:

The resulting index number for the child display object.

Example:

LInit(50, "legend", 800, 480, main);
var container;
function main () {
    container = new LSprite();
    addChild(container);
    var circle1 = new LSprite();
    circle1.graphics.drawRect(1,"#000000",[0,0,100,100],true,"#000000");
    circle1.addEventListener(LMouseEvent.MOUSE_DOWN, clicked);
    var circle2 = new LSprite();
    circle2.graphics.drawRect(1,"#FF0000",[40,80,100,100],true,"#FF0000");
    circle2.addEventListener(LMouseEvent.MOUSE_DOWN, clicked);
    var circle3 = new LSprite();
    circle3.graphics.drawRect(1,"#008800",[80,0,100,100],true,"#008800");
    circle3.addEventListener(LMouseEvent.MOUSE_DOWN, clicked);
    container.addChild(circle1);
    container.addChild(circle2);
    container.addChild(circle3);
}
function clicked (event) {
    var circle = event.target;
    var topPosition = container.numChildren - 1;
    container.setChildIndex(circle, topPosition);
}

setRotate

(
  • angle
)
public

Defined in display/LSprite.js:84

Available since 1.4.0

Rotates the object by an angle, when you use the Box2dWeb

Parameters:

  • angle Float

    angle。

startDrag

(
  • touchPointID
)
public

Defined in display/LSprite.js:116

Available since 1.8.9

Lets the user drag the specified sprite. The sprite remains draggable until explicitly stopped through a call to the LSprite.stopDrag() method.

Parameters:

  • touchPointID Int

    An integer to assign to the touch point(a touch-enabled device).

Example:

LInit(1000/50,"legend",800,450,main);
function main(){
    LMultitouch.inputMode = LMultitouchInputMode.TOUCH_POINT;
    for(var i=0;i<3;i++){
        var child = new LSprite();
        child.x = 250*i;
        child.graphics.drawRect(2,"#ff0000",[0,0,100,100],true,"#ff0000");
        child.addEventListener(LMouseEvent.MOUSE_DOWN,ondown);
        child.addEventListener(LMouseEvent.MOUSE_UP,onup);
        addChild(child);
    }
}
function ondown(e){
    e.clickTarget.startDrag(e.touchPointID);
}
function onup(e){
    e.clickTarget.stopDrag();
}

stopDrag

() public

Defined in display/LSprite.js:156

Available since 1.8.9

Ends the startDrag() method.

Example:

LInit(1000/50,"legend",800,450,main);
function main(){
    LMultitouch.inputMode = LMultitouchInputMode.TOUCH_POINT;
    for(var i=0;i<3;i++){
        var child = new LSprite();
        child.x = 250*i;
        child.graphics.drawRect(2,"#ff0000",[0,0,100,100],true,"#ff0000");
        child.addEventListener(LMouseEvent.MOUSE_DOWN,ondown);
        child.addEventListener(LMouseEvent.MOUSE_UP,onup);
        addChild(child);
    }
}
function ondown(e){
    e.clickTarget.startDrag(e.touchPointID);
}
function onup(e){
    e.clickTarget.stopDrag();
}

Properties

alpha

Float public

Inherited from LDisplayObject: display/LDisplayObject.js:55

Available since 1.6.0

Indicates the alpha transparency value of the object specified. Valid values are 0 (fully transparent) to 1 (fully opaque). The default value is 1. Display objects with alpha set to 0 are active, even though they are invisible.

Default: 0

blendMode

String public

Inherited from LDisplayObject: display/LDisplayObject.js:91

Available since 1.8.0

A value from the LBlendMode class that specifies which blend mode to use. A bitmap can be drawn internally in two ways. If you have a blend mode enabled or an external clipping mask, the bitmap is drawn by adding a bitmap-filled square shape to the vector render. If you attempt to set this property to an invalid value, runtimes set the value to LBlendMode.NORMAL.

Default: null

childList

Array public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:15

Available since 1.0.0

the child display object list

filters

Array public

Inherited from LDisplayObject: display/LDisplayObject.js:100

Available since 1.6.0

An indexed array that contains each filter object currently associated with the display object.

Default: null

graphics

LGraphics public

Defined in display/LSprite.js:36

Available since 1.0.0

[read-only] Specifies the LGraphics object that belongs to this sprite where vector drawing commands can occur.

Example:

var layer = new LSprite();
addChild(layer);
layer.graphics.drawRect(2, "#ff0000", [10, 10, 50, 100], true, "#880088");

mask

LDisplayObject public

Inherited from LDisplayObject: display/LDisplayObject.js:82

Available since 1.6.0

The calling display object is masked by the specified mask object. To ensure that masking works when the Stage is scaled, the mask display object must be in an active part of the display list. The mask object itself is not drawn. Set mask to null to remove the mask.

Default: null

mouseChildren

Boolean public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:46

Available since 1.9.0

Determines whether or not the children of the object are mouse, enabled.

Example:

LGlobal.setDebug(true);
var container1 = new LSprite();
container1.x = container1.y = 20;
var container2 = new LSprite();
container2.x = 20;
container2.y = 100;
container2.mouseChildren = false;
addChild(container1);
addChild(container2);
var button01 = new LButtonSample1("mouseChildren=true");
container1.addChild(button01);
button01.addEventListener(LMouseEvent.MOUSE_DOWN,function(e){
    trace("button01 click");
});
var button02 = new LButtonSample1("mouseChildren=false");
container2.addChild(button02);
button02.addEventListener(LMouseEvent.MOUSE_DOWN,function(e){
    trace("button02 click");
});

mouseEnabled

Boolean public

Inherited from LInteractiveObject: display/LInteractiveObject.js:14

Available since 1.8.10

Specifies whether this object receives mouse, or other user input, messages. The default value is true, which means that by default any InteractiveObject instance that is on the display list receives mouse events or other user input events. If mouseEnabled is set to false, the instance does not receive any mouse events (or other user input events like keyboard events). Any children of this instance on the display list are not affected. To change the mouseEnabled behavior for all children of an object on the display list, use LDisplayObjectContainer.mouseChildren.

Example:

LGlobal.setDebug(true);
var button01 = new LButtonSample1("mouseEnabled=true");
button01.x = button01.y = 20;
addChild(button01);
button01.addEventListener(LMouseEvent.MOUSE_DOWN,function(e){
    trace("button01 click");
});
var button02 = new LButtonSample1("mouseEnabled=false");
button02.x = 20;
button02.y = 150;
button02.mouseEnabled = false;
addChild(button02);
button02.addEventListener(LMouseEvent.MOUSE_DOWN,function(e){
    trace("button02 click");
});

numChildren

Int public

Inherited from LDisplayObjectContainer: display/LDisplayObjectContainer.js:23

Available since 1.9.0

Returns the number of children of this object.

Example:

var container1 = new LSprite();
var container2 = new LSprite();
var circle1 = new LSprite();
circle1.graphics.drawRect(1,"#000000",[0,0,50,50]);
var circle2 = new LSprite();
circle2.graphics.drawRect(1,"#000000",[100,100,50,50]);
container2.addChild(container1);
container1.addChild(circle1);
container1.addChild(circle2);
trace(container1.numChildren); // 2
trace(container2.numChildren); // 1
trace(circle1.numChildren); // 0
trace(circle2.numChildren); // 0

objectIndex

Int public

Inherited from LObject: main/LObject.js:11

Available since 1.6.0

ID of the object

rotate

Float public

Inherited from LDisplayObject: display/LDisplayObject.js:73

Available since 1.6.0

Indicates the rotation of the LDisplayObject instance, in degrees, from its original orientation. Values from 0 to 180 represent clockwise rotation; values from 0 to -180 represent counterclockwise rotation. Values outside this range are added to or subtracted from 360 to obtain a value within the range. For example, the statement my_video.rotate = 450 is the same as my_video.rotate = 90.

Default: 0

scaleX

Float public

Inherited from LDisplayObject: display/LDisplayObject.js:37

Available since 1.6.0

Indicates the horizontal scale (percentage) of the object as applied from the registration point. The default registration point is (0,0). 1.0 equals 100% scale.

Default: 1

scaleY

Float public

Inherited from LDisplayObject: display/LDisplayObject.js:46

Available since 1.6.0

Indicates the vertical scale (percentage) of an object as applied from the registration point of the object. The default registration point is (0,0). 1.0 is 100% scale.

Default: 1

shapes

Array public

Defined in display/LSprite.js:51

Available since 1.9.0

The collider’s shape list

Example:

function loadBitmapdata (event) {
    var bitmapdata = new LBitmapData(event.currentTarget); 
    var bitmap = new LBitmap(bitmapdata);

    layer = new LSprite();
    layer.addChild(bitmap);
    layer.x = 20;
    layer.y = 50;
    layer.addShape(LShape.VERTICES, [[180, 20], [210, 40], [210, 60], [120, 110], [35, 100]]);
    layer.addShape(LShape.VERTICES, [[120, 110], [140, 120], [140, 150], [110, 160], [35, 120], [35, 100]]);
    addChild(layer);

    layer.addEventListener(LEvent.ENTER_FRAME, onframe);
}
function onframe (e) {
    if (layer.hitTestPoint(mouseX, mouseY)) {
        layer.alpha = 0.5;
    } else {
        layer.alpha = 1;
    }
}

type

String public

Defined in display/LSprite.js:25

Available since 1.0.0

type of the object

Default: LSprite

visible

Boolean public

Inherited from LDisplayObject: display/LDisplayObject.js:64

Available since 1.6.0

Whether or not the display object is visible. Display objects that are not visible are disabled. For example, if visible=false for an LInteractiveObject instance, it cannot be clicked.

Default: true

x

Float public

Inherited from LDisplayObject: display/LDisplayObject.js:17

Available since 1.6.0

Indicates the x coordinate of the LDisplayObject instance relative to the local coordinates of the parent LDisplayObjectContainer. If the object is inside a LDisplayObjectContainer that has transformations, it is in the local coordinate system of the enclosing LDisplayObjectContainer. Thus, for a LDisplayObjectContainer rotated 90° counterclockwise, the LDisplayObjectContainer's children inherit a coordinate system that is rotated 90° counterclockwise. The object's coordinates refer to the registration point position.

Default: 0

y

Float public

Inherited from LDisplayObject: display/LDisplayObject.js:26

Available since 1.6.0

Indicates the y coordinate of the LDisplayObject instance relative to the local coordinates of the parent LDisplayObjectContainer. If the object is inside a LDisplayObjectContainer that has transformations, it is in the local coordinate system of the enclosing LDisplayObjectContainer. Thus, for a LDisplayObjectContainer rotated 90° counterclockwise, the LDisplayObjectContainer's children inherit a coordinate system that is rotated 90° counterclockwise. The object's coordinates refer to the registration point position.

Default: 0

Events

LEvent.ENTER_FRAME

[broadcast event] Dispatched when the playhead is entering a new frame.

LEvent.ENTER_FRAME

LMouseEvent.DOUBLE_CLICK

Dispatched when a user presses and releases the main button of a pointing device twice in rapid succession over the same LInteractiveObject.

LMouseEvent.DOUBLE_CLICK

LMouseEvent.MOUSE_DOWN

Dispatched when a user presses the pointing device button over an LInteractiveObject instance.

LMouseEvent.MOUSE_DOWN

LMouseEvent.MOUSE_MOVE

Dispatched when a user moves the pointing device while it is over an LInteractiveObject.

LMouseEvent.MOUSE_MOVE

LMouseEvent.MOUSE_OUT

Dispatched when the user moves a pointing device away from an LInteractiveObject instance.

LMouseEvent.MOUSE_OUT

LMouseEvent.MOUSE_OVER

Dispatched when the user moves a pointing device over an LInteractiveObject instance.

LMouseEvent.MOUSE_OVER

LMouseEvent.MOUSE_UP

Dispatched when a user releases the pointing device button over an LInteractiveObject instance.

LMouseEvent.MOUSE_UP