UNPKG

starling-framework

Version:

A fast, productive library for 2D cross-platform development.

836 lines (821 loc) 32.9 kB
// Class: starling.display.DisplayObject var $global = typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : this $global.Object.defineProperty(exports, "__esModule", {value: true}); var __map_reserved = {}; // Imports var $hxClasses = require("./../../hxClasses_stub").default; var $hxEnums = require("./../../hxEnums_stub").default; var $import = require("./../../import_stub").default; var $bind = require("./../../bind_stub").default; var $extend = require("./../../extend_stub").default; function starling_events_EventDispatcher() {return require("./../../starling/events/EventDispatcher");} function openfl_geom_Matrix() {return $import(require("openfl/geom/Matrix"));} function js__$Boot_HaxeError() {return require("./../../js/_Boot/HaxeError");} function starling_errors_AbstractMethodError() {return require("./../../starling/errors/AbstractMethodError");} function openfl_geom_Point() {return $import(require("openfl/geom/Point"));} function starling_utils_MatrixUtil() {return require("./../../starling/utils/MatrixUtil");} function starling_utils_MathUtil() {return require("./../../starling/utils/MathUtil");} function openfl_errors_ArgumentError() {return $import(require("openfl/errors/ArgumentError"));} function starling_core_Starling() {return require("./../../starling/core/Starling");} function starling_display_Stage() {return require("./../../starling/display/Stage");} function openfl_display_BitmapData() {return $import(require("openfl/display/BitmapData"));} function starling_utils_Color() {return require("./../../starling/utils/Color");} function starling_utils_Pool() {return require("./../../starling/utils/Pool");} function starling_utils_Execute() {return require("./../../starling/utils/Execute");} function openfl_geom_Matrix3D() {return $import(require("openfl/geom/Matrix3D"));} function openfl_errors_IllegalOperationError() {return $import(require("openfl/errors/IllegalOperationError"));} function openfl_ui_Mouse() {return $import(require("openfl/ui/Mouse"));} function starling_utils_SystemUtil() {return require("./../../starling/utils/SystemUtil");} function haxe_Log() {return require("./../../haxe/Log");} function openfl__$Vector_Vector_$Impl_$() {return require("./../../openfl/_Vector/Vector_Impl_");} function openfl_geom_Vector3D() {return $import(require("openfl/geom/Vector3D"));} function openfl_geom_Rectangle() {return $import(require("openfl/geom/Rectangle"));} function starling_rendering_BatchToken() {return require("./../../starling/rendering/BatchToken");} // Constructor var DisplayObject = function() { this.__popToken = new (starling_rendering_BatchToken().default)(); this.__pushToken = new (starling_rendering_BatchToken().default)(); this.__maskInverted = false; this.__is3D = false; (starling_events_EventDispatcher().default).call(this); this.__x = this.__y = this.__pivotX = this.__pivotY = this.__rotation = this.__skewX = this.__skewY = 0.0; this.__scaleX = this.__scaleY = this.__alpha = 1.0; this.__visible = this.__touchable = this.__hasVisibleArea = true; this.__blendMode = "auto"; this.__transformationMatrix = new (openfl_geom_Matrix().default)(); } // Meta DisplayObject.__name__ = "starling.display.DisplayObject"; DisplayObject.__isInterface__ = false; DisplayObject.__super__ = (starling_events_EventDispatcher().default); DisplayObject.prototype = $extend((starling_events_EventDispatcher().default).prototype, { dispose: function() { if(this.__filter != null) { this.__filter.dispose(); } if(this.__mask != null) { this.__mask.dispose(); } this.removeEventListeners(); this.set_mask(null); }, removeFromParent: function(dispose) { if(dispose == null) { dispose = false; } if(this.__parent != null) { this.__parent.removeChild(this,dispose); } else if(dispose) { this.dispose(); } }, getTransformationMatrix: function(targetSpace,out) { var currentObject; if(out != null) { out.identity(); } else { out = new (openfl_geom_Matrix().default)(); } if(targetSpace == this) { return out; } else if(targetSpace == this.__parent || targetSpace == null && this.__parent == null) { out.copyFrom(this.get_transformationMatrix()); return out; } else if(targetSpace == null || targetSpace == this.get_base()) { currentObject = this; while(currentObject != targetSpace) { out.concat(currentObject.get_transformationMatrix()); currentObject = currentObject.__parent; } return out; } else if(targetSpace.__parent == this) { targetSpace.getTransformationMatrix(this,out); out.invert(); return out; } var commonParent = DisplayObject.__findCommonParent(this,targetSpace); currentObject = this; while(currentObject != commonParent) { out.concat(currentObject.get_transformationMatrix()); currentObject = currentObject.__parent; } if(commonParent == targetSpace) { return out; } DisplayObject.sHelperMatrix.identity(); currentObject = targetSpace; while(currentObject != commonParent) { DisplayObject.sHelperMatrix.concat(currentObject.get_transformationMatrix()); currentObject = currentObject.__parent; } DisplayObject.sHelperMatrix.invert(); out.concat(DisplayObject.sHelperMatrix); return out; }, getBounds: function(targetSpace,out) { throw new (js__$Boot_HaxeError().default)(new (starling_errors_AbstractMethodError().default)()); }, hitTest: function(localPoint) { if(!this.__visible || !this.__touchable) { return null; } if(this.__mask != null && !this.hitTestMask(localPoint)) { return null; } if(this.getBounds(this,DisplayObject.sHelperRect).containsPoint(localPoint)) { return this; } else { return null; } }, hitTestMask: function(localPoint) { if(this.__mask != null) { if(this.__mask.get_stage() != null) { this.getTransformationMatrix(this.__mask,DisplayObject.sHelperMatrixAlt); } else { DisplayObject.sHelperMatrixAlt.copyFrom(this.__mask.get_transformationMatrix()); DisplayObject.sHelperMatrixAlt.invert(); } var helperPoint = localPoint == DisplayObject.sHelperPoint ? new (openfl_geom_Point().default)() : DisplayObject.sHelperPoint; (starling_utils_MatrixUtil().default).transformPoint(DisplayObject.sHelperMatrixAlt,localPoint,helperPoint); var isMaskHit = this.__mask.hitTest(helperPoint) != null; if(this.__maskInverted) { return !isMaskHit; } else { return isMaskHit; } } else { return true; } }, localToGlobal: function(localPoint,out) { if(this.get_is3D()) { DisplayObject.sHelperPoint3D.setTo(localPoint.x,localPoint.y,0); return this.local3DToGlobal(DisplayObject.sHelperPoint3D,out); } else { this.getTransformationMatrix(this.get_base(),DisplayObject.sHelperMatrixAlt); return (starling_utils_MatrixUtil().default).transformPoint(DisplayObject.sHelperMatrixAlt,localPoint,out); } }, globalToLocal: function(globalPoint,out) { if(this.get_is3D()) { this.globalToLocal3D(globalPoint,DisplayObject.sHelperPoint3D); this.get_stage().getCameraPosition(this,DisplayObject.sHelperPointAlt3D); return (starling_utils_MathUtil().default).intersectLineWithXYPlane(DisplayObject.sHelperPointAlt3D,DisplayObject.sHelperPoint3D,out); } else { this.getTransformationMatrix(this.get_base(),DisplayObject.sHelperMatrixAlt); DisplayObject.sHelperMatrixAlt.invert(); return (starling_utils_MatrixUtil().default).transformPoint(DisplayObject.sHelperMatrixAlt,globalPoint,out); } }, render: function(painter) { throw new (js__$Boot_HaxeError().default)(new (starling_errors_AbstractMethodError().default)()); }, alignPivot: function(horizontalAlign,verticalAlign) { if(verticalAlign == null) { verticalAlign = "center"; } if(horizontalAlign == null) { horizontalAlign = "center"; } var bounds = this.getBounds(this,DisplayObject.sHelperRect); if(horizontalAlign == "left") { this.set_pivotX(bounds.x); } else if(horizontalAlign == "center") { this.set_pivotX(bounds.x + bounds.width / 2.0); } else if(horizontalAlign == "right") { this.set_pivotX(bounds.x + bounds.width); } else { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Invalid horizontal alignment: " + horizontalAlign)); } if(verticalAlign == "top") { this.set_pivotY(bounds.y); } else if(verticalAlign == "center") { this.set_pivotY(bounds.y + bounds.height / 2.0); } else if(verticalAlign == "bottom") { this.set_pivotY(bounds.y + bounds.height); } else { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Invalid vertical alignment: " + verticalAlign)); } }, drawToBitmapData: function(out,color,alpha) { if(alpha == null) { alpha = 0.0; } if(color == null) { color = 0; } var painter = (starling_core_Starling().default).get_current().get_painter(); var stage = (starling_core_Starling().default).get_current().get_stage(); var viewPort = (starling_core_Starling().default).get_current().get_viewPort(); var stageWidth = stage.get_stageWidth(); var stageHeight = stage.get_stageHeight(); var scaleX = viewPort.width / stageWidth; var scaleY = viewPort.height / stageHeight; var backBufferScale = painter.get_backBufferScaleFactor(); var totalScaleX = scaleX * backBufferScale; var totalScaleY = scaleY * backBufferScale; var projectionX; var projectionY; var bounds; if(((this) instanceof (starling_display_Stage().default))) { projectionX = viewPort.x < 0 ? -viewPort.x / scaleX : 0.0; projectionY = viewPort.y < 0 ? -viewPort.y / scaleY : 0.0; if(out == null) { out = new (openfl_display_BitmapData().default)(Math.ceil(painter.get_backBufferWidth() * backBufferScale),Math.ceil(painter.get_backBufferHeight() * backBufferScale)); } } else { bounds = this.getBounds(this.__parent,DisplayObject.sHelperRect); projectionX = bounds.x; projectionY = bounds.y; if(out == null) { out = new (openfl_display_BitmapData().default)(Math.ceil(bounds.width * totalScaleX),Math.ceil(bounds.height * totalScaleY)); } } color = (starling_utils_Color().default).multiply(color,alpha); painter.pushState(); painter.setupContextDefaults(); painter.get_state().set_renderTarget(null); painter.get_state().setModelviewMatricesToIdentity(); painter.setStateTo(this.get_transformationMatrix()); var stepX; var stepY = projectionY; var stepWidth = painter.get_backBufferWidth() / scaleX; var stepHeight = painter.get_backBufferHeight() / scaleY; var positionInBitmap = (starling_utils_Pool().default).getPoint(0,0); var boundsInBuffer = (starling_utils_Pool().default).getRectangle(0,0,painter.get_backBufferWidth() * backBufferScale,painter.get_backBufferHeight() * backBufferScale); if(this.__mask != null) { painter.eraseMask(this.get_mask(),this); } while(positionInBitmap.y < out.height) { stepX = projectionX; positionInBitmap.x = 0; while(positionInBitmap.x < out.width) { painter.clear(color,alpha); painter.get_state().setProjectionMatrix(stepX,stepY,stepWidth,stepHeight,stageWidth,stageHeight,stage.get_cameraPosition()); if(this.__mask != null) { painter.drawMask(this.get_mask(),this); } if(this.__filter != null) { this.__filter.render(painter); } else { this.render(painter); } if(this.__mask != null) { painter.eraseMask(this.get_mask(),this); } painter.finishMeshBatch(); (starling_utils_Execute().default).execute(($_=painter.get_context(),$bind($_,$_.drawToBitmapData)),[out,boundsInBuffer,positionInBitmap]); stepX += stepWidth; positionInBitmap.x += stepWidth * totalScaleX; } stepY += stepHeight; positionInBitmap.y += stepHeight * totalScaleY; } painter.popState(); (starling_utils_Pool().default).putRectangle(boundsInBuffer); (starling_utils_Pool().default).putPoint(positionInBitmap); return out; }, getTransformationMatrix3D: function(targetSpace,out) { var currentObject; if(out != null) { out.identity(); } else { out = new (openfl_geom_Matrix3D().default)(); } if(targetSpace == this) { return out; } else if(targetSpace == this.__parent || targetSpace == null && this.__parent == null) { out.copyFrom(this.get_transformationMatrix3D()); return out; } else if(targetSpace == null || targetSpace == this.get_base()) { currentObject = this; while(currentObject != targetSpace) { out.append(currentObject.get_transformationMatrix3D()); currentObject = currentObject.__parent; } return out; } else if(targetSpace.__parent == this) { targetSpace.getTransformationMatrix3D(this,out); out.invert(); return out; } var commonParent = DisplayObject.__findCommonParent(this,targetSpace); currentObject = this; while(currentObject != commonParent) { out.append(currentObject.get_transformationMatrix3D()); currentObject = currentObject.__parent; } if(commonParent == targetSpace) { return out; } DisplayObject.sHelperMatrix3D.identity(); currentObject = targetSpace; while(currentObject != commonParent) { DisplayObject.sHelperMatrix3D.append(currentObject.get_transformationMatrix3D()); currentObject = currentObject.__parent; } DisplayObject.sHelperMatrix3D.invert(); out.append(DisplayObject.sHelperMatrix3D); return out; }, local3DToGlobal: function(localPoint,out) { var stage = this.get_stage(); if(stage == null) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_IllegalOperationError().default)("Object not connected to stage")); } this.getTransformationMatrix3D(stage,DisplayObject.sHelperMatrixAlt3D); (starling_utils_MatrixUtil().default).transformPoint3D(DisplayObject.sHelperMatrixAlt3D,localPoint,DisplayObject.sHelperPoint3D); return (starling_utils_MathUtil().default).intersectLineWithXYPlane(stage.get_cameraPosition(),DisplayObject.sHelperPoint3D,out); }, globalToLocal3D: function(globalPoint,out) { var stage = this.get_stage(); if(stage == null) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_IllegalOperationError().default)("Object not connected to stage")); } this.getTransformationMatrix3D(stage,DisplayObject.sHelperMatrixAlt3D); DisplayObject.sHelperMatrixAlt3D.invert(); return (starling_utils_MatrixUtil().default).transformCoords3D(DisplayObject.sHelperMatrixAlt3D,globalPoint.x,globalPoint.y,0,out); }, __setParent: function(value) { var ancestor = value; while(ancestor != this && ancestor != null) ancestor = ancestor.__parent; if(ancestor == this) { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("An object cannot be added as a child to itself or one " + "of its children (or children's children, etc.)")); } else { this.__parent = value; } }, __setIs3D: function(value) { this.__is3D = value; }, get_isMask: function() { return this.__maskee != null; }, setRequiresRedraw: function() { var parent = this.__parent != null ? this.__parent : this.__maskee; var frameID = (starling_core_Starling().default).get_current() != null ? (starling_core_Starling().default).get_current().get_frameID() : 0; this.__lastParentOrSelfChangeFrameID = frameID; this.__hasVisibleArea = this.__alpha != 0.0 && this.__visible && this.__maskee == null && this.__scaleX != 0.0 && this.__scaleY != 0.0; while(parent != null && parent.__lastChildChangeFrameID != frameID) { parent.__lastChildChangeFrameID = frameID; parent = parent.__parent != null ? parent.__parent : parent.__maskee; } }, get_requiresRedraw: function() { var frameID = (starling_core_Starling().default).get_current().get_frameID(); if(this.__lastParentOrSelfChangeFrameID != frameID) { return this.__lastChildChangeFrameID == frameID; } else { return true; } }, excludeFromCache: function() { var object = this; var max = -1; while(object != null && object.__tokenFrameID != max) { object.__tokenFrameID = max; object = object.__parent; } }, __setTransformationChanged: function() { this.__transformationChanged = true; this.setRequiresRedraw(); }, __updateTransformationMatrices: function(x,y,pivotX,pivotY,scaleX,scaleY,skewX,skewY,rotation,out,out3D) { if(skewX == 0.0 && skewY == 0.0) { if(rotation == 0.0) { out.setTo(scaleX,0.0,0.0,scaleY,x - pivotX * scaleX,y - pivotY * scaleY); } else { var cos = Math.cos(rotation); var sin = Math.sin(rotation); var a = scaleX * cos; var b = scaleX * sin; var c = scaleY * -sin; var d = scaleY * cos; var tx = x - pivotX * a - pivotY * c; var ty = y - pivotX * b - pivotY * d; out.setTo(a,b,c,d,tx,ty); } } else { out.identity(); out.scale(scaleX,scaleY); (starling_utils_MatrixUtil().default).skew(out,skewX,skewY); out.rotate(rotation); out.translate(x,y); if(pivotX != 0.0 || pivotY != 0.0) { out.tx = x - out.a * pivotX - out.c * pivotY; out.ty = y - out.b * pivotX - out.d * pivotY; } } if(out3D != null) { (starling_utils_MatrixUtil().default).convertTo3D(out,out3D); } }, dispatchEvent: function(event) { if(event.type == "removedFromStage" && this.get_stage() == null) { return; } else { (starling_events_EventDispatcher().default).prototype.dispatchEvent.call(this,event); } }, addEventListener: function(type,listener) { if(type == "enterFrame" && !this.hasEventListener(type)) { this.addEventListener("addedToStage",$bind(this,this.__addEnterFrameListenerToStage)); this.addEventListener("removedFromStage",$bind(this,this.__removeEnterFrameListenerFromStage)); if(this.get_stage() != null) { this.__addEnterFrameListenerToStage(); } } (starling_events_EventDispatcher().default).prototype.addEventListener.call(this,type,listener); }, removeEventListener: function(type,listener) { (starling_events_EventDispatcher().default).prototype.removeEventListener.call(this,type,listener); if(type == "enterFrame" && !this.hasEventListener(type)) { this.removeEventListener("addedToStage",$bind(this,this.__addEnterFrameListenerToStage)); this.removeEventListener("removedFromStage",$bind(this,this.__removeEnterFrameListenerFromStage)); this.__removeEnterFrameListenerFromStage(); } }, removeEventListeners: function(type) { if((type == null || type == "enterFrame") && this.hasEventListener("enterFrame")) { this.removeEventListener("addedToStage",$bind(this,this.__addEnterFrameListenerToStage)); this.removeEventListener("removedFromStage",$bind(this,this.__removeEnterFrameListenerFromStage)); this.__removeEnterFrameListenerFromStage(); } (starling_events_EventDispatcher().default).prototype.removeEventListeners.call(this,type); }, __addEnterFrameListenerToStage: function(e) { (starling_core_Starling().default).get_current().get_stage().addEnterFrameListener(this); }, __removeEnterFrameListenerFromStage: function(e) { (starling_core_Starling().default).get_current().get_stage().removeEnterFrameListener(this); }, get_transformationMatrix: function() { if(this.__transformationChanged) { this.__transformationChanged = false; if(this.__transformationMatrix3D == null && this.__is3D) { this.__transformationMatrix3D = new (openfl_geom_Matrix3D().default)(); } this.__updateTransformationMatrices(this.__x,this.__y,this.__pivotX,this.__pivotY,this.__scaleX,this.__scaleY,this.__skewX,this.__skewY,this.__rotation,this.__transformationMatrix,this.__transformationMatrix3D); } return this.__transformationMatrix; }, set_transformationMatrix: function(matrix) { var PI_Q = Math.PI / 4.0; this.setRequiresRedraw(); this.__transformationChanged = false; this.__transformationMatrix.copyFrom(matrix); this.__pivotX = this.__pivotY = 0; this.__x = matrix.tx; this.__y = matrix.ty; this.__skewX = Math.atan(-matrix.c / matrix.d); this.__skewY = Math.atan(matrix.b / matrix.a); if(this.__skewX != this.__skewX) { this.__skewX = 0.0; } if(this.__skewY != this.__skewY) { this.__skewY = 0.0; } this.__scaleY = this.__skewX > -PI_Q && this.__skewX < PI_Q ? matrix.d / Math.cos(this.__skewX) : -matrix.c / Math.sin(this.__skewX); this.__scaleX = this.__skewY > -PI_Q && this.__skewY < PI_Q ? matrix.a / Math.cos(this.__skewY) : matrix.b / Math.sin(this.__skewY); if((starling_utils_MathUtil().default).isEquivalent(this.__skewX,this.__skewY)) { this.__rotation = this.__skewX; this.__skewX = this.__skewY = 0; } else { this.__rotation = 0; } return this.__transformationMatrix; }, get_transformationMatrix3D: function() { if(this.__transformationMatrix3D == null) { this.__transformationMatrix3D = (starling_utils_MatrixUtil().default).convertTo3D(this.__transformationMatrix); } if(this.__transformationChanged) { this.__transformationChanged = false; this.__updateTransformationMatrices(this.__x,this.__y,this.__pivotX,this.__pivotY,this.__scaleX,this.__scaleY,this.__skewX,this.__skewY,this.__rotation,this.__transformationMatrix,this.__transformationMatrix3D); } return this.__transformationMatrix3D; }, get_is3D: function() { return this.__is3D; }, get_useHandCursor: function() { return this.__useHandCursor; }, set_useHandCursor: function(value) { if(value == this.__useHandCursor) { return value; } this.__useHandCursor = value; if(this.__useHandCursor) { this.addEventListener("touch",$bind(this,this.__onTouch)); } else { this.removeEventListener("touch",$bind(this,this.__onTouch)); } return value; }, __onTouch: function(event) { (openfl_ui_Mouse().default).cursor = event.interactsWith(this) ? "button" : "auto"; }, get_bounds: function() { return this.getBounds(this.__parent); }, get_width: function() { return this.getBounds(this.__parent,DisplayObject.sHelperRect).width; }, set_width: function(value) { var actualWidth; var scaleIsNaN = this.__scaleX != this.__scaleX; var scaleIsZero = this.__scaleX < 1e-8 && this.__scaleX > -1e-8; if(scaleIsZero || scaleIsNaN) { this.set_scaleX(1.0); actualWidth = this.get_width(); } else { actualWidth = Math.abs(this.get_width() / this.__scaleX); } if(actualWidth != 0) { this.set_scaleX(value / actualWidth); } return value; }, get_height: function() { return this.getBounds(this.__parent,DisplayObject.sHelperRect).height; }, set_height: function(value) { var actualHeight; var scaleIsNaN = this.__scaleY != this.__scaleY; var scaleIsZero = this.__scaleY < 1e-8 && this.__scaleY > -1e-8; if(scaleIsZero || scaleIsNaN) { this.set_scaleY(1.0); actualHeight = this.get_height(); } else { actualHeight = Math.abs(this.get_height() / this.__scaleY); } if(actualHeight != 0) { this.set_scaleY(value / actualHeight); } return this.get_height(); }, get_x: function() { return this.__x; }, set_x: function(value) { if(this.__x != value) { this.__x = value; this.__setTransformationChanged(); } return value; }, get_y: function() { return this.__y; }, set_y: function(value) { if(this.__y != value) { this.__y = value; this.__setTransformationChanged(); } return value; }, get_pivotX: function() { return this.__pivotX; }, set_pivotX: function(value) { if(this.__pivotX != value) { this.__pivotX = value; this.__setTransformationChanged(); } return value; }, get_pivotY: function() { return this.__pivotY; }, set_pivotY: function(value) { if(this.__pivotY != value) { this.__pivotY = value; this.__setTransformationChanged(); } return value; }, get_scaleX: function() { return this.__scaleX; }, set_scaleX: function(value) { if(this.__scaleX != value) { this.__scaleX = value; this.__setTransformationChanged(); } return value; }, get_scaleY: function() { return this.__scaleY; }, set_scaleY: function(value) { if(this.__scaleY != value) { this.__scaleY = value; this.__setTransformationChanged(); } return value; }, get_scale: function() { return this.get_scaleX(); }, set_scale: function(value) { return this.set_scaleX(this.set_scaleY(value)); }, get_skewX: function() { return this.__skewX; }, set_skewX: function(value) { value = (starling_utils_MathUtil().default).normalizeAngle(value); if(this.__skewX != value) { this.__skewX = value; this.__setTransformationChanged(); } return value; }, get_skewY: function() { return this.__skewY; }, set_skewY: function(value) { value = (starling_utils_MathUtil().default).normalizeAngle(value); if(this.__skewY != value) { this.__skewY = value; this.__setTransformationChanged(); } return value; }, get_rotation: function() { return this.__rotation; }, set_rotation: function(value) { value = (starling_utils_MathUtil().default).normalizeAngle(value); if(this.__rotation != value) { this.__rotation = value; this.__setTransformationChanged(); } return value; }, get_isRotated: function() { if(!(this.__rotation != 0.0 || this.__skewX != 0.0)) { return this.__skewY != 0.0; } else { return true; } }, get_alpha: function() { return this.__alpha; }, set_alpha: function(value) { if(value != this.__alpha) { this.__alpha = value < 0.0 ? 0.0 : value > 1.0 ? 1.0 : value; this.setRequiresRedraw(); } return value; }, get_visible: function() { return this.__visible; }, set_visible: function(value) { if(value != this.__visible) { this.__visible = value; this.setRequiresRedraw(); } return value; }, get_touchable: function() { return this.__touchable; }, set_touchable: function(value) { return this.__touchable = value; }, get_blendMode: function() { return this.__blendMode; }, set_blendMode: function(value) { if(value != this.__blendMode) { this.__blendMode = value; this.setRequiresRedraw(); } return value; }, get_name: function() { return this.__name; }, set_name: function(value) { return this.__name = value; }, get_filter: function() { return this.__filter; }, set_filter: function(value) { if(value != this.__filter) { if(this.__filter != null) { this.__filter.setTarget(null); } if(value != null) { value.setTarget(this); } this.__filter = value; this.setRequiresRedraw(); } return value; }, get_mask: function() { return this.__mask; }, set_mask: function(value) { if(this.__mask != value) { if(!DisplayObject.sMaskWarningShown) { if(!(starling_utils_SystemUtil().default).get_supportsDepthAndStencil()) { (haxe_Log().default).trace("[Starling] Full mask support requires 'depthAndStencil'" + " to be enabled in the application descriptor.",{ fileName : "../src/starling/display/DisplayObject.hx", lineNumber : 1293, className : "starling.display.DisplayObject", methodName : "set_mask"}); } DisplayObject.sMaskWarningShown = true; } if(this.__mask != null) { this.__mask.__maskee = null; } if(value != null) { value.__maskee = this; value.__hasVisibleArea = false; } this.__mask = value; this.setRequiresRedraw(); } return this.__mask; }, get_maskInverted: function() { return this.__maskInverted; }, set_maskInverted: function(value) { return this.__maskInverted = value; }, get_parent: function() { return this.__parent; }, get_base: function() { var currentObject = this; while(currentObject.__parent != null) currentObject = currentObject.__parent; return currentObject; }, get_root: function() { var currentObject = this; while(currentObject.__parent != null) if(((currentObject.__parent) instanceof (starling_display_Stage().default))) { return currentObject; } else { currentObject = currentObject.get_parent(); } return null; }, get_stage: function() { if(((this.get_base()) instanceof (starling_display_Stage().default))) { return this.get_base(); } else { return null; } } }); DisplayObject.prototype.__class__ = DisplayObject.prototype.constructor = $hxClasses["starling.display.DisplayObject"] = DisplayObject; // Init Object.defineProperties(DisplayObject.prototype,{ isMask : { get : function () { return this.get_isMask (); }}, requiresRedraw : { get : function () { return this.get_requiresRedraw (); }}, transformationMatrix : { get : function () { return this.get_transformationMatrix (); }, set : function (v) { return this.set_transformationMatrix (v); }}, transformationMatrix3D : { get : function () { return this.get_transformationMatrix3D (); }}, is3D : { get : function () { return this.get_is3D (); }}, useHandCursor : { get : function () { return this.get_useHandCursor (); }, set : function (v) { return this.set_useHandCursor (v); }}, bounds : { get : function () { return this.get_bounds (); }}, width : { get : function () { return this.get_width (); }, set : function (v) { return this.set_width (v); }}, height : { get : function () { return this.get_height (); }, set : function (v) { return this.set_height (v); }}, x : { get : function () { return this.get_x (); }, set : function (v) { return this.set_x (v); }}, y : { get : function () { return this.get_y (); }, set : function (v) { return this.set_y (v); }}, pivotX : { get : function () { return this.get_pivotX (); }, set : function (v) { return this.set_pivotX (v); }}, pivotY : { get : function () { return this.get_pivotY (); }, set : function (v) { return this.set_pivotY (v); }}, scaleX : { get : function () { return this.get_scaleX (); }, set : function (v) { return this.set_scaleX (v); }}, scaleY : { get : function () { return this.get_scaleY (); }, set : function (v) { return this.set_scaleY (v); }}, scale : { get : function () { return this.get_scale (); }, set : function (v) { return this.set_scale (v); }}, skewX : { get : function () { return this.get_skewX (); }, set : function (v) { return this.set_skewX (v); }}, skewY : { get : function () { return this.get_skewY (); }, set : function (v) { return this.set_skewY (v); }}, rotation : { get : function () { return this.get_rotation (); }, set : function (v) { return this.set_rotation (v); }}, isRotated : { get : function () { return this.get_isRotated (); }}, alpha : { get : function () { return this.get_alpha (); }, set : function (v) { return this.set_alpha (v); }}, visible : { get : function () { return this.get_visible (); }, set : function (v) { return this.set_visible (v); }}, touchable : { get : function () { return this.get_touchable (); }, set : function (v) { return this.set_touchable (v); }}, blendMode : { get : function () { return this.get_blendMode (); }, set : function (v) { return this.set_blendMode (v); }}, name : { get : function () { return this.get_name (); }, set : function (v) { return this.set_name (v); }}, filter : { get : function () { return this.get_filter (); }, set : function (v) { return this.set_filter (v); }}, mask : { get : function () { return this.get_mask (); }, set : function (v) { return this.set_mask (v); }}, maskInverted : { get : function () { return this.get_maskInverted (); }, set : function (v) { return this.set_maskInverted (v); }}, parent : { get : function () { return this.get_parent (); }}, base : { get : function () { return this.get_base (); }}, root : { get : function () { return this.get_root (); }}, stage : { get : function () { return this.get_stage (); }}}); // Statics DisplayObject.__findCommonParent = function(object1,object2) { var currentObject = object1; while(currentObject != null) { (openfl__$Vector_Vector_$Impl_$().default).set(DisplayObject.sAncestors,DisplayObject.sAncestors.length,currentObject); currentObject = currentObject.__parent; } currentObject = object2; while(true) { var tmp; if(currentObject != null) { var this1 = DisplayObject.sAncestors; tmp = (Array.prototype.indexOf.call)(this1,currentObject,0) == -1; } else { tmp = false; } if(!tmp) { break; } currentObject = currentObject.__parent; } DisplayObject.sAncestors.length = 0; if(currentObject != null) { return currentObject; } else { throw new (js__$Boot_HaxeError().default)(new (openfl_errors_ArgumentError().default)("Object not connected to target")); } } DisplayObject.sAncestors = (openfl__$Vector_Vector_$Impl_$().default)._new() DisplayObject.sHelperPoint = new (openfl_geom_Point().default)() DisplayObject.sHelperPoint3D = new (openfl_geom_Vector3D().default)() DisplayObject.sHelperPointAlt3D = new (openfl_geom_Vector3D().default)() DisplayObject.sHelperRect = new (openfl_geom_Rectangle().default)() DisplayObject.sHelperMatrix = new (openfl_geom_Matrix().default)() DisplayObject.sHelperMatrixAlt = new (openfl_geom_Matrix().default)() DisplayObject.sHelperMatrix3D = new (openfl_geom_Matrix3D().default)() DisplayObject.sHelperMatrixAlt3D = new (openfl_geom_Matrix3D().default)() DisplayObject.sMaskWarningShown = false // Export exports.default = DisplayObject;