LBitmap Class
Initializes a LBitmap object to refer to the specified LBitmapData object. The LBitmap class represents display objects that represent bitmap images. These can be images that you load with the LLoader class, or they can be images that you create with the LBitmap() constructor. The LBitmap() constructor allows you to create a Bitmap object that contains a reference to a BitmapData object. After you create a LBitmap object, use the addChild() or addChildAt() method of the parent instance to place the bitmap on the display list. A LBitmap object can share its BitmapData reference among several Bitmap objects, independent of translation or rotation properties. Because you can create multiple LBitmap objects that reference the same BitmapData object, multiple display objects can use the same complex BitmapData object without incurring the memory overhead of a BitmapData object for each display object instance. A LBitmapData object can be drawn to the screen by a LBitmap object in one of two ways: by using the vector renderer as a fill-bitmap shape, or by using a faster pixel-copying routine. The pixel-copying routine is substantially faster than the vector renderer. The LBitmap class is not a subclass of the InteractiveObject class, so it cannot dispatch mouse events. However, you can use the addEventListener() method of the display object container that contains the LBitmap object.
Constructor
LBitmap
-
bitmapData
Parameters:
-
bitmapData
LBitmapDataThe LBitmapData object being referenced.
Example:
Linit(50, "mylegend", 800, 480, main);
function main () {
var loader = new LLoader();
loader.addEventListener(LEvent.COMPLETE, loadBitmapdata);
loader.load("lufylegend.js.png", "bitmapData");
}
function loadBitmapdata (event) {
var bitmapdata = new LBitmapData(event.currentTarget);
var bitmap = new LBitmap(bitmapdata);
addChild(bitmap);
}
Item Index
Methods
Properties
Events
Methods
addEventListener
-
type
-
listener
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
StringThe type of event.
-
listener
FunctionThe listener function that processes the event.
callParent
-
functionName
-
arguments
call the method of parent。
Parameters:
-
functionName
Stringfunction's name
-
arguments
ArrayFixed 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
}
clone
()
LBitmap
public
Returns a new LBitmap object that is a clone of the original instance with an exact copy of the contained bitmap.
Returns:
A new LSprite object that is identical to the original.
Example:
var bmd = new LBitmapData("#FF0000", 0, 0, 100, 100);
var bm1 = new LBitmap(bmd);
addChild(bm1);
var bm2 = bm1.clone();
bm2.x = 120;
addChild(bm2);
dispatchEvent
-
event
Dispatches an event into the event flow. The event target is the LEventDispatcher object upon which the dispatchEvent() method is called.
Parameters:
-
event
LEvent | StringThe 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:
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
Returns a rectangle that defines the area of the display object relative to the coordinate system of the targetCoordinateSpace object.
Parameters:
-
targetCoordinateSpace
LDisplayObjectThe display object that defines the coordinate system to use.
Returns:
The rectangle that defines the area of the display object relative to the targetCoordinateSpace object's coordinate system.
getDataURL
()
Base64 Image
public
Get a string of base64-encoded image.
Returns:
a string of base64-encoded image.
getHeight
()
Float
public
Get the height of the display object, in pixels.
Returns:
the height of the display object.
Example:
var bitmapdata = new LBitmapData(event.currentTarget);
var bitmap = new LBitmap(bitmapdata);
addChild(bitmap);
trace("height : " + bitmap.getHeight());
getRootCoordinate
()
LPoint
public
Get the coordinates (Relative to the canvas).
Returns:
a LPoint object。
getWidth
()
Float
public
Get the width of the display object, in pixels.
Returns:
the width of the display object.
Example:
var bitmapdata = new LBitmapData(event.currentTarget);
var bitmap = new LBitmap(bitmapdata);
addChild(bitmap);
trace("width : " + bitmap.getWidth());
hasEventListener
-
type
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
StringThe type of event.
Returns:
A value of true if a listener of the specified type is registered; false otherwise.
remove
()
public
Remove self from the parent container.
removeAllEventListener
()
public
Removes all the listeners from the LEventDispatcher object.
removeEventListener
-
type
-
listener
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
StringThe type of event.
-
listener
FunctionThe listener object to remove.
Properties
alpha
Float
public
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
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
filters
Array
public
An indexed array that contains each filter object currently associated with the display object.
Default: null
mask
LDisplayObject
public
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
objectIndex
Int
public
ID of the object
rotate
Float
public
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
rotateCenter
Boolean
public
Set the LBitmap object's center of rotation .
Default: true
scaleX
Float
public
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
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
type
String
public
type of the object
Default: LBitmap
visible
Boolean
public
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
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
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
Disabled.