├── .gitignore ├── README.md └── StarlingFeathers ├── .actionScriptProperties ├── .flexLibProperties ├── .project └── src ├── com └── adobe │ └── utils │ └── AGALMiniAssembler.as ├── extend ├── CoolDownImage.as ├── Gauge.as ├── HGauge.as ├── MultidirectionalTileScroller.as ├── PixelMaskDisplayObject.as └── particlesystem │ ├── ColorArgb.as │ ├── PDParticle.as │ ├── PDParticleSystem.as │ ├── Particle.as │ ├── ParticleDesignerPS.as │ └── ParticleSystem.as ├── feathers ├── controls │ ├── Alert.as │ ├── Button.as │ ├── ButtonGroup.as │ ├── Callout.as │ ├── Check.as │ ├── Drawers.as │ ├── GroupedList.as │ ├── Header.as │ ├── IDirectionalScrollBar.as │ ├── IRange.as │ ├── IScreen.as │ ├── IScrollBar.as │ ├── IScrollContainer.as │ ├── ImageLoader.as │ ├── Label.as │ ├── LayoutGroup.as │ ├── List.as │ ├── NumericStepper.as │ ├── PageIndicator.as │ ├── Panel.as │ ├── PanelScreen.as │ ├── PickerList.as │ ├── ProgressBar.as │ ├── Radio.as │ ├── Screen.as │ ├── ScreenNavigator.as │ ├── ScreenNavigatorItem.as │ ├── ScrollBar.as │ ├── ScrollContainer.as │ ├── ScrollScreen.as │ ├── ScrollText.as │ ├── Scroller.as │ ├── SimpleScrollBar.as │ ├── Slider.as │ ├── TabBar.as │ ├── TextArea.as │ ├── TextInput.as │ ├── ToggleButton.as │ ├── ToggleSwitch.as │ ├── popups │ │ ├── CalloutPopUpContentManager.as │ │ ├── DropDownPopUpContentManager.as │ │ ├── IPopUpContentManager.as │ │ └── VerticalCenteredPopUpContentManager.as │ ├── renderers │ │ ├── BaseDefaultItemRenderer.as │ │ ├── DefaultGroupedListHeaderOrFooterRenderer.as │ │ ├── DefaultGroupedListItemRenderer.as │ │ ├── DefaultListItemRenderer.as │ │ ├── IGroupedListHeaderOrFooterRenderer.as │ │ ├── IGroupedListItemRenderer.as │ │ ├── IListItemRenderer.as │ │ ├── LayoutGroupGroupedListHeaderOrFooterRenderer.as │ │ ├── LayoutGroupGroupedListItemRenderer.as │ │ └── LayoutGroupListItemRenderer.as │ ├── supportClasses │ │ ├── GroupedListDataViewPort.as │ │ ├── IViewPort.as │ │ ├── LayoutViewPort.as │ │ ├── ListDataViewPort.as │ │ └── TextFieldViewPort.as │ └── text │ │ ├── BitmapFontTextEditor.as │ │ ├── BitmapFontTextRenderer.as │ │ ├── ITextEditorViewPort.as │ │ ├── StageTextTextEditor.as │ │ ├── TextBlockTextEditor.as │ │ ├── TextBlockTextRenderer.as │ │ ├── TextFieldTextEditor.as │ │ ├── TextFieldTextEditorViewPort.as │ │ └── TextFieldTextRenderer.as ├── core │ ├── DefaultFocusManager.as │ ├── DefaultPopUpManager.as │ ├── DisplayListWatcher.as │ ├── FeathersControl.as │ ├── FocusManager.as │ ├── IFeathersControl.as │ ├── IFeathersDisplayObject.as │ ├── IFeathersEventDispatcher.as │ ├── IFocusDisplayObject.as │ ├── IFocusExtras.as │ ├── IFocusManager.as │ ├── IGroupedToggle.as │ ├── IMultilineTextEditor.as │ ├── IPopUpManager.as │ ├── ITextBaselineControl.as │ ├── ITextEditor.as │ ├── ITextRenderer.as │ ├── IToggle.as │ ├── IValidating.as │ ├── PopUpManager.as │ ├── PropertyProxy.as │ ├── ToggleGroup.as │ ├── TokenList.as │ └── ValidationQueue.as ├── data │ ├── ArrayChildrenHierarchicalCollectionDataDescriptor.as │ ├── ArrayListCollectionDataDescriptor.as │ ├── HierarchicalCollection.as │ ├── IHierarchicalCollectionDataDescriptor.as │ ├── IListCollectionDataDescriptor.as │ ├── ListCollection.as │ ├── VectorIntListCollectionDataDescriptor.as │ ├── VectorListCollectionDataDescriptor.as │ ├── VectorNumberListCollectionDataDescriptor.as │ ├── VectorUintListCollectionDataDescriptor.as │ └── XMLListListCollectionDataDescriptor.as ├── display │ ├── Scale3Image.as │ ├── Scale9Image.as │ └── TiledImage.as ├── dragDrop │ ├── DragData.as │ ├── DragDropManager.as │ ├── IDragSource.as │ └── IDropTarget.as ├── events │ ├── CollectionEventType.as │ ├── DragDropEvent.as │ ├── ExclusiveTouch.as │ └── FeathersEventType.as ├── layout │ ├── AnchorLayout.as │ ├── AnchorLayoutData.as │ ├── HorizontalLayout.as │ ├── HorizontalLayoutData.as │ ├── ILayout.as │ ├── ILayoutData.as │ ├── ILayoutDisplayObject.as │ ├── ITrimmedVirtualLayout.as │ ├── IVariableVirtualLayout.as │ ├── IVirtualLayout.as │ ├── LayoutBoundsResult.as │ ├── TiledColumnsLayout.as │ ├── TiledRowsLayout.as │ ├── VerticalLayout.as │ ├── VerticalLayoutData.as │ └── ViewPortBounds.as ├── motion │ └── transitions │ │ ├── OldFadeNewSlideTransitionManager.as │ │ ├── ScreenFadeTransitionManager.as │ │ ├── ScreenSlidingStackTransitionManager.as │ │ └── TabBarSlideTransitionManager.as ├── skins │ ├── AddOnFunctionStyleProvider.as │ ├── FunctionStyleProvider.as │ ├── IStyleProvider.as │ ├── ImageStateValueSelector.as │ ├── Scale9ImageStateValueSelector.as │ ├── SmartDisplayObjectStateValueSelector.as │ ├── StandardIcons.as │ ├── StateValueSelector.as │ ├── StateWithToggleValueSelector.as │ ├── StyleNameFunctionStyleProvider.as │ └── StyleProviderRegistry.as ├── system │ └── DeviceCapabilities.as ├── text │ ├── BitmapFontTextFormat.as │ └── StageTextField.as ├── textures │ ├── Scale3Textures.as │ └── Scale9Textures.as ├── themes │ └── StyleNameFunctionTheme.as └── utils │ ├── display │ ├── calculateScaleRatioToFill.as │ ├── calculateScaleRatioToFit.as │ └── getDisplayObjectDepthFromStage.as │ ├── geom │ ├── matrixToRotation.as │ ├── matrixToScaleX.as │ └── matrixToScaleY.as │ ├── math │ ├── clamp.as │ ├── roundDownToNearest.as │ ├── roundToNearest.as │ ├── roundToPrecision.as │ └── roundUpToNearest.as │ └── text │ ├── TextInputNavigation.as │ └── TextInputRestrict.as ├── lzm ├── data │ └── BaseData.as ├── starling │ ├── STLConstant.as │ ├── STLMainClass.as │ ├── STLRootClass.as │ ├── STLStarup.as │ ├── display │ │ ├── Alert.as │ │ ├── BaseScene.as │ │ ├── BaseSceneLoading.as │ │ ├── Button.as │ │ ├── ContentList.as │ │ ├── ContentListItem.as │ │ ├── DistortImage.as │ │ ├── DistortImageContainer.as │ │ ├── GridMask.as │ │ ├── ImageViewer.as │ │ ├── ScrollContainer.as │ │ ├── ScrollContainerItem.as │ │ └── ainmation │ │ │ ├── GroupMovieClip.as │ │ │ ├── MutiStateMovieClip.as │ │ │ └── bone │ │ │ ├── BoneAnimation.as │ │ │ └── BoneAnimationFactory.as │ ├── entityComponent │ │ ├── Entity.as │ │ ├── EntityComponent.as │ │ ├── EntityWorld.as │ │ ├── effects │ │ │ └── BlurComponent.as │ │ └── gestures │ │ │ └── DragGesturesComponent.as │ ├── gestures │ │ ├── DoubleTapGestures.as │ │ ├── DragGestures.as │ │ ├── Gestures.as │ │ ├── HoldGestures.as │ │ ├── HoverGestures.as │ │ ├── MoveOverGestures.as │ │ ├── MovedGestures.as │ │ ├── RotationGestures.as │ │ ├── SwipeGestures.as │ │ ├── TapGestures.as │ │ └── ZoomGestures.as │ ├── swf │ │ ├── FPSUtil.as │ │ ├── Swf.as │ │ ├── SwfAssetManager.as │ │ ├── SwfUpdateManager.as │ │ ├── blendmode │ │ │ └── SwfBlendMode.as │ │ ├── components │ │ │ ├── ComponentConfig.as │ │ │ ├── ISwfComponent.as │ │ │ ├── ISwfComponentForEditor.as │ │ │ ├── feathers │ │ │ │ ├── FeathersButton.as │ │ │ │ ├── FeathersCheck.as │ │ │ │ ├── FeathersProgressBar.as │ │ │ │ └── FeathersTextInput.as │ │ │ └── propertyvalues │ │ │ │ └── ArrayPropertys.as │ │ ├── display │ │ │ ├── ISwfAnimation.as │ │ │ ├── SwfButton.as │ │ │ ├── SwfImage.as │ │ │ ├── SwfMovieClip.as │ │ │ ├── SwfParticleSyetem.as │ │ │ ├── SwfScale9Image.as │ │ │ ├── SwfShapeImage.as │ │ │ └── SwfSprite.as │ │ └── filter │ │ │ └── SwfFilter.as │ ├── texture │ │ └── DynamicTextureAtlas.as │ ├── ui │ │ └── layout │ │ │ └── LayoutUitl.as │ └── util │ │ └── EnterFrameFPSUtil.as └── util │ ├── AutoSkip.as │ ├── Base64.as │ ├── Bezier.as │ ├── Clone.as │ ├── CollisionUtils.as │ ├── DoScale.as │ ├── HttpClient.as │ ├── LSOManager.as │ ├── LzmPoint.as │ ├── MaxRectsBinPack.as │ ├── Mobile.as │ ├── OSUtil.as │ ├── ParticlePool.as │ ├── TimeUtil.as │ └── XXTEA.as ├── starling ├── animation │ ├── DelayedCall.as │ ├── IAnimatable.as │ ├── Juggler.as │ ├── Transitions.as │ └── Tween.as ├── core │ ├── RenderSupport.as │ ├── Starling.as │ ├── StatsDisplay.as │ └── starling_internal.as ├── display │ ├── BlendMode.as │ ├── Button.as │ ├── ButtonState.as │ ├── Canvas.as │ ├── DisplayObject.as │ ├── DisplayObjectContainer.as │ ├── Graphics.as │ ├── GraphicsEndFill.as │ ├── GraphicsLine.as │ ├── GraphicsMaterialFill.as │ ├── GraphicsPath.as │ ├── GraphicsPathCommands.as │ ├── GraphicsSolidFill.as │ ├── GraphicsTextureFill.as │ ├── IGraphicsData.as │ ├── IGraphicsFill.as │ ├── Image.as │ ├── MovieClip.as │ ├── Quad.as │ ├── QuadBatch.as │ ├── Shape.as │ ├── Sprite.as │ ├── Sprite3D.as │ ├── Stage.as │ ├── graphics │ │ ├── FastStroke.as │ │ ├── Fill.as │ │ ├── Graphic.as │ │ ├── NGon.as │ │ ├── Plane.as │ │ ├── RoundedRectangle.as │ │ ├── Stroke.as │ │ ├── StrokeVertex.as │ │ ├── TriangleFan.as │ │ ├── TriangleStrip.as │ │ ├── VertexList.as │ │ └── util │ │ │ └── TriangleUtil.as │ ├── graphicsEx │ │ ├── GraphicsEx.as │ │ ├── GraphicsExColorData.as │ │ ├── GraphicsExThicknessData.as │ │ ├── GraphicsNaturalSpline.as │ │ ├── ShapeEx.as │ │ └── StrokeEx.as │ ├── materials │ │ ├── FlatColorMaterial.as │ │ ├── IMaterial.as │ │ ├── Program3DCache.as │ │ ├── StandardMaterial.as │ │ └── TextureMaterial.as │ ├── shaders │ │ ├── AbstractShader.as │ │ ├── IShader.as │ │ ├── fragment │ │ │ ├── TextureFragmentShader.as │ │ │ ├── TextureVertexColorFragmentShader.as │ │ │ └── VertexColorFragmentShader.as │ │ └── vertex │ │ │ ├── AnimateUVVertexShader.as │ │ │ ├── RippleVertexShader.as │ │ │ └── StandardVertexShader.as │ └── util │ │ └── CurveUtil.as ├── errors │ ├── AbstractClassError.as │ ├── AbstractMethodError.as │ ├── MissingContextError.as │ └── NotSupportedError.as ├── events │ ├── EnterFrameEvent.as │ ├── Event.as │ ├── EventDispatcher.as │ ├── KeyboardEvent.as │ ├── ResizeEvent.as │ ├── Touch.as │ ├── TouchEvent.as │ ├── TouchMarker.as │ ├── TouchPhase.as │ └── TouchProcessor.as ├── filters │ ├── BlurFilter.as │ ├── ColorMatrixFilter.as │ ├── DisplacementMapFilter.as │ ├── FragmentFilter.as │ └── FragmentFilterMode.as ├── geom │ └── Polygon.as ├── text │ ├── BitmapChar.as │ ├── BitmapFont.as │ ├── MiniBitmapFont.as │ ├── TextField.as │ └── TextFieldAutoSize.as ├── textures │ ├── AtfData.as │ ├── ConcreteTexture.as │ ├── ConcreteVideoTexture.as │ ├── GradientTexture.as │ ├── RenderTexture.as │ ├── SubTexture.as │ ├── Texture.as │ ├── TextureAtlas.as │ ├── TextureOptions.as │ └── TextureSmoothing.as └── utils │ ├── ArrayUtil.as │ ├── AssetManager.as │ ├── Color.as │ ├── HAlign.as │ ├── MathUtil.as │ ├── MatrixUtil.as │ ├── RectangleUtil.as │ ├── ScaleMode.as │ ├── SystemUtil.as │ ├── VAlign.as │ ├── VectorUtil.as │ ├── VertexData.as │ ├── cleanMasterString.as │ ├── deg2rad.as │ ├── execute.as │ ├── formatString.as │ ├── getNextPowerOfTwo.as │ ├── rad2deg.as │ └── transformCoords.as └── swallow ├── effect └── EffectScene.as ├── events └── TimerEvent2D.as ├── filters ├── AdvancedFilter.as ├── BumpMakerFilter.as ├── HdrFilter.as ├── LightFilter.as ├── MaskFilter.as ├── MosaicFilter.as ├── ReliefFilter.as ├── Screenshot.as ├── ShadowFilter.as └── WaveFilter.as └── utils ├── Timer2D.as └── TimerLists.as /.gitignore: -------------------------------------------------------------------------------- 1 | # Build and Release Folders 2 | bin/ 3 | bin-debug/ 4 | bin-release/ 5 | 6 | # Other files and folders 7 | .settings/ 8 | 9 | # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` 10 | # should NOT be excluded as they contain compiler settings and other important 11 | # information for Eclipse / Flash Builder. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | StarlingFeathers 2 | ================ 3 | 4 | #####整合Starling+Feathers 还有一些Starling扩展 5 | #####Starling 1.7.1+ Feathers 2.0.1 6 | 7 | Starling源码的优化 8 | ================ 9 | 10 | 1.关闭Enterframe事件。 11 | ------------------- 12 | (1.3的包 1.4引擎自己已经优化) 13 | starling本身会每一帧遍历所有对象派发enterframe事件。如果对象很多效率自然下降。 14 | 改用starling.events.EnterFrameManager统一管理无需每帧遍历所有对象。 15 | 注册enterframe事件的方式不变。 16 | 2.VertexData优化。 17 | ---------------- 18 | (1.3的包 1.4引擎自己已经优化) 19 | mRawData改为bytearray上传数据速度提升. 20 | 3.为DisplayObjectContainer添加了3个方法 21 | ------------------------------------- 22 | addQuiackChild()快速添加子对象 23 | removeQuickChild()快速移除子对象 24 | clearChild()一键清理子对象 25 | 使用上面3个方法都不会派发ADD_TO_STAGE,REMOVE_FROME_STAGE事件。当平凡添加和移除子对象时效率可大大提升. 26 | 4.使用跳帧策略. 27 | ------------- 28 | 当任务繁忙的时候渲染部分主动丢帧。 29 | 30 | 应用级别优化 31 | ========== 32 | 33 | 1.简化starling创建流程. 34 | --------------------- 35 | 程序主类继承STLStarup 36 | Starling入口类继承STLMainClass 37 | STLStarup主类中调用 38 | initStarlingWithWH->根据宽高初始化starling 39 | 或 40 | initStarling->初始化的starling将会充满屏幕 41 | 进行初一键初始化自动适应屏幕大小。具体效果请运行查看 42 | 43 | 2.封装了一部分手势 44 | --------------- 45 | lzm.starling.gestures包 46 | 47 | 3.添加动态纹理 48 | ------------ 49 | lzm.starling.texture.DynamicTextureAtlas 50 | 可以很好的优化drw数量。底层是renderTexture 51 | 52 | 4.添加一些自定义组建 53 | ----------------- 54 | lzm.starling.display 55 | DistortImage,DistortImageContainer四角拉伸图片可拉升的图片 56 | ImageViewer类似于手机上的图片查看器 57 | ScrollContainer,ScrollContainerItem优化过的feathers滚动面板 58 | BaseScene通用场景 做手游比较试用. 59 | 其他。。。 60 | -------------------------------------------------------------------------------- /StarlingFeathers/.flexLibProperties: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /StarlingFeathers/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | StarlingFeathers 4 | 5 | 6 | 7 | 8 | 9 | com.adobe.flexbuilder.project.flexbuilder 10 | 11 | 12 | 13 | 14 | 15 | com.adobe.flexbuilder.project.aslibnature 16 | com.adobe.flexbuilder.project.actionscriptnature 17 | 18 | 19 | -------------------------------------------------------------------------------- /StarlingFeathers/src/extend/Gauge.as: -------------------------------------------------------------------------------- 1 | package extend 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.display.Image; 6 | import starling.textures.Texture; 7 | 8 | /** 9 | * 进度条 10 | * @author lzm 11 | * 12 | */ 13 | public class Gauge extends Image 14 | { 15 | private var _ratio:Number; 16 | 17 | public function Gauge(texture:Texture) 18 | { 19 | super(texture); 20 | } 21 | 22 | private function update():void 23 | { 24 | scaleX = _ratio; 25 | setTexCoords(1, new Point(_ratio, 0.0)); 26 | setTexCoords(3, new Point(_ratio, 1.0)); 27 | } 28 | 29 | public function get ratio():Number { return _ratio; } 30 | public function set ratio(value:Number):void 31 | { 32 | if(value != _ratio){ 33 | _ratio = Math.max(0.0, Math.min(1.0, value)); 34 | update(); 35 | } 36 | } 37 | } 38 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/extend/HGauge.as: -------------------------------------------------------------------------------- 1 | package extend 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.display.Image; 6 | import starling.textures.Texture; 7 | 8 | public class HGauge extends Image 9 | { 10 | private var _ratio:Number; 11 | 12 | public function HGauge(texture:Texture) 13 | { 14 | super(texture); 15 | } 16 | 17 | private function update():void 18 | { 19 | scaleY = _ratio; 20 | setTexCoords(2, new Point(0.0, _ratio)); 21 | setTexCoords(3, new Point(1.0, _ratio)); 22 | } 23 | 24 | public function get ratio():Number { return _ratio; } 25 | public function set ratio(value:Number):void 26 | { 27 | if(value != _ratio){ 28 | _ratio = Math.max(0.0, Math.min(1.0, value)); 29 | update(); 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/extend/particlesystem/PDParticle.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2012 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package extend.particlesystem 12 | { 13 | public class PDParticle extends Particle 14 | { 15 | public var colorArgb:ColorArgb; 16 | public var colorArgbDelta:ColorArgb; 17 | public var startX:Number, startY:Number; 18 | public var velocityX:Number, velocityY:Number; 19 | public var radialAcceleration:Number; 20 | public var tangentialAcceleration:Number; 21 | public var emitRadius:Number, emitRadiusDelta:Number; 22 | public var emitRotation:Number, emitRotationDelta:Number; 23 | public var rotationDelta:Number; 24 | public var scaleDelta:Number; 25 | 26 | public function PDParticle() 27 | { 28 | colorArgb = new ColorArgb(); 29 | colorArgbDelta = new ColorArgb(); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/extend/particlesystem/Particle.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2011 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package extend.particlesystem 12 | { 13 | public class Particle 14 | { 15 | public var x:Number; 16 | public var y:Number; 17 | public var scale:Number; 18 | public var rotation:Number; 19 | public var color:uint; 20 | public var alpha:Number; 21 | public var currentTime:Number; 22 | public var totalTime:Number; 23 | 24 | public function Particle() 25 | { 26 | x = y = rotation = currentTime = 0.0; 27 | totalTime = alpha = scale = 1.0; 28 | color = 0xffffff; 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/extend/particlesystem/ParticleDesignerPS.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework - Particle System Extension 4 | // Copyright 2012 Gamua OG. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package extend.particlesystem 12 | { 13 | import starling.textures.Texture; 14 | 15 | /** This class is only available for backwards-compatibility. 16 | * This was the old name of the 'PDParticleSystem' class. */ 17 | public class ParticleDesignerPS extends PDParticleSystem 18 | { 19 | private static var sDeprecationNotified:Boolean = false; 20 | 21 | public function ParticleDesignerPS(config:XML, texture:Texture) 22 | { 23 | if (!sDeprecationNotified) 24 | { 25 | sDeprecationNotified = true; 26 | trace("[Starling] The class 'ParticleDesignerPS' is deprecated. " + 27 | "Please use 'PDParticleSystem' instead."); 28 | } 29 | super(config, texture); 30 | } 31 | } 32 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/Check.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls 9 | { 10 | import feathers.skins.IStyleProvider; 11 | 12 | import flash.errors.IllegalOperationError; 13 | 14 | [Exclude(name="isToggle",kind="property")] 15 | 16 | /** 17 | * A toggle control that contains a label and a box that may be checked 18 | * or not to indicate selection. 19 | * 20 | *

In the following example, a check is created and selected, and a 21 | * listener for Event.CHANGE is added:

22 | * 23 | * 24 | * var check:Check = new Check(); 25 | * check.label = "Pick Me!"; 26 | * check.isSelected = true; 27 | * check.addEventListener( Event.CHANGE, check_changeHandler ); 28 | * this.addChild( check ); 29 | * 30 | * @see http://wiki.starling-framework.org/feathers/check 31 | * @see ToggleSwitch 32 | */ 33 | public class Check extends ToggleButton 34 | { 35 | /** 36 | * The default IStyleProvider for all Check 37 | * components. 38 | * 39 | * @default null 40 | * @see feathers.core.FeathersControl#styleProvider 41 | */ 42 | public static var globalStyleProvider:IStyleProvider; 43 | 44 | /** 45 | * Constructor. 46 | */ 47 | public function Check() 48 | { 49 | super(); 50 | super.isToggle = true; 51 | } 52 | 53 | /** 54 | * @private 55 | */ 56 | override protected function get defaultStyleProvider():IStyleProvider 57 | { 58 | return Check.globalStyleProvider; 59 | } 60 | 61 | /** 62 | * @private 63 | */ 64 | override public function set isToggle(value:Boolean):void 65 | { 66 | throw IllegalOperationError("CheckBox isToggle must always be true."); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/IDirectionalScrollBar.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls 9 | { 10 | /** 11 | * A scroll bar that supports both horizontal or vertical orientations. The 12 | * feathers.controls.Scroller class (and all subclasses) will 13 | * automatically set the direction property when an 14 | * IDirectionalScrollBar is returned by its scroll bar 15 | * factories. 16 | */ 17 | public interface IDirectionalScrollBar extends IScrollBar 18 | { 19 | /** 20 | * The direction of the scroll bar, either horizontal or vertical. 21 | * 22 | * @see feathers.controls.SimpleScrollBar#DIRECTION_HORIZONTAL 23 | * @see feathers.controls.SimpleScrollBar#DIRECTION_VERTICAL 24 | */ 25 | function get direction():String; 26 | 27 | /** 28 | * @private 29 | */ 30 | function set direction(value:String):void; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/IScreen.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls 9 | { 10 | import feathers.core.IFeathersControl; 11 | 12 | /** 13 | * A screen for use with ScreenNavigator. 14 | * 15 | * @see ScreenNavigator 16 | * @see ScreenNavigatorItem 17 | */ 18 | public interface IScreen extends IFeathersControl 19 | { 20 | /** 21 | * The identifier for the screen. This value is passed in by the 22 | * ScreenNavigator when the screen is instantiated. 23 | */ 24 | function get screenID():String; 25 | 26 | /** 27 | * @private 28 | */ 29 | function set screenID(value:String):void; 30 | 31 | /** 32 | * The ScreenNavigator that is displaying this screen. 33 | */ 34 | function get owner():ScreenNavigator; 35 | 36 | /** 37 | * @private 38 | */ 39 | function set owner(value:ScreenNavigator):void; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/IScrollBar.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls 9 | { 10 | /** 11 | * Dispatched when the scroll bar's value changes. 12 | * 13 | *

The properties of the event object have the following values:

14 | * 15 | * 16 | * 17 | * 21 | * 22 | * 26 | *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the 18 | * event listener that handles the event. For example, if you use 19 | * myButton.addEventListener() to register an event listener, 20 | * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; 23 | * it is not always the Object listening for the event. Use the 24 | * currentTarget property to always access the Object 25 | * listening for the event.
27 | * 28 | * @eventType starling.events.Event.CHANGE 29 | */ 30 | [Event(name="change",type="starling.events.Event")] 31 | 32 | /** 33 | * Minimum requirements for a scroll bar to be usable with a Scroller 34 | * component. 35 | * 36 | * @see Scroller 37 | */ 38 | public interface IScrollBar extends IRange 39 | { 40 | 41 | /** 42 | * The amount the scroll bar value must change to get from one "page" to 43 | * the next. 44 | * 45 | *

In the following example, the page is changed to 10:

46 | * 47 | * 48 | * scrollBar.minimum = 0; 49 | * scrollBar.maximum = 100; 50 | * scrollBar.step = 1; 51 | * scrollBar.page = 10 52 | * scrollBar.value = 12; 53 | */ 54 | function get page():Number; 55 | 56 | /** 57 | * @private 58 | */ 59 | function set page(value:Number):void; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/renderers/IGroupedListHeaderOrFooterRenderer.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls.renderers 9 | { 10 | import feathers.controls.GroupedList; 11 | import feathers.core.IFeathersControl; 12 | 13 | /** 14 | * Interface to implement a renderer for a grouped list header or footer. 15 | */ 16 | public interface IGroupedListHeaderOrFooterRenderer extends IFeathersControl 17 | { 18 | /** 19 | * Data for a header or footer from the grouped list's data provider. 20 | * The data may change if this renderer is reused for a new header or 21 | * footer because it's no longer needed for the original data. 22 | * 23 | *

This property is set by the list, and should not be set manually.

24 | */ 25 | function get data():Object; 26 | 27 | /** 28 | * @private 29 | */ 30 | function set data(value:Object):void; 31 | 32 | /** 33 | * The index of the group within the data provider of the grouped list. 34 | * 35 | *

This property is set by the list, and should not be set manually.

36 | */ 37 | function get groupIndex():int; 38 | 39 | /** 40 | * @private 41 | */ 42 | function set groupIndex(value:int):void; 43 | 44 | /** 45 | * The index of the item within the layout. 46 | * 47 | *

This property is set by the list, and should not be set manually.

48 | */ 49 | function get layoutIndex():int; 50 | 51 | /** 52 | * @private 53 | */ 54 | function set layoutIndex(value:int):void; 55 | 56 | /** 57 | * The grouped list that contains this header or footer renderer. 58 | * 59 | *

This property is set by the list, and should not be set manually.

60 | */ 61 | function get owner():GroupedList; 62 | 63 | /** 64 | * @private 65 | */ 66 | function set owner(value:GroupedList):void; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/renderers/IGroupedListItemRenderer.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls.renderers 9 | { 10 | import feathers.controls.*; 11 | import feathers.core.IToggle; 12 | 13 | /** 14 | * Interface to implement a renderer for a grouped list item. 15 | */ 16 | public interface IGroupedListItemRenderer extends IToggle 17 | { 18 | /** 19 | * An item from the grouped list's data provider. The data may change if 20 | * this item renderer is reused for a new item because it's no longer 21 | * needed for the original item. 22 | * 23 | *

This property is set by the list, and should not be set manually.

24 | */ 25 | function get data():Object; 26 | 27 | /** 28 | * @private 29 | */ 30 | function set data(value:Object):void; 31 | 32 | /** 33 | * The index of the item's parent group within the data provider of the 34 | * grouped list. 35 | * 36 | *

This property is set by the list, and should not be set manually.

37 | */ 38 | function get groupIndex():int; 39 | 40 | /** 41 | * @private 42 | */ 43 | function set groupIndex(value:int):void; 44 | 45 | /** 46 | * The index of the item within its parent group. 47 | * 48 | *

This property is set by the list, and should not be set manually.

49 | */ 50 | function get itemIndex():int; 51 | 52 | /** 53 | * @private 54 | */ 55 | function set itemIndex(value:int):void; 56 | 57 | /** 58 | * The index of the item within the layout. 59 | * 60 | *

This property is set by the list, and should not be set manually.

61 | */ 62 | function get layoutIndex():int; 63 | 64 | /** 65 | * @private 66 | */ 67 | function set layoutIndex(value:int):void; 68 | 69 | /** 70 | * The grouped list that contains this item renderer. 71 | * 72 | *

This property is set by the list, and should not be set manually.

73 | */ 74 | function get owner():GroupedList; 75 | 76 | /** 77 | * @private 78 | */ 79 | function set owner(value:GroupedList):void; 80 | } 81 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/renderers/IListItemRenderer.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls.renderers 9 | { 10 | import feathers.controls.*; 11 | import feathers.core.IToggle; 12 | 13 | /** 14 | * Interface to implement a renderer for a list item. 15 | */ 16 | public interface IListItemRenderer extends IToggle 17 | { 18 | /** 19 | * An item from the list's data provider. The data may change if this 20 | * item renderer is reused for a new item because it's no longer needed 21 | * for the original item. 22 | * 23 | *

This property is set by the list, and should not be set manually.

24 | */ 25 | function get data():Object; 26 | 27 | /** 28 | * @private 29 | */ 30 | function set data(value:Object):void; 31 | 32 | /** 33 | * The index (numeric position, starting from zero) of the item within 34 | * the list's data provider. Like the data property, this 35 | * value may change if this item renderer is reused by the list for a 36 | * different item. 37 | * 38 | *

This property is set by the list, and should not be set manually.

39 | */ 40 | function get index():int; 41 | 42 | /** 43 | * @private 44 | */ 45 | function set index(value:int):void; 46 | 47 | /** 48 | * The list that contains this item renderer. 49 | * 50 | *

This property is set by the list, and should not be set manually.

51 | */ 52 | function get owner():List; 53 | 54 | /** 55 | * @private 56 | */ 57 | function set owner(value:List):void; 58 | } 59 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/supportClasses/IViewPort.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls.supportClasses 9 | { 10 | import feathers.core.IFeathersControl; 11 | 12 | [ExcludeClass] 13 | public interface IViewPort extends IFeathersControl 14 | { 15 | function get visibleWidth():Number; 16 | function set visibleWidth(value:Number):void; 17 | function get minVisibleWidth():Number; 18 | function set minVisibleWidth(value:Number):void; 19 | function get maxVisibleWidth():Number; 20 | function set maxVisibleWidth(value:Number):void; 21 | function get visibleHeight():Number; 22 | function set visibleHeight(value:Number):void; 23 | function get minVisibleHeight():Number; 24 | function set minVisibleHeight(value:Number):void; 25 | function get maxVisibleHeight():Number; 26 | function set maxVisibleHeight(value:Number):void; 27 | 28 | function get contentX():Number; 29 | function get contentY():Number; 30 | 31 | function get horizontalScrollPosition():Number; 32 | function set horizontalScrollPosition(value:Number):void; 33 | function get verticalScrollPosition():Number; 34 | function set verticalScrollPosition(value:Number):void; 35 | function get horizontalScrollStep():Number; 36 | function get verticalScrollStep():Number; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/controls/text/ITextEditorViewPort.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.controls.text 9 | { 10 | import feathers.controls.supportClasses.IViewPort; 11 | import feathers.core.ITextEditor; 12 | 13 | /** 14 | * Handles the editing of multiline text. 15 | * 16 | * @see feathers.controls.TextArea 17 | * @see http://wiki.starling-framework.org/feathers/text-editors 18 | */ 19 | public interface ITextEditorViewPort extends ITextEditor, IViewPort 20 | { 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IFocusExtras.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | import starling.display.DisplayObject; 11 | 12 | /** 13 | * A container that may have extra children that aren't accessible from the 14 | * standard display list functions like getChildAt(), but those 15 | * "extra" children may still need to receive focus. An example of this 16 | * would be a container with "chrome", such as feathers.controls.Panel. 17 | * 18 | * @see feathers.core.IFocusManager 19 | */ 20 | public interface IFocusExtras 21 | { 22 | /** 23 | * Extra display objects that are not accessible through standard 24 | * display list functions like getChildAt(), but should 25 | * appear before those children in the focus order. Typically, this is 26 | * for containers that have chrome that is hidden from the normal 27 | * display list API. 28 | * 29 | *

May return null if there are no extra children.

30 | */ 31 | function get focusExtrasBefore():Vector.; 32 | 33 | /** 34 | * Extra display objects that are not accessible through standard 35 | * display list functions like getChildAt(), but should 36 | * appear after those children in the focus order. Typically, this is 37 | * for containers that have chrome that is hidden from the normal 38 | * display list API. 39 | * 40 | *

May return null if there are no extra children.

41 | */ 42 | function get focusExtrasAfter():Vector.; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IFocusManager.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | import starling.display.DisplayObjectContainer; 11 | 12 | /** 13 | * Interface for focus management. 14 | * 15 | * @see feathers.core.IFocusDisplayObject 16 | * @see feathers.core.FocusManager 17 | */ 18 | public interface IFocusManager 19 | { 20 | /** 21 | * Determines if this focus manager is enabled. A focus manager may be 22 | * disabled when another focus manager has control, such as when a 23 | * modal pop-up is displayed. 24 | */ 25 | function get isEnabled():Boolean; 26 | 27 | /** 28 | * @private 29 | */ 30 | function set isEnabled(value:Boolean):void; 31 | 32 | /** 33 | * The object that currently has focus. May return null if 34 | * no object has focus. 35 | * 36 | *

In the following example, the focus is changed:

37 | * 38 | * 39 | * focusManager.focus = someObject; 40 | */ 41 | function get focus():IFocusDisplayObject; 42 | 43 | /** 44 | * @private 45 | */ 46 | function set focus(value:IFocusDisplayObject):void; 47 | 48 | /** 49 | * The top-level container of the focus manager. This isn't necessarily 50 | * the root of the display list. 51 | */ 52 | function get root():DisplayObjectContainer; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IGroupedToggle.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | /** 11 | * A toggle associated with a specific group. 12 | * 13 | * @see ToggleGroup 14 | */ 15 | public interface IGroupedToggle extends IToggle 16 | { 17 | /** 18 | * When the toggle is added to a ToggleGroup, the group 19 | * will manage the entire group's selection when one of the toggles in 20 | * the group changes. 21 | * 22 | *

In the following example, a Radio is added to a ToggleGroup:

23 | * 24 | * 25 | * var group:ToggleGroup = new ToggleGroup(); 26 | * group.addEventListener( Event.CHANGE, group_changeHandler ); 27 | * 28 | * var radio:Radio = new Radio(); 29 | * radio.toggleGroup = group; 30 | * this.addChild( radio ); 31 | */ 32 | function get toggleGroup():ToggleGroup; 33 | 34 | /** 35 | * @private 36 | */ 37 | function set toggleGroup(value:ToggleGroup):void; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IMultilineTextEditor.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | /** 11 | * Handles the editing of text, and supports multiline editing. This is not 12 | * a text editor intended for a TextArea component. Instead, 13 | * its a text editor intended for a TextInput component and it 14 | * is expected to provide its own scroll bars. 15 | * 16 | * @see feathers.controls.TextInput 17 | * @see http://wiki.starling-framework.org/feathers/text-editors 18 | */ 19 | public interface IMultilineTextEditor extends ITextEditor 20 | { 21 | /** 22 | * Indicates whether the text editor can display more than one line of 23 | * text. 24 | */ 25 | function get multiline():Boolean; 26 | 27 | /** 28 | * @private 29 | */ 30 | function set multiline(value:Boolean):void; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IPopUpManager.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | import starling.display.DisplayObject; 11 | import starling.display.DisplayObjectContainer; 12 | 13 | /** 14 | * Interface for pop-up management. 15 | * 16 | * @see feathers.core.PopUpManager 17 | */ 18 | public interface IPopUpManager 19 | { 20 | /** 21 | * @copy PopUpManager#overlayFactory 22 | */ 23 | function get overlayFactory():Function; 24 | 25 | /** 26 | * @private 27 | */ 28 | function set overlayFactory(value:Function):void; 29 | 30 | /** 31 | * @copy PopUpManager#root 32 | */ 33 | function get root():DisplayObjectContainer; 34 | 35 | /** 36 | * @private 37 | */ 38 | function set root(value:DisplayObjectContainer):void; 39 | 40 | /** 41 | * @copy PopUpManager#addPopUp() 42 | */ 43 | function addPopUp(popUp:DisplayObject, isModal:Boolean = true, isCentered:Boolean = true, customOverlayFactory:Function = null):DisplayObject; 44 | 45 | /** 46 | * @copy PopUpManager#removePopUp() 47 | */ 48 | function removePopUp(popUp:DisplayObject, dispose:Boolean = false):DisplayObject; 49 | 50 | /** 51 | * @copy PopUpManager#isPopUp() 52 | */ 53 | function isPopUp(popUp:DisplayObject):Boolean; 54 | 55 | /** 56 | * @copy PopUpManager#isTopLevelPopUp() 57 | */ 58 | function isTopLevelPopUp(popUp:DisplayObject):Boolean; 59 | 60 | /** 61 | * @copy PopUpManager#centerPopUp() 62 | */ 63 | function centerPopUp(popUp:DisplayObject):void; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/ITextBaselineControl.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | /** 11 | * A UI control with text that has a baseline. 12 | */ 13 | public interface ITextBaselineControl extends IFeathersControl 14 | { 15 | /** 16 | * Returns the text baseline measurement, in pixels. 17 | */ 18 | function get baseline():Number; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/ITextRenderer.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | import flash.geom.Point; 11 | 12 | /** 13 | * Interface that handles common capabilities of rendering text. 14 | * 15 | * @see http://wiki.starling-framework.org/feathers/text-renderers 16 | */ 17 | public interface ITextRenderer extends IFeathersControl, ITextBaselineControl 18 | { 19 | /** 20 | * The text to render. 21 | */ 22 | function get text():String; 23 | 24 | /** 25 | * @private 26 | */ 27 | function set text(value:String):void; 28 | 29 | /** 30 | * Determines if the text wraps to the next line when it reaches the 31 | * width of the component. 32 | */ 33 | function get wordWrap():Boolean; 34 | 35 | /** 36 | * @private 37 | */ 38 | function set wordWrap(value:Boolean):void; 39 | 40 | /** 41 | * Measures the text's bounds (without a full validation, if 42 | * possible). 43 | */ 44 | function measureText(result:Point = null):Point; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IToggle.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | /** 11 | * Dispatched when the selection changes. 12 | * 13 | *

The properties of the event object have the following values:

14 | * 15 | * 16 | * 17 | * 21 | * 22 | * 26 | *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the 18 | * event listener that handles the event. For example, if you use 19 | * myButton.addEventListener() to register an event listener, 20 | * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; 23 | * it is not always the Object listening for the event. Use the 24 | * currentTarget property to always access the Object 25 | * listening for the event.
27 | * 28 | * @eventType starling.events.Event.CHANGE 29 | */ 30 | [Event(name="change",type="starling.events.Event")] 31 | 32 | /** 33 | * An interface for something that may be selected. 34 | */ 35 | public interface IToggle extends IFeathersControl 36 | { 37 | /** 38 | * Indicates if the IToggle is selected or not. 39 | */ 40 | function get isSelected():Boolean; 41 | 42 | /** 43 | * @private 44 | */ 45 | function set isSelected(value:Boolean):void; 46 | } 47 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/core/IValidating.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.core 9 | { 10 | /** 11 | * A display object that supports validation. Display objects of this type 12 | * will delay updating after property changes until just before Starling 13 | * renders the display list to avoid running redundant code. 14 | */ 15 | public interface IValidating extends IFeathersDisplayObject 16 | { 17 | /** 18 | * The component's depth in the display list, relative to the stage. If 19 | * the component isn't on the stage, its depth will be -1. 20 | * 21 | *

Used by the validation system to validate components from the 22 | * top down

. 23 | */ 24 | function get depth():int; 25 | 26 | /** 27 | * Immediately validates the display object, if it is invalid. The 28 | * validation system exists to postpone updating a display object after 29 | * properties are changed until until the last possible moment the 30 | * display object is rendered. This allows multiple properties to be 31 | * changed at a time without requiring a full update every time. 32 | * 33 | *

A display object cannot validate if it does not have access to the 34 | * stage.

35 | */ 36 | function validate():void; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/data/IHierarchicalCollectionDataDescriptor.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.data 9 | { 10 | /** 11 | * An adapter interface to support any kind of data source in 12 | * hierarchical collections. 13 | * 14 | * @see HierarchicalCollection 15 | */ 16 | public interface IHierarchicalCollectionDataDescriptor 17 | { 18 | /** 19 | * Determines if a node from the data source is a branch. 20 | */ 21 | function isBranch(node:Object):Boolean; 22 | 23 | /** 24 | * The number of items at the specified location in the data source. 25 | * 26 | *

The rest arguments are the indices that make up the location. If 27 | * a location is omitted, the length returned will be for the root level 28 | * of the collection.

29 | */ 30 | function getLength(data:Object, ...rest:Array):int; 31 | 32 | /** 33 | * Returns the item at the specified location in the data source. 34 | * 35 | *

The rest arguments are the indices that make up the location.

36 | */ 37 | function getItemAt(data:Object, index:int, ...rest:Array):Object; 38 | 39 | /** 40 | * Replaces the item at the specified location with a new item. 41 | * 42 | *

The rest arguments are the indices that make up the location.

43 | */ 44 | function setItemAt(data:Object, item:Object, index:int, ...rest:Array):void; 45 | 46 | /** 47 | * Adds an item to the data source, at the specified location. 48 | * 49 | *

The rest arguments are the indices that make up the location.

50 | */ 51 | function addItemAt(data:Object, item:Object, index:int, ...rest:Array):void; 52 | 53 | /** 54 | * Removes the item at the specified location from the data source and 55 | * returns it. 56 | * 57 | *

The rest arguments are the indices that make up the location.

58 | */ 59 | function removeItemAt(data:Object, index:int, ...rest:Array):Object; 60 | 61 | /** 62 | * Determines which location the item appears at within the data source. 63 | * If the item isn't in the data source, returns an empty Vector.<int>. 64 | * 65 | *

The rest arguments are optional indices to narrow 66 | * the search.

67 | */ 68 | function getItemLocation(data:Object, item:Object, result:Vector. = null, ...rest:Array):Vector.; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/data/IListCollectionDataDescriptor.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.data 9 | { 10 | /** 11 | * An adapter interface to support any kind of data source in 12 | * ListCollection. 13 | * 14 | * @see ListCollection 15 | */ 16 | public interface IListCollectionDataDescriptor 17 | { 18 | /** 19 | * The number of items in the data source. 20 | */ 21 | function getLength(data:Object):int; 22 | 23 | /** 24 | * Returns the item at the specified index in the data source. 25 | */ 26 | function getItemAt(data:Object, index:int):Object; 27 | 28 | /** 29 | * Replaces the item at the specified index with a new item. 30 | */ 31 | function setItemAt(data:Object, item:Object, index:int):void; 32 | 33 | /** 34 | * Adds an item to the data source, at the specified index. 35 | */ 36 | function addItemAt(data:Object, item:Object, index:int):void; 37 | 38 | /** 39 | * Removes the item at the specified index from the data source and 40 | * returns it. 41 | */ 42 | function removeItemAt(data:Object, index:int):Object; 43 | 44 | /** 45 | * Determines which index the item appears at within the data source. If 46 | * the item isn't in the data source, returns -1. 47 | */ 48 | function getItemIndex(data:Object, item:Object):int; 49 | 50 | /** 51 | * Removes all items from the data source. 52 | */ 53 | function removeAll(data:Object):void; 54 | } 55 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/dragDrop/DragData.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.dragDrop 9 | { 10 | /** 11 | * Stores data associated with a drag and drop operation. 12 | * 13 | * @see DragDropManager 14 | */ 15 | public class DragData 16 | { 17 | /** 18 | * Constructor. 19 | */ 20 | public function DragData() 21 | { 22 | } 23 | 24 | /** 25 | * @private 26 | */ 27 | protected var _data:Object = {}; 28 | 29 | /** 30 | * Determines if the specified data format is available. 31 | */ 32 | public function hasDataForFormat(format:String):Boolean 33 | { 34 | return this._data.hasOwnProperty(format); 35 | } 36 | 37 | /** 38 | * Returns data for the specified format. 39 | */ 40 | public function getDataForFormat(format:String):* 41 | { 42 | if(this._data.hasOwnProperty(format)) 43 | { 44 | return this._data[format]; 45 | } 46 | return undefined; 47 | } 48 | 49 | /** 50 | * Saves data for the specified format. 51 | */ 52 | public function setDataForFormat(format:String, data:*):void 53 | { 54 | this._data[format] = data; 55 | } 56 | 57 | /** 58 | * Removes all data for the specified format. 59 | */ 60 | public function clearDataForFormat(format:String):* 61 | { 62 | var data:* = undefined; 63 | if(this._data.hasOwnProperty(format)) 64 | { 65 | data = this._data[format]; 66 | } 67 | delete this._data[format]; 68 | return data; 69 | 70 | } 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/events/CollectionEventType.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.events 9 | { 10 | /** 11 | * Event type constants for collections. This class is 12 | * not a subclass of starling.events.Event because these 13 | * constants are meant to be used with dispatchEventWith() and 14 | * take advantage of the Starling's event object pooling. The object passed 15 | * to an event listener will be of type starling.events.Event. 16 | */ 17 | public class CollectionEventType 18 | { 19 | /** 20 | * Dispatched when the data provider's source is completely replaced. 21 | */ 22 | public static const RESET:String = "reset"; 23 | 24 | /** 25 | * Dispatched when an item is added to the collection. 26 | */ 27 | public static const ADD_ITEM:String = "addItem"; 28 | 29 | /** 30 | * Dispatched when an item is removed from the collection. 31 | */ 32 | public static const REMOVE_ITEM:String = "removeItem"; 33 | 34 | /** 35 | * Dispatched when an item is replaced in the collection with a 36 | * different item. 37 | */ 38 | public static const REPLACE_ITEM:String = "replaceItem"; 39 | 40 | /** 41 | * Dispatched when an item in the collection has changed. 42 | */ 43 | public static const UPDATE_ITEM:String = "updateItem"; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/layout/ILayoutData.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.layout 9 | { 10 | import feathers.core.IFeathersEventDispatcher; 11 | 12 | /** 13 | * Dispatched when a property of the layout data changes. 14 | * 15 | *

The properties of the event object have the following values:

16 | * 17 | * 18 | * 19 | * 23 | * 24 | * 28 | *
PropertyValue
bubblesfalse
currentTargetThe Object that defines the 20 | * event listener that handles the event. For example, if you use 21 | * myButton.addEventListener() to register an event listener, 22 | * myButton is the value of the currentTarget.
datanull
targetThe Object that dispatched the event; 25 | * it is not always the Object listening for the event. Use the 26 | * currentTarget property to always access the Object 27 | * listening for the event.
29 | */ 30 | [Event(name="change",type="starling.events.Event")] 31 | 32 | /** 33 | * Extra data used by layout algorithms. 34 | */ 35 | public interface ILayoutData extends IFeathersEventDispatcher 36 | { 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/layout/ILayoutDisplayObject.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.layout 9 | { 10 | import feathers.core.IFeathersDisplayObject; 11 | 12 | /** 13 | * Dispatched when a property of the display object's layout data changes. 14 | * 15 | * @eventType feathers.events.FeathersEventType.LAYOUT_DATA_CHANGE 16 | */ 17 | [Event(name="layoutDataChange",type="starling.events.Event")] 18 | 19 | /** 20 | * A display object that may be associated with extra data for use with 21 | * advanced layouts. 22 | */ 23 | public interface ILayoutDisplayObject extends IFeathersDisplayObject 24 | { 25 | /** 26 | * Extra parameters associated with this display object that will be 27 | * used by the layout algorithm. 28 | */ 29 | function get layoutData():ILayoutData; 30 | 31 | /** 32 | * @private 33 | */ 34 | function set layoutData(value:ILayoutData):void; 35 | 36 | /** 37 | * Determines if the ILayout should use this object or ignore it. 38 | * 39 | *

In the following example, the display object is excluded from 40 | * the layout:

41 | * 42 | * 43 | * object.includeInLayout = false; 44 | */ 45 | function get includeInLayout():Boolean; 46 | 47 | /** 48 | * @private 49 | */ 50 | function set includeInLayout(value:Boolean):void; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/layout/ITrimmedVirtualLayout.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.layout 9 | { 10 | /** 11 | * Optimizes a virtual layout by skipping a specific number of items before 12 | * and after the set that is passed to layout(). 13 | */ 14 | public interface ITrimmedVirtualLayout extends IVirtualLayout 15 | { 16 | /** 17 | * Used internally by a component, such as List, to set the 18 | * number of virtualized items that appear before the items passed to 19 | * layout(). Allows the array of items to be smaller than 20 | * the full size. Does not work if the layout has variable item 21 | * dimensions. 22 | * 23 | *

This property is meant to be set by the List or other 24 | * component that uses the virtual layout. If you're simply creating 25 | * a layout for a List or another component, do not use 26 | * this property. It is meant for developers creating custom components 27 | * only.

28 | */ 29 | function get beforeVirtualizedItemCount():int; 30 | 31 | /** 32 | * @private 33 | */ 34 | function set beforeVirtualizedItemCount(value:int):void; 35 | 36 | /** 37 | * Used internally by a component, such as List, to set the 38 | * number of virtualized items that appear after the items passed to 39 | * layout(). Allows the array of items to be smaller than 40 | * the full size. Does not work if the layout has variable item 41 | * dimensions. 42 | * 43 | *

This property is meant to be set by the List or other 44 | * component that uses the virtual layout. If you're simply creating 45 | * a layout for a List or another component, do not use 46 | * this property. It is meant for developers creating custom components 47 | * only.

48 | */ 49 | function get afterVirtualizedItemCount():int; 50 | 51 | /** 52 | * @private 53 | */ 54 | function set afterVirtualizedItemCount(value:int):void; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/layout/IVariableVirtualLayout.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.layout 9 | { 10 | import starling.display.DisplayObject; 11 | 12 | /** 13 | * A virtual layout that supports variable item dimensions. 14 | */ 15 | public interface IVariableVirtualLayout extends IVirtualLayout 16 | { 17 | /** 18 | * When the layout is virtualized, and this value is true, the items may 19 | * have variable dimensions. If false, the items will all share the 20 | * same dimensions as the typical item. Performance is better for 21 | * layouts where all items have the same dimensions. 22 | */ 23 | function get hasVariableItemDimensions():Boolean; 24 | 25 | /** 26 | * @private 27 | */ 28 | function set hasVariableItemDimensions(value:Boolean):void; 29 | 30 | /** 31 | * Clears the cached dimensions for all virtualized indices. 32 | */ 33 | function resetVariableVirtualCache():void; 34 | 35 | /** 36 | * Clears the cached dimensions for one specific virtualized index. 37 | */ 38 | function resetVariableVirtualCacheAtIndex(index:int, item:DisplayObject = null):void; 39 | 40 | /** 41 | * Inserts an item in to the cache at the specified index, pushing the 42 | * old cached value at that index, and all following values, up one 43 | * index. 44 | */ 45 | function addToVariableVirtualCacheAtIndex(index:int, item:DisplayObject = null):void; 46 | 47 | /** 48 | * Removes an item in to the cache at the specified index, moving the 49 | * values at following indexes down by one. 50 | */ 51 | function removeFromVariableVirtualCacheAtIndex(index:int):void; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/layout/LayoutBoundsResult.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.layout 9 | { 10 | /** 11 | * Calculated bounds for layout. 12 | */ 13 | public class LayoutBoundsResult 14 | { 15 | /** 16 | * Constructor. 17 | */ 18 | public function LayoutBoundsResult() 19 | { 20 | 21 | } 22 | 23 | /** 24 | * The starting position of the view port's content on the x axis. 25 | * Usually, this value is 0, but it may be negative. 26 | * negative. 27 | */ 28 | public var contentX:Number = 0; 29 | 30 | /** 31 | * The starting position of the view port's content on the y axis. 32 | * Usually, this value is 0, but it may be negative. 33 | */ 34 | public var contentY:Number = 0; 35 | 36 | /** 37 | * The visible width of the view port. The view port's content may be 38 | * clipped. 39 | */ 40 | public var viewPortWidth:Number; 41 | 42 | /** 43 | * The visible height of the view port. The view port's content may be 44 | * clipped. 45 | */ 46 | public var viewPortHeight:Number; 47 | 48 | /** 49 | * The width of the content. May be larger or smaller than the view 50 | * port. 51 | */ 52 | public var contentWidth:Number; 53 | 54 | /** 55 | * The height of the content. May be larger or smaller than the view 56 | * port. 57 | */ 58 | public var contentHeight:Number; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/layout/ViewPortBounds.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.layout 9 | { 10 | /** 11 | * Used by layout algorithms for determining the bounds in which to position 12 | * and size items. 13 | */ 14 | public class ViewPortBounds 15 | { 16 | /** 17 | * Constructor. 18 | */ 19 | public function ViewPortBounds() 20 | { 21 | 22 | } 23 | 24 | /** 25 | * The x position of the view port, in pixels. 26 | */ 27 | public var x:Number = 0; 28 | 29 | /** 30 | * The y position of the view port, in pixels. 31 | */ 32 | public var y:Number = 0; 33 | 34 | /** 35 | * The horizontal scroll position of the view port, in pixels. 36 | */ 37 | public var scrollX:Number = 0; 38 | 39 | /** 40 | * The vertical scroll position of the view port, in pixels. 41 | */ 42 | public var scrollY:Number = 0; 43 | 44 | /** 45 | * The explicit width of the view port, in pixels. If NaN, 46 | * there is no explicit width value. 47 | */ 48 | public var explicitWidth:Number = NaN; 49 | 50 | /** 51 | * The explicit height of the view port, in pixels. If NaN, 52 | * there is no explicit height value. 53 | */ 54 | public var explicitHeight:Number = NaN; 55 | 56 | /** 57 | * The minimum width of the view port, in pixels. Should be 0 or 58 | * a positive number less than infinity. 59 | */ 60 | public var minWidth:Number = 0; 61 | 62 | /** 63 | * The minimum width of the view port, in pixels. Should be 0 or 64 | * a positive number less than infinity. 65 | */ 66 | public var minHeight:Number = 0; 67 | 68 | /** 69 | * The maximum width of the view port, in pixels. Should be 0 or 70 | * a positive number, including infinity. 71 | */ 72 | public var maxWidth:Number = Number.POSITIVE_INFINITY; 73 | 74 | /** 75 | * The maximum height of the view port, in pixels. Should be 0 or 76 | * a positive number, including infinity. 77 | */ 78 | public var maxHeight:Number = Number.POSITIVE_INFINITY; 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/skins/FunctionStyleProvider.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.skins 9 | { 10 | import feathers.core.IFeathersControl; 11 | 12 | /** 13 | * Sets styles on a Feathers UI component by passing the component to a 14 | * function when the style provider's applyStyles() is called. 15 | * 16 | *

In the following example, a FunctionStyleProvider is 17 | * created:

18 | * 19 | * var button:Button = new Button(); 20 | * button.label = "Click Me"; 21 | * button.styleProvider = new FunctionStyleProvider( function( target:Button ):void 22 | * { 23 | * target.defaultSkin = new Image( texture ); 24 | * // set other styles... 25 | * }); 26 | * this.addChild( button ); 27 | */ 28 | public class FunctionStyleProvider implements IStyleProvider 29 | { 30 | /** 31 | * Constructor. 32 | */ 33 | public function FunctionStyleProvider(skinFunction:Function) 34 | { 35 | this._styleFunction = skinFunction; 36 | } 37 | 38 | /** 39 | * @private 40 | */ 41 | protected var _styleFunction:Function; 42 | 43 | /** 44 | * The target Feathers UI component is passed to this function when 45 | * applyStyles() is called. 46 | * 47 | *

The function is expected to have the following signature:

48 | *
function( item:IFeathersControl ):void
49 | */ 50 | public function get styleFunction():Function 51 | { 52 | return this._styleFunction; 53 | } 54 | 55 | /** 56 | * @private 57 | */ 58 | public function set styleFunction(value:Function):void 59 | { 60 | this._styleFunction = value; 61 | } 62 | 63 | /** 64 | * @inheritDoc 65 | */ 66 | public function applyStyles(target:IFeathersControl):void 67 | { 68 | if(this._styleFunction == null) 69 | { 70 | return; 71 | } 72 | this._styleFunction(target); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/skins/IStyleProvider.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.skins 9 | { 10 | import feathers.core.IFeathersControl; 11 | 12 | /** 13 | * Sets skin and style properties on a Feathers UI component. 14 | */ 15 | public interface IStyleProvider 16 | { 17 | /** 18 | * Applies styles to a specific Feathers UI component, unless that 19 | * component has been excluded. 20 | * 21 | * @see #exclude() 22 | */ 23 | function applyStyles(target:IFeathersControl):void; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/skins/ImageStateValueSelector.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.skins 9 | { 10 | import starling.display.Image; 11 | import starling.textures.Texture; 12 | 13 | /** 14 | * Values for each state are Texture instances, and the manager attempts to 15 | * reuse the existing Image instance that is passed in to getValueForState() 16 | * as the old value by swapping the texture. 17 | */ 18 | public class ImageStateValueSelector extends StateWithToggleValueSelector 19 | { 20 | /** 21 | * Constructor. 22 | */ 23 | public function ImageStateValueSelector() 24 | { 25 | } 26 | 27 | /** 28 | * @private 29 | */ 30 | protected var _imageProperties:Object; 31 | 32 | /** 33 | * Optional properties to set on the Image instance. 34 | * 35 | * @see http://doc.starling-framework.org/core/starling/display/Image.html starling.display.Image 36 | */ 37 | public function get imageProperties():Object 38 | { 39 | if(!this._imageProperties) 40 | { 41 | this._imageProperties = {}; 42 | } 43 | return this._imageProperties; 44 | } 45 | 46 | /** 47 | * @private 48 | */ 49 | public function set imageProperties(value:Object):void 50 | { 51 | this._imageProperties = value; 52 | } 53 | 54 | /** 55 | * @private 56 | */ 57 | override public function setValueForState(value:Object, state:Object, isSelected:Boolean = false):void 58 | { 59 | if(!(value is Texture)) 60 | { 61 | throw new ArgumentError("Value for state must be a Texture instance."); 62 | } 63 | super.setValueForState(value, state, isSelected); 64 | } 65 | 66 | /** 67 | * @private 68 | */ 69 | override public function updateValue(target:Object, state:Object, oldValue:Object = null):Object 70 | { 71 | var texture:Texture = super.updateValue(target, state) as Texture; 72 | if(!texture) 73 | { 74 | return null; 75 | } 76 | 77 | if(oldValue is Image) 78 | { 79 | var image:Image = Image(oldValue); 80 | image.texture = texture; 81 | image.readjustSize(); 82 | } 83 | else 84 | { 85 | image = new Image(texture); 86 | } 87 | 88 | for(var propertyName:String in this._imageProperties) 89 | { 90 | var propertyValue:Object = this._imageProperties[propertyName]; 91 | image[propertyName] = propertyValue; 92 | } 93 | 94 | return image; 95 | } 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/skins/StandardIcons.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.skins 9 | { 10 | import starling.textures.Texture; 11 | 12 | /** 13 | * A set of icon textures, expected to be populated by the current theme. If 14 | * the standard icons are not populated by a theme, the icons will be 15 | * null. 16 | */ 17 | public class StandardIcons 18 | { 19 | /** 20 | * An arrow pointing to the right that appears as an accessory in a list 21 | * item renderer to indicate that selecting the item will drill down to 22 | * the next level of data (most likely in another list). 23 | */ 24 | public static var listDrillDownAccessoryTexture:Texture; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/skins/StateValueSelector.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.skins 9 | { 10 | import flash.utils.Dictionary; 11 | 12 | /** 13 | * Maps a component's states to values, perhaps for one of the component's 14 | * properties such as a skin or text format. 15 | */ 16 | public class StateValueSelector 17 | { 18 | /** 19 | * Constructor. 20 | */ 21 | public function StateValueSelector() 22 | { 23 | } 24 | 25 | /** 26 | * @private 27 | * Stores the values for each state. 28 | */ 29 | protected var stateToValue:Dictionary = new Dictionary(true); 30 | 31 | /** 32 | * If there is no value for the specified state, a default value can 33 | * be used as a fallback. 34 | */ 35 | public var defaultValue:Object; 36 | 37 | /** 38 | * Stores a value for a specified state to be returned from 39 | * getValueForState(). 40 | */ 41 | public function setValueForState(value:Object, state:Object):void 42 | { 43 | this.stateToValue[state] = value; 44 | } 45 | 46 | /** 47 | * Clears the value stored for a specific state. 48 | */ 49 | public function clearValueForState(state:Object):Object 50 | { 51 | var value:Object = this.stateToValue[state]; 52 | delete this.stateToValue[state]; 53 | return value; 54 | } 55 | 56 | /** 57 | * Returns the value stored for a specific state. 58 | */ 59 | public function getValueForState(state:Object):Object 60 | { 61 | return this.stateToValue[state]; 62 | } 63 | 64 | /** 65 | * Returns the value stored for a specific state. May generate a value, 66 | * if none is present. 67 | * 68 | * @param target The object receiving the stored value. The manager may query properties on the target to customize the returned value. 69 | * @param state The current state. 70 | * @param oldValue The previous value. May be reused for the new value. 71 | */ 72 | public function updateValue(target:Object, state:Object, oldValue:Object = null):Object 73 | { 74 | var value:Object = this.stateToValue[state]; 75 | if(!value) 76 | { 77 | value = this.defaultValue; 78 | } 79 | return value; 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/text/BitmapFontTextFormat.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.text 9 | { 10 | import flash.text.TextFormatAlign; 11 | 12 | import starling.text.BitmapFont; 13 | import starling.text.TextField; 14 | 15 | /** 16 | * Customizes a bitmap font for use by a BitmapFontTextRenderer. 17 | * 18 | * @see feathers.controls.text.BitmapFontTextRenderer 19 | */ 20 | public class BitmapFontTextFormat 21 | { 22 | /** 23 | * Constructor. 24 | */ 25 | public function BitmapFontTextFormat(font:Object, size:Number = NaN, color:uint = 0xffffff, align:String = TextFormatAlign.LEFT) 26 | { 27 | if(font is String) 28 | { 29 | font = TextField.getBitmapFont(font as String); 30 | } 31 | if(!(font is BitmapFont)) 32 | { 33 | throw new ArgumentError("BitmapFontTextFormat font must be a BitmapFont instance or a String representing the name of a registered bitmap font."); 34 | } 35 | this.font = BitmapFont(font); 36 | this.size = size; 37 | this.color = color; 38 | this.align = align; 39 | } 40 | 41 | /** 42 | * The name of the font. 43 | */ 44 | public function get fontName():String 45 | { 46 | return this.font ? this.font.name : null; 47 | } 48 | 49 | /** 50 | * The BitmapFont instance to use. 51 | */ 52 | public var font:BitmapFont; 53 | 54 | /** 55 | * The multiply color. 56 | * 57 | * @default 0xffffff 58 | */ 59 | public var color:uint; 60 | 61 | /** 62 | * The size at which to display the bitmap font. Set to NaN 63 | * to use the default size in the BitmapFont instance. 64 | * 65 | * @default NaN 66 | */ 67 | public var size:Number; 68 | 69 | /** 70 | * The number of extra pixels between characters. May be positive or 71 | * negative. 72 | * 73 | * @default 0 74 | */ 75 | public var letterSpacing:Number = 0; 76 | 77 | [Inspectable(type="String",enumeration="left,center,right")] 78 | /** 79 | * Determines the alignment of the text, either left, center, or right. 80 | * 81 | * @default flash.text.TextFormatAlign.LEFT 82 | */ 83 | public var align:String = TextFormatAlign.LEFT; 84 | 85 | /** 86 | * Determines if the kerning values defined in the BitmapFont instance 87 | * will be used for layout. 88 | * 89 | * @default true 90 | */ 91 | public var isKerningEnabled:Boolean = true; 92 | } 93 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/themes/StyleNameFunctionTheme.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.themes 9 | { 10 | import feathers.skins.StyleNameFunctionStyleProvider; 11 | import feathers.skins.StyleProviderRegistry; 12 | 13 | import starling.events.EventDispatcher; 14 | 15 | /** 16 | * Base class for themes that pass a StyleNameFunctionStyleProvider 17 | * to each component class. 18 | * 19 | * @see feathers.skins.StyleNameFunctionStyleProvider 20 | */ 21 | public class StyleNameFunctionTheme extends EventDispatcher 22 | { 23 | /** 24 | * Constructor. 25 | */ 26 | public function StyleNameFunctionTheme() 27 | { 28 | this._registry = new StyleProviderRegistry(); 29 | } 30 | 31 | /** 32 | * @private 33 | */ 34 | protected var _registry:StyleProviderRegistry; 35 | 36 | /** 37 | * Disposes the theme. 38 | */ 39 | public function dispose():void 40 | { 41 | if(this._registry) 42 | { 43 | this._registry.dispose(); 44 | this._registry = null; 45 | } 46 | } 47 | 48 | /** 49 | * Returns a StyleNameFunctionStyleProvider to be passed to 50 | * the specified class. 51 | */ 52 | protected function getStyleProviderForClass(type:Class):StyleNameFunctionStyleProvider 53 | { 54 | return StyleNameFunctionStyleProvider(this._registry.getStyleProvider(type)); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/display/calculateScaleRatioToFill.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.display 9 | { 10 | /** 11 | * Calculates a scale value to maintain aspect ratio and fill the required 12 | * bounds (with the possibility of cutting of the edges a bit). 13 | */ 14 | public function calculateScaleRatioToFill(originalWidth:Number, originalHeight:Number, targetWidth:Number, targetHeight:Number):Number 15 | { 16 | var widthRatio:Number = targetWidth / originalWidth; 17 | var heightRatio:Number = targetHeight / originalHeight; 18 | if(widthRatio > heightRatio) 19 | { 20 | return widthRatio; 21 | } 22 | return heightRatio; 23 | } 24 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/display/calculateScaleRatioToFit.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.display 9 | { 10 | /** 11 | * Calculates a scale value to maintain aspect ratio and fit inside the 12 | * required bounds (with the possibility of a bit of empty space on the 13 | * edges). 14 | */ 15 | public function calculateScaleRatioToFit(originalWidth:Number, originalHeight:Number, targetWidth:Number, targetHeight:Number):Number 16 | { 17 | var widthRatio:Number = targetWidth / originalWidth; 18 | var heightRatio:Number = targetHeight / originalHeight; 19 | if(widthRatio < heightRatio) 20 | { 21 | return widthRatio; 22 | } 23 | return heightRatio; 24 | } 25 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/display/getDisplayObjectDepthFromStage.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.display 9 | { 10 | import starling.display.DisplayObject; 11 | 12 | /** 13 | * Calculates how many levels deep the target object is on the display list, 14 | * starting from the Starling stage. If the target object is the stage, the 15 | * depth will be 0. A direct child of the stage will have a 16 | * depth of 1, and it increases with each new level. If the 17 | * object does not have a reference to the stage, the depth will always be 18 | * -1, even if the object has a parent. 19 | */ 20 | public function getDisplayObjectDepthFromStage(target:DisplayObject):int 21 | { 22 | if(!target.stage) 23 | { 24 | return -1; 25 | } 26 | var count:int = 0; 27 | while(target.parent) 28 | { 29 | target = target.parent; 30 | count++; 31 | } 32 | return count; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/geom/matrixToRotation.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.geom 9 | { 10 | import flash.geom.Matrix; 11 | 12 | /** 13 | * Extracts the rotation value (in radians) from a flash.geom.Matrix 14 | * 15 | * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix.html flash.geom.Matrix 16 | */ 17 | public function matrixToRotation(matrix:Matrix):Number 18 | { 19 | var c:Number = matrix.c; 20 | var d:Number = matrix.d; 21 | return -Math.atan(c / d); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/geom/matrixToScaleX.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.geom 9 | { 10 | import flash.geom.Matrix; 11 | 12 | /** 13 | * Extracts the x scale value from a flash.geom.Matrix 14 | * 15 | * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix.html flash.geom.Matrix 16 | */ 17 | public function matrixToScaleX(matrix:Matrix):Number 18 | { 19 | var a:Number = matrix.a; 20 | var b:Number = matrix.b; 21 | return Math.sqrt(a * a + b * b); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/geom/matrixToScaleY.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.geom 9 | { 10 | import flash.geom.Matrix; 11 | 12 | /** 13 | * Extracts the y scale value from a flash.geom.Matrix 14 | * 15 | * @see http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix.html flash.geom.Matrix 16 | */ 17 | public function matrixToScaleY(matrix:Matrix):Number 18 | { 19 | var c:Number = matrix.c; 20 | var d:Number = matrix.d; 21 | return Math.sqrt(c * c + d * d); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/math/clamp.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.math 9 | { 10 | 11 | /** 12 | * Forces a numeric value into a specified range. 13 | * 14 | * @param value The value to force into the range. 15 | * @param minimum The minimum bound of the range. 16 | * @param maximum The maximum bound of the range. 17 | * @return A value within the specified range. 18 | * 19 | * @author Josh Tynjala (joshblog.net) 20 | */ 21 | public function clamp(value:Number, minimum:Number, maximum:Number):Number 22 | { 23 | if(minimum > maximum) 24 | { 25 | throw new ArgumentError("minimum should be smaller than maximum."); 26 | } 27 | if(value < minimum) 28 | { 29 | value = minimum; 30 | } 31 | else if(value > maximum) 32 | { 33 | value = maximum; 34 | } 35 | return value; 36 | } 37 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/math/roundDownToNearest.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.math 9 | { 10 | /** 11 | * Rounds a Number down to the nearest multiple of an input. For example, by rounding 12 | * 16 down to the nearest 10, you will receive 10. Similar to the built-in function Math.floor(). 13 | * 14 | * @param numberToRound the number to round down 15 | * @param nearest the number whose mutiple must be found 16 | * @return the rounded number 17 | * 18 | * @see Math#floor 19 | */ 20 | public function roundDownToNearest(number:Number, nearest:Number = 1):Number 21 | { 22 | if(nearest == 0) 23 | { 24 | return number; 25 | } 26 | return Math.floor(roundToPrecision(number / nearest, 10)) * nearest; 27 | } 28 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/math/roundToNearest.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.math 9 | { 10 | /** 11 | * Rounds a Number to the nearest multiple of an input. For example, by rounding 12 | * 16 to the nearest 10, you will receive 20. Similar to the built-in function Math.round(). 13 | * 14 | * @param numberToRound the number to round 15 | * @param nearest the number whose mutiple must be found 16 | * @return the rounded number 17 | * 18 | * @see Math#round 19 | */ 20 | public function roundToNearest(number:Number, nearest:Number = 1):Number 21 | { 22 | if(nearest == 0) 23 | { 24 | return number; 25 | } 26 | var roundedNumber:Number = Math.round(roundToPrecision(number / nearest, 10)) * nearest; 27 | return roundToPrecision(roundedNumber, 10); 28 | } 29 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/math/roundToPrecision.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.math 9 | { 10 | /** 11 | * Rounds a number to a certain level of precision. Useful for limiting the number of 12 | * decimal places on a fractional number. 13 | * 14 | * @param number the input number to round. 15 | * @param precision the number of decimal digits to keep 16 | * @return the rounded number, or the original input if no rounding is needed 17 | * 18 | * @see Math#round 19 | */ 20 | public function roundToPrecision(number:Number, precision:int = 0):Number 21 | { 22 | var decimalPlaces:Number = Math.pow(10, precision); 23 | return Math.round(decimalPlaces * number) / decimalPlaces; 24 | } 25 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/math/roundUpToNearest.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.math 9 | { 10 | /** 11 | * Rounds a Number up to the nearest multiple of an input. For example, by rounding 12 | * 16 up to the nearest 10, you will receive 20. Similar to the built-in function Math.ceil(). 13 | * 14 | * @param numberToRound the number to round up 15 | * @param nearest the number whose mutiple must be found 16 | * @return the rounded number 17 | * 18 | * @see Math#ceil 19 | */ 20 | public function roundUpToNearest(number:Number, nearest:Number = 1):Number 21 | { 22 | if(nearest == 0) 23 | { 24 | return number; 25 | } 26 | return Math.ceil(roundToPrecision(number / nearest, 10)) * nearest; 27 | } 28 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/feathers/utils/text/TextInputNavigation.as: -------------------------------------------------------------------------------- 1 | /* 2 | Feathers 3 | Copyright 2012-2014 Joshua Tynjala. All Rights Reserved. 4 | 5 | This program is free software. You can redistribute and/or modify it in 6 | accordance with the terms of the accompanying license agreement. 7 | */ 8 | package feathers.utils.text 9 | { 10 | /** 11 | * Functions for navigating text inputs with the keyboard. 12 | */ 13 | public class TextInputNavigation 14 | { 15 | /** 16 | * @private 17 | */ 18 | protected static const IS_WORD:RegExp = /\w/; 19 | 20 | /** 21 | * @private 22 | */ 23 | protected static const IS_WHITESPACE:RegExp = /\s/; 24 | 25 | /** 26 | * Finds the start index of the word that starts before the selection. 27 | */ 28 | public static function findPreviousWordStartIndex(text:String, selectionStartIndex:int):int 29 | { 30 | if(selectionStartIndex <= 0) 31 | { 32 | return 0; 33 | } 34 | var nextCharIsWord:Boolean = IS_WORD.test(text.charAt(selectionStartIndex - 1)); 35 | for(var i:int = selectionStartIndex - 2; i >= 0; i--) 36 | { 37 | var charIsWord:Boolean = IS_WORD.test(text.charAt(i)); 38 | if(!charIsWord && nextCharIsWord) 39 | { 40 | return i + 1; 41 | } 42 | nextCharIsWord = charIsWord; 43 | } 44 | return 0; 45 | } 46 | 47 | /** 48 | * Finds the start index of the next word that starts after the 49 | * selection. 50 | */ 51 | public static function findNextWordStartIndex(text:String, selectionEndIndex:int):int 52 | { 53 | var textLength:int = text.length; 54 | if(selectionEndIndex >= textLength - 1) 55 | { 56 | return textLength; 57 | } 58 | //the first character is a special case. any non-whitespace is 59 | //considered part of the word. 60 | var prevCharIsWord:Boolean = !IS_WHITESPACE.test(text.charAt(selectionEndIndex)); 61 | for(var i:int = selectionEndIndex + 1; i < textLength; i++) 62 | { 63 | var charIsWord:Boolean = IS_WORD.test(text.charAt(i)); 64 | if(charIsWord && !prevCharIsWord) 65 | { 66 | return i; 67 | } 68 | prevCharIsWord = charIsWord; 69 | } 70 | return textLength; 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/data/BaseData.as: -------------------------------------------------------------------------------- 1 | package lzm.data 2 | { 3 | 4 | 5 | public dynamic class BaseData 6 | { 7 | public function BaseData() 8 | { 9 | 10 | } 11 | 12 | public function parse(data:Object):void{ 13 | for(var k:String in data){ 14 | if(this.hasOwnProperty(k)){ 15 | this[k] = data[k]; 16 | } 17 | } 18 | } 19 | 20 | public function parseFieldValues(fields:Array,values:Array):void{ 21 | var len:int = fields.length; 22 | var filed:String; 23 | for (var i:int = 0; i < len; i++) { 24 | filed = fields[i]; 25 | if(this.hasOwnProperty(filed)){ 26 | this[filed] = values[i]; 27 | } 28 | } 29 | } 30 | 31 | } 32 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/STLConstant.as: -------------------------------------------------------------------------------- 1 | package lzm.starling 2 | { 3 | import flash.display.Stage; 4 | 5 | public class STLConstant 6 | { 7 | public static var nativeStage:Stage; 8 | 9 | public static var currnetAppRoot:STLRootClass;//当前的根容器 10 | 11 | public static var StageWidth:int = 480;//舞台宽 12 | public static var StageHeight:int = 320;//舞台高 13 | 14 | public static var scale:int = 1;//比例 15 | public static var useMipMaps:Boolean = false; 16 | } 17 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/STLMainClass.as: -------------------------------------------------------------------------------- 1 | package lzm.starling 2 | { 3 | import starling.display.Sprite; 4 | 5 | public class STLMainClass extends Sprite 6 | { 7 | public function STLMainClass() 8 | { 9 | 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/STLRootClass.as: -------------------------------------------------------------------------------- 1 | package lzm.starling 2 | { 3 | import starling.display.Sprite; 4 | 5 | public class STLRootClass extends Sprite 6 | { 7 | private var _root:Sprite; 8 | 9 | public function STLRootClass() 10 | { 11 | 12 | } 13 | 14 | public function start(clazz:Class):void{ 15 | _root = new clazz(); 16 | addChild(_root); 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/display/BaseSceneLoading.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.display 2 | { 3 | import starling.core.Starling; 4 | import starling.display.Sprite; 5 | 6 | import swallow.filters.MosaicFilter; 7 | 8 | public class BaseSceneLoading extends Sprite 9 | { 10 | /** 11 | * 将要被替换掉的场景 12 | */ 13 | protected var _replaceScene:BaseScene; 14 | 15 | /** 16 | * 将要被显示的场景 17 | */ 18 | protected var _targetScene:BaseScene; 19 | 20 | public function BaseSceneLoading() 21 | { 22 | 23 | } 24 | 25 | public function show(callBack:Function):void{ 26 | var filter:MosaicFilter = new MosaicFilter(0.1,0.1); 27 | _replaceScene.filter = filter; 28 | Starling.juggler.tween(filter,0.3,{thresholdX:12,thresholdY:12,onComplete:function():void{ 29 | _replaceScene.filter = null; 30 | filter.dispose(); 31 | callBack(); 32 | }}); 33 | } 34 | 35 | public function hide(callBack:Function):void{ 36 | var filter:MosaicFilter = new MosaicFilter(12,12); 37 | _targetScene.filter = filter; 38 | Starling.juggler.tween(filter,0.3,{thresholdX:0.1,thresholdY:0.1,onComplete:function():void{ 39 | _targetScene.filter = null; 40 | filter.dispose(); 41 | callBack(); 42 | }}); 43 | } 44 | 45 | internal function set replaceScene(value:BaseScene):void{ 46 | _replaceScene = value; 47 | } 48 | 49 | internal function get replaceScene():BaseScene{ 50 | return _replaceScene; 51 | } 52 | 53 | internal function set targetScene(value:BaseScene):void{ 54 | _targetScene = value; 55 | } 56 | 57 | internal function get targetScene():BaseScene{ 58 | return _targetScene; 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/display/ContentList.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.display 2 | { 3 | import lzm.starling.gestures.TapGestures; 4 | 5 | /** 6 | * 可在listitem下面显示一个内容区域的list组建 7 | * @author lzm 8 | * 9 | */ 10 | public class ContentList extends ScrollContainer 11 | { 12 | 13 | private var _items:Vector.; 14 | private var __itemCount:int = 0; 15 | 16 | private var _contentTitleHeight:int;//每个标题的高度 17 | private var _contentHeight:int;//每个标题内容的高度 18 | 19 | private var _currentIndex:int = -1;//当前显示的容器 20 | 21 | /** 22 | * @param width 容器宽度 23 | * @param height 容器高度 24 | * @param contentTitleHeight 每个标题的高度 25 | * @param contentHeight 每个标题内容的高度 26 | */ 27 | public function ContentList(width:int,height:int,contentTitleHeight:int,contentHeight:int) 28 | { 29 | super(); 30 | this.width = width; 31 | this.height = height; 32 | 33 | _contentTitleHeight = contentTitleHeight; 34 | _contentHeight = contentHeight; 35 | _items = new Vector.(); 36 | } 37 | 38 | public function addContentListItem(item:ContentListItem):void{ 39 | item.index = __itemCount; 40 | item.normalY = __itemCount * (_contentTitleHeight + 3); 41 | item.otherOpenY = item.normalY + this._contentHeight; 42 | item.content.width = this.width; 43 | item.content.height = this._contentHeight; 44 | new TapGestures(item,change(item.index)); 45 | if(_currentIndex != -1 && _currentIndex > __itemCount){ 46 | item.y = item.otherOpenY; 47 | }else{ 48 | item.y = item.normalY; 49 | } 50 | addChild(item); 51 | _items.push(item); 52 | __itemCount++; 53 | } 54 | 55 | public function set currentIndex(value:int):void{ 56 | if(_currentIndex != -1){ 57 | _items[_currentIndex].content.removeFromParent(); 58 | } 59 | _currentIndex = value == _currentIndex ? -1 : value; 60 | var count:int = _items.length; 61 | var item:ContentListItem; 62 | for (var i:int = 0; i < __itemCount; i++) { 63 | item = _items[i]; 64 | if(_currentIndex == -1){ 65 | item.y = item.normalY; 66 | }else if(i < _currentIndex){ 67 | item.y = item.normalY; 68 | }else if(i > _currentIndex){ 69 | item.y = item.otherOpenY; 70 | }else{ 71 | item.y = item.normalY; 72 | item.content.alpha = 1; 73 | item.content.y = item.y + _contentTitleHeight; 74 | addChildAt(item.content,0); 75 | } 76 | } 77 | } 78 | 79 | private function change(index:int):Function{ 80 | return function():void{ 81 | currentIndex = index; 82 | } 83 | } 84 | 85 | public function get currentIndex():int{ 86 | return _currentIndex; 87 | } 88 | } 89 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/display/ContentListItem.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.display 2 | { 3 | import starling.display.Sprite; 4 | 5 | public class ContentListItem extends Sprite 6 | { 7 | 8 | private var _content:ScrollContainer; 9 | 10 | internal var index:int; 11 | internal var otherOpenY:Number;//其他item打开后y所在的位置 12 | internal var normalY:Number//没有其他item打开的时候所在的y的位置 13 | 14 | public function ContentListItem() 15 | { 16 | super(); 17 | _content = new ScrollContainer(); 18 | } 19 | 20 | public function get content():ScrollContainer{ 21 | return _content; 22 | } 23 | 24 | } 25 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/display/DistortImage.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.display 2 | { 3 | import starling.display.Image; 4 | import starling.textures.Texture; 5 | 6 | /** 7 | * 任意变形的图片 8 | * @author lzm 9 | * 10 | */ 11 | public class DistortImage extends Image 12 | { 13 | 14 | private var _w:Number; 15 | private var _h:Number; 16 | 17 | public function DistortImage(texture:Texture) 18 | { 19 | super(texture); 20 | _w = texture.width; 21 | _h = texture.height; 22 | } 23 | 24 | /** 25 | * 设置顶点位置 26 | * */ 27 | public function setVertextDataPostion(vertexID:int, x:Number, y:Number):void{ 28 | switch(vertexID) 29 | { 30 | case 0: 31 | mVertexData.setPosition(vertexID,x,y); 32 | break; 33 | case 1: 34 | mVertexData.setPosition(vertexID,_w + x,y); 35 | break; 36 | case 2: 37 | mVertexData.setPosition(vertexID,x,_h + y); 38 | break; 39 | case 3: 40 | mVertexData.setPosition(vertexID,_w + x,_h + y); 41 | break; 42 | } 43 | resetAllTexCoords(); 44 | onVertexDataChanged(); 45 | } 46 | 47 | /**重置UV坐标*/ 48 | protected function resetAllTexCoords():void 49 | { 50 | mVertexData.setTexCoords(0, 0, 0); 51 | mVertexData.setTexCoords(1, 1, 0); 52 | mVertexData.setTexCoords(2, 0, 1); 53 | mVertexData.setTexCoords(3, 1.0, 1.0); 54 | } 55 | 56 | } 57 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/display/ImageViewer.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.display 2 | { 3 | import feathers.controls.Scroller; 4 | import feathers.layout.HorizontalLayout; 5 | 6 | import lzm.starling.gestures.MoveOverGestures; 7 | import lzm.util.DoScale; 8 | 9 | import starling.core.Starling; 10 | import starling.display.DisplayObject; 11 | 12 | public class ImageViewer extends ScrollContainer 13 | { 14 | private var _tempHorizontalPosition:Number = 0; 15 | private var _tempIndex:int = 0; 16 | 17 | public function ImageViewer(width:Number,height:Number) 18 | { 19 | super(); 20 | this.width = width; 21 | this.height= height; 22 | 23 | var layout:HorizontalLayout = new HorizontalLayout(); 24 | layout.gap = 0; 25 | 26 | this.layout = layout; 27 | this.scrollBarDisplayMode = Scroller.SCROLL_BAR_DISPLAY_MODE_NONE; 28 | new MoveOverGestures(this,stopMove); 29 | } 30 | 31 | private function stopMove():void{ 32 | stopScrolling(); 33 | if(_tempHorizontalPosition > horizontalScrollPosition){//往左边滑动了 34 | _tempIndex--; 35 | }else if(_tempHorizontalPosition < horizontalScrollPosition){//往右边滑动了 36 | _tempIndex++; 37 | } 38 | 39 | var maxIndex:int = int(maxHorizontalScrollPosition / width); 40 | _tempIndex = _tempIndex < 0 ? 0 : _tempIndex; 41 | _tempIndex = _tempIndex > maxIndex ? maxIndex : _tempIndex; 42 | 43 | _tempHorizontalPosition = _tempIndex * width; 44 | 45 | Starling.juggler.tween(this,0.1,{horizontalScrollPosition:_tempHorizontalPosition}); 46 | } 47 | 48 | public function addImage(image:DisplayObject):void{ 49 | var scObject:Object = DoScale.doScale(image.width,image.height,width,height); 50 | image.scaleX = scObject.sx; 51 | image.scaleY = scObject.sy; 52 | 53 | var item:ScrollContainerItem = new ScrollContainerItem(); 54 | item.addChild(image); 55 | 56 | addScrollContainerItem(item); 57 | } 58 | } 59 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/display/ScrollContainerItem.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.display 2 | { 3 | import flash.geom.Rectangle; 4 | 5 | import starling.display.DisplayObject; 6 | import starling.display.Sprite; 7 | import starling.events.Event; 8 | 9 | public class ScrollContainerItem extends Sprite 10 | { 11 | internal var _viewPort:Rectangle; 12 | internal var _isInView:Boolean = false;//是否在显示范围内部 13 | internal var _scrollContainer:ScrollContainer;//容器 14 | 15 | public function ScrollContainerItem() 16 | { 17 | super(); 18 | _viewPort = new Rectangle(); 19 | addEventListener(Event.ADDED_TO_STAGE,addToStage); 20 | } 21 | 22 | protected function addToStage(e:Event):void{ 23 | var temp:Rectangle = getBounds(parent); 24 | _viewPort.width = temp.width; 25 | _viewPort.height = temp.height; 26 | } 27 | 28 | public override function addChildAt(child:DisplayObject, index:int):DisplayObject{ 29 | super.addChildAt(child,index); 30 | if(parent) addToStage(null); 31 | return child; 32 | } 33 | 34 | public override function removeChildAt(index:int, dispose:Boolean=false):DisplayObject{ 35 | var child:DisplayObject = super.removeChildAt(index,dispose); 36 | if(parent) addToStage(null); 37 | return child; 38 | } 39 | 40 | public override function set x(value:Number):void{ 41 | super.x = value; 42 | _viewPort.x = value; 43 | if(_scrollContainer) _scrollContainer.updateShowItems(); 44 | } 45 | 46 | public override function set y(value:Number):void{ 47 | super.y = value; 48 | _viewPort.y = value; 49 | if(_scrollContainer) _scrollContainer.updateShowItems(); 50 | } 51 | 52 | /** 53 | * 进入显示区域 54 | * */ 55 | public function inView():void{ 56 | 57 | } 58 | 59 | /** 60 | * 离开显示区域 61 | * */ 62 | public function outView():void{ 63 | 64 | } 65 | 66 | public function get isInView():Boolean{ 67 | return _isInView; 68 | } 69 | 70 | public function get scrollContainer():ScrollContainer{ 71 | return _scrollContainer; 72 | } 73 | 74 | public override function dispose():void{ 75 | _scrollContainer = null; 76 | super.dispose(); 77 | } 78 | } 79 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/entityComponent/EntityComponent.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.entityComponent 2 | { 3 | import starling.events.EventDispatcher; 4 | 5 | public class EntityComponent extends EventDispatcher 6 | { 7 | /** 8 | * 组件属于哪一个Entity 9 | * */ 10 | internal var _entity:Entity; 11 | 12 | /** 13 | * 组件的名称 14 | * */ 15 | public var name:String; 16 | 17 | public function EntityComponent() 18 | { 19 | 20 | } 21 | 22 | public function get entity():Entity{ 23 | return _entity; 24 | } 25 | 26 | public function start():void{ 27 | 28 | } 29 | 30 | public function update():void{ 31 | 32 | } 33 | 34 | public function stop():void{ 35 | 36 | } 37 | 38 | public function dispose():void{ 39 | _entity = null; 40 | 41 | removeEventListeners(); 42 | } 43 | } 44 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/entityComponent/EntityWorld.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.entityComponent 2 | { 3 | import starling.events.EnterFrameEvent; 4 | import starling.events.Event; 5 | 6 | public class EntityWorld extends Entity 7 | { 8 | public function EntityWorld() 9 | { 10 | 11 | } 12 | 13 | protected function enterFrame(e:EnterFrameEvent):void{ 14 | update(); 15 | } 16 | 17 | /** 18 | * 开始 19 | * */ 20 | public function start():void{ 21 | addEventListener(Event.ENTER_FRAME,enterFrame); 22 | } 23 | 24 | /** 25 | * 停止 26 | * */ 27 | public function stop():void{ 28 | removeEventListener(Event.ENTER_FRAME,enterFrame); 29 | } 30 | 31 | public override function dispose():void{ 32 | stop(); 33 | super.dispose(); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/entityComponent/gestures/DragGesturesComponent.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.entityComponent.gestures 2 | { 3 | import lzm.starling.entityComponent.EntityComponent; 4 | import lzm.starling.gestures.DragGestures; 5 | 6 | /** 7 | * 拖拽手势 8 | * @author lingjing 9 | */ 10 | public class DragGesturesComponent extends EntityComponent 11 | { 12 | 13 | private var _dragGestures:DragGestures; 14 | 15 | public function DragGesturesComponent() 16 | { 17 | super(); 18 | } 19 | 20 | public override function start():void{ 21 | _dragGestures = new DragGestures(entity); 22 | } 23 | 24 | public override function stop():void{ 25 | _dragGestures.dispose(); 26 | _dragGestures = null; 27 | } 28 | 29 | public override function dispose():void{ 30 | if(_dragGestures){ 31 | _dragGestures.dispose(); 32 | } 33 | super.dispose(); 34 | } 35 | 36 | public function get gestures():DragGestures{ 37 | return _dragGestures; 38 | } 39 | 40 | } 41 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/DoubleTapGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import flash.geom.Rectangle; 4 | 5 | import starling.display.DisplayObject; 6 | import starling.events.Touch; 7 | import starling.events.TouchPhase; 8 | 9 | /** 10 | * 双击收拾 11 | * @author lzm 12 | * 13 | */ 14 | public class DoubleTapGestures extends Gestures 15 | { 16 | public function DoubleTapGestures(target:DisplayObject, callBack:Function=null) 17 | { 18 | super(target, callBack); 19 | } 20 | 21 | public override function checkGestures(touch:Touch):void{ 22 | if(touch.phase == TouchPhase.ENDED && touch.tapCount == 2){ 23 | 24 | var buttonRect:Rectangle = _target.getBounds(_target.stage); 25 | if (touch.globalX < buttonRect.x || 26 | touch.globalY < buttonRect.y || 27 | touch.globalX > buttonRect.x + buttonRect.width || 28 | touch.globalY > buttonRect.y+ buttonRect.height ){ 29 | return; 30 | } 31 | 32 | if(_callBack){ 33 | if(_callBack.length == 0){ 34 | _callBack(); 35 | }else{ 36 | _callBack(touch); 37 | } 38 | } 39 | } 40 | } 41 | 42 | } 43 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/Gestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import starling.display.DisplayObject; 4 | import starling.events.Touch; 5 | import starling.events.TouchEvent; 6 | 7 | /** 8 | * 手势基类 9 | * @author lzm 10 | * 11 | */ 12 | public class Gestures 13 | { 14 | protected var _target:DisplayObject;//目标 15 | protected var _callBack:Function;//回调 16 | 17 | private var _enabled:Boolean = true; 18 | 19 | public function Gestures(target:DisplayObject,callBack:Function=null){ 20 | _target = target; 21 | _callBack = callBack; 22 | 23 | _target.addEventListener(TouchEvent.TOUCH,onTouch); 24 | } 25 | 26 | public function set callBack(value:Function):void{ 27 | _callBack = value; 28 | } 29 | 30 | public function get callBack():Function{ 31 | return _callBack; 32 | } 33 | 34 | /** 35 | * 检测手势 36 | * */ 37 | protected function onTouch(e:TouchEvent):void{ 38 | var touch:Touch = e.getTouch(_target); 39 | if(touch) checkGestures(touch); 40 | 41 | var touches:Vector. = e.getTouches(_target); 42 | if(touches && touches.length > 0) checkGesturesByTouches(touches); 43 | } 44 | 45 | /** 46 | * 检测手势 47 | * */ 48 | public function checkGestures(touch:Touch):void{ 49 | 50 | } 51 | 52 | /** 53 | * 检测手势 54 | * */ 55 | public function checkGesturesByTouches(touches:Vector.):void{ 56 | 57 | } 58 | 59 | public function get target():DisplayObject{ 60 | return _target; 61 | } 62 | 63 | public function set enabled(value:Boolean):void{ 64 | if(_enabled == value) return; 65 | 66 | _enabled = value; 67 | 68 | if(_enabled) 69 | _target.addEventListener(TouchEvent.TOUCH,onTouch); 70 | else 71 | _target.removeEventListener(TouchEvent.TOUCH,onTouch); 72 | } 73 | 74 | public function get enabled():Boolean{ 75 | return _enabled; 76 | } 77 | 78 | public function dispose():void{ 79 | _target.removeEventListener(TouchEvent.TOUCH,onTouch); 80 | _target = null; 81 | _callBack = null; 82 | } 83 | } 84 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/HoldGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import flash.events.TimerEvent; 4 | import flash.utils.Timer; 5 | 6 | import starling.display.DisplayObject; 7 | import starling.events.Touch; 8 | import starling.events.TouchPhase; 9 | 10 | /** 11 | * 长按收拾 12 | * @author zmliu 13 | */ 14 | public class HoldGestures extends Gestures 15 | { 16 | private var _timer:Timer; 17 | private var _holdTime:int = 500; 18 | private var _callBackTime:int = 100; 19 | 20 | private var _firstHold:Boolean = false; 21 | private var _holdStartCallBack:Function; 22 | private var _holdEndCallBack:Function; 23 | 24 | public function HoldGestures(target:DisplayObject, callBack:Function=null,holdEndCallBack:Function=null,holdStartCallBack:Function=null) 25 | { 26 | super(target, callBack); 27 | _holdEndCallBack = holdEndCallBack; 28 | _holdStartCallBack = holdStartCallBack; 29 | } 30 | 31 | public override function checkGestures(touch:Touch):void{ 32 | if(touch.phase == TouchPhase.BEGAN){ 33 | if(_timer == null){ 34 | _timer = new Timer(_holdTime); 35 | _timer.addEventListener(TimerEvent.TIMER,onTimer); 36 | } 37 | _timer.start(); 38 | }else if(touch.phase == TouchPhase.MOVED){ 39 | 40 | }else if(touch.phase == TouchPhase.ENDED){ 41 | if(_holdEndCallBack && _timer.delay == _callBackTime) _holdEndCallBack(); 42 | 43 | _timer.stop(); 44 | _timer.reset(); 45 | _timer.delay = _holdTime; 46 | } 47 | } 48 | 49 | private function onTimer(e:TimerEvent):void{ 50 | if(_timer.delay == _holdTime) _timer.delay = _callBackTime; 51 | if(!_firstHold && _holdStartCallBack) { 52 | _holdStartCallBack(); 53 | _firstHold = true; 54 | } 55 | if(_callBack) _callBack(); 56 | } 57 | 58 | public override function dispose():void{ 59 | super.dispose(); 60 | if(_timer){ 61 | _timer.stop(); 62 | _timer.removeEventListener(TimerEvent.TIMER,onTimer); 63 | _timer = null; 64 | } 65 | _holdEndCallBack = null; 66 | } 67 | 68 | 69 | 70 | } 71 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/HoverGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import starling.display.DisplayObject; 4 | import starling.events.Touch; 5 | import starling.events.TouchPhase; 6 | 7 | /** 8 | * 悬停手势 9 | * @author lzm 10 | * 11 | */ 12 | public class HoverGestures extends Gestures 13 | { 14 | public function HoverGestures(target:DisplayObject, callBack:Function=null) 15 | { 16 | super(target, callBack); 17 | } 18 | 19 | public override function checkGestures(touch:Touch):void{ 20 | if(touch.phase == TouchPhase.HOVER){ 21 | if(_callBack){ 22 | if(_callBack.length == 0){ 23 | _callBack(); 24 | }else{ 25 | _callBack(touch); 26 | } 27 | } 28 | } 29 | } 30 | } 31 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/MoveOverGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import starling.display.DisplayObject; 4 | import starling.events.Touch; 5 | import starling.events.TouchPhase; 6 | 7 | public class MoveOverGestures extends Gestures 8 | { 9 | private var _isMove:Boolean = false; 10 | 11 | public function MoveOverGestures(target:DisplayObject, callBack:Function=null) 12 | { 13 | super(target, callBack); 14 | } 15 | 16 | public override function checkGestures(touch:Touch):void{ 17 | if(touch.phase == TouchPhase.BEGAN){ 18 | _isMove = false; 19 | }else if(touch.phase == TouchPhase.MOVED){ 20 | _isMove = true; 21 | }else if(touch.phase == TouchPhase.ENDED){ 22 | _isMove = false; 23 | if(_callBack){ 24 | if(_callBack.length == 0){ 25 | _callBack(); 26 | }else{ 27 | _callBack(touch); 28 | } 29 | } 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/MovedGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import starling.display.DisplayObject; 4 | import starling.events.Touch; 5 | import starling.events.TouchPhase; 6 | 7 | /** 8 | * 移动手势 9 | * @author lzm 10 | * 11 | */ 12 | public class MovedGestures extends Gestures 13 | { 14 | public function MovedGestures(target:DisplayObject, callBack:Function=null) 15 | { 16 | super(target, callBack); 17 | } 18 | 19 | public override function checkGestures(touch:Touch):void{ 20 | if(touch.phase == TouchPhase.BEGAN){ 21 | }else if(touch.phase == TouchPhase.MOVED){ 22 | if(_callBack){ 23 | if(_callBack.length == 0){ 24 | _callBack(); 25 | }else{ 26 | _callBack(touch); 27 | } 28 | } 29 | }else if(touch.phase == TouchPhase.ENDED){ 30 | } 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/RotationGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.display.DisplayObject; 6 | import starling.events.Touch; 7 | import starling.events.TouchPhase; 8 | 9 | /** 10 | * 旋转收拾 11 | * @author lzm 12 | * 13 | */ 14 | public class RotationGestures extends Gestures 15 | { 16 | public function RotationGestures(target:DisplayObject, callBack:Function=null) 17 | { 18 | super(target, callBack); 19 | } 20 | 21 | public override function checkGesturesByTouches(touches:Vector.):void{ 22 | if(touches.length != 2) return; 23 | 24 | var touchA:Touch = touches[0]; 25 | var touchB:Touch = touches[1]; 26 | 27 | if(touchA.phase != TouchPhase.MOVED || touchB.phase != TouchPhase.MOVED) return; 28 | 29 | var currentPosA:Point = touchA.getLocation(_target.parent); 30 | var previousPosA:Point = touchA.getPreviousLocation(_target.parent); 31 | var currentPosB:Point = touchB.getLocation(_target.parent); 32 | var previousPosB:Point = touchB.getPreviousLocation(_target.parent); 33 | 34 | var currentVector:Point = currentPosA.subtract(currentPosB); 35 | var previousVector:Point = previousPosA.subtract(previousPosB); 36 | 37 | var currentAngle:Number = Math.atan2(currentVector.y, currentVector.x); 38 | var previousAngle:Number = Math.atan2(previousVector.y, previousVector.x); 39 | var deltaAngle:Number = currentAngle - previousAngle; 40 | 41 | var previousLocalA:Point = touchA.getPreviousLocation(_target); 42 | var previousLocalB:Point = touchB.getPreviousLocation(_target); 43 | _target.pivotX = (previousLocalA.x + previousLocalB.x) * 0.5; 44 | _target.pivotY = (previousLocalA.y + previousLocalB.y) * 0.5; 45 | _target.x = (currentPosA.x + currentPosB.x) * 0.5; 46 | _target.y = (currentPosA.y + currentPosB.y) * 0.5; 47 | 48 | _target.rotation += deltaAngle; 49 | } 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/SwipeGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import flash.geom.Point; 4 | import flash.utils.getTimer; 5 | 6 | import starling.display.DisplayObject; 7 | import starling.events.Touch; 8 | import starling.events.TouchPhase; 9 | 10 | /** 11 | * @author 昀凡 12 | */ 13 | public class SwipeGestures extends Gestures 14 | { 15 | public static const UP:String = "up"; 16 | public static const DOWN:String = "down"; 17 | public static const LEFT:String = "left"; 18 | public static const RIGHT:String = "right"; 19 | private static const DISTIME:int = 300; 20 | private static const DIS:int = 50; 21 | private var _downPoint:Point; 22 | private var _downTime:int; 23 | public function SwipeGestures(target:DisplayObject, callBack:Function=null) 24 | { 25 | super(target, callBack); 26 | } 27 | public override function checkGestures(touch:Touch):void{ 28 | if(touch.phase == TouchPhase.BEGAN){ 29 | _downPoint = touch.getLocation(_target.stage); 30 | _downTime = getTimer(); 31 | }else if(touch.phase == TouchPhase.ENDED){ 32 | var timeDis:int = getTimer() - _downTime; 33 | var releasePoint:Point = touch.getLocation(_target.stage); 34 | //trace("时间差:", timeDis); 35 | if(DISTIME < timeDis)return; 36 | var xDis:int = releasePoint.x - _downPoint.x; 37 | var yDis:int = releasePoint.y - _downPoint.y; 38 | if(Math.abs(xDis) > Math.abs(yDis)) 39 | { 40 | if(Math.abs(xDis)>DIS && _callBack != null) 41 | _callBack(xDis > 0 ? RIGHT : LEFT); 42 | }else 43 | { 44 | if(Math.abs(yDis)>DIS && _callBack != null) 45 | _callBack(yDis > 0 ? DOWN : UP); 46 | } 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/gestures/ZoomGestures.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.gestures 2 | { 3 | import flash.geom.Point; 4 | 5 | import starling.display.DisplayObject; 6 | import starling.events.Touch; 7 | import starling.events.TouchPhase; 8 | 9 | /** 10 | * 缩放手势 11 | * @author lzm 12 | * 13 | */ 14 | public class ZoomGestures extends Gestures 15 | { 16 | public var minScale:Number = NaN;//可以缩放的最小值 17 | public var maxScale:Number = NaN;//可以缩放的最大值 18 | 19 | public function ZoomGestures(target:DisplayObject, callBack:Function=null) 20 | { 21 | super(target, callBack); 22 | } 23 | 24 | public override function checkGesturesByTouches(touches:Vector.):void{ 25 | if(touches.length != 2) return; 26 | 27 | var touchA:Touch = touches[0]; 28 | var touchB:Touch = touches[1]; 29 | 30 | if(touchA.phase != TouchPhase.MOVED || touchB.phase != TouchPhase.MOVED) return; 31 | 32 | var currentPosA:Point = touchA.getLocation(_target.parent); 33 | var previousPosA:Point = touchA.getPreviousLocation(_target.parent); 34 | var currentPosB:Point = touchB.getLocation(_target.parent); 35 | var previousPosB:Point = touchB.getPreviousLocation(_target.parent); 36 | 37 | var currentVector:Point = currentPosA.subtract(currentPosB); 38 | var previousVector:Point = previousPosA.subtract(previousPosB); 39 | 40 | var currentAngle:Number = Math.atan2(currentVector.y, currentVector.x); 41 | var previousAngle:Number = Math.atan2(previousVector.y, previousVector.x); 42 | var deltaAngle:Number = currentAngle - previousAngle; 43 | 44 | var previousLocalA:Point = touchA.getPreviousLocation(_target); 45 | var previousLocalB:Point = touchB.getPreviousLocation(_target); 46 | _target.pivotX = (previousLocalA.x + previousLocalB.x) * 0.5; 47 | _target.pivotY = (previousLocalA.y + previousLocalB.y) * 0.5; 48 | _target.x = (currentPosA.x + currentPosB.x) * 0.5; 49 | _target.y = (currentPosA.y + currentPosB.y) * 0.5; 50 | 51 | var sizeDiff:Number = currentVector.length / previousVector.length; 52 | _target.scaleX *= sizeDiff; 53 | _target.scaleY *= sizeDiff; 54 | 55 | if(!isNaN(minScale)){ 56 | if(_target.scaleX < minScale) _target.scaleX = minScale; 57 | if(_target.scaleY < minScale) _target.scaleY = minScale; 58 | } 59 | 60 | if(!isNaN(maxScale)){ 61 | if(_target.scaleX > maxScale) _target.scaleX = maxScale; 62 | if(_target.scaleY > maxScale) _target.scaleY = maxScale; 63 | } 64 | 65 | } 66 | 67 | } 68 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/FPSUtil.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf 2 | { 3 | import flash.utils.getTimer; 4 | 5 | /** 6 | * 当某个enterframe事件 需要用特定的帧率 而不是stage的帧率可以使用这个工具跳帧 7 | * @author zmliu 8 | * 9 | */ 10 | public class FPSUtil 11 | { 12 | 13 | private var _fps:int; 14 | private var _fpsTime:Number; 15 | private var _currentTime:Number; 16 | private var _lastFrameTimestamp:Number; 17 | 18 | private var _pause:Boolean = false; 19 | 20 | public function FPSUtil(fps:int) 21 | { 22 | this.fps = fps; 23 | } 24 | 25 | public function get fps():int{ 26 | return _fps; 27 | } 28 | 29 | public function set fps(value:int):void{ 30 | _fps = value; 31 | _fpsTime = 1000 / _fps * 0.001; 32 | _currentTime = 0; 33 | _lastFrameTimestamp = getTimer() / 1000; 34 | } 35 | 36 | public function update():Boolean{ 37 | if(_pause) return false; 38 | 39 | var now:Number = getTimer() / 1000.0; 40 | var passedTime:Number = now - _lastFrameTimestamp; 41 | _lastFrameTimestamp = now; 42 | 43 | _currentTime += passedTime; 44 | if(_currentTime >= _fpsTime){ 45 | _currentTime -= _fpsTime; 46 | if(_currentTime > _fpsTime){ 47 | _currentTime = 0; 48 | } 49 | return true; 50 | } 51 | return false; 52 | } 53 | 54 | public function pause():void{ 55 | _pause = true; 56 | } 57 | 58 | public function resume():void{ 59 | _pause = false; 60 | } 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/SwfUpdateManager.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf 2 | { 3 | import lzm.starling.swf.display.ISwfAnimation; 4 | 5 | import starling.display.Sprite; 6 | import starling.events.EnterFrameEvent; 7 | import starling.events.Event; 8 | 9 | /** 10 | * 11 | * @author zmliu 12 | * 13 | */ 14 | public class SwfUpdateManager 15 | { 16 | 17 | private var _starlingRoot:Sprite; 18 | private var _fpsUtil:FPSUtil; 19 | 20 | private var _animations:Vector.; 21 | 22 | public function SwfUpdateManager(fps:int,starlingRoot:Sprite){ 23 | _fpsUtil = new FPSUtil(fps); 24 | _starlingRoot = starlingRoot; 25 | 26 | _animations = new Vector.(); 27 | } 28 | 29 | public function addSwfAnimation(animation:ISwfAnimation):void{ 30 | var index:int = _animations.indexOf(animation); 31 | if(index == -1){ 32 | _animations.push(animation); 33 | if(_animations.length == 1){ 34 | _starlingRoot.addEventListener(Event.ENTER_FRAME,enterFrame); 35 | } 36 | } 37 | } 38 | 39 | public function removeSwfAnimation(animation:ISwfAnimation):void{ 40 | var index:int = _animations.indexOf(animation); 41 | if(index != -1){ 42 | _animations.splice(index,1); 43 | } 44 | if(_animations.length == 0){ 45 | _starlingRoot.removeEventListener(Event.ENTER_FRAME,enterFrame); 46 | } 47 | } 48 | 49 | private function enterFrame(e:EnterFrameEvent):void{ 50 | if(_fpsUtil &&_fpsUtil.update()){ 51 | for each (var animation:ISwfAnimation in _animations) { 52 | if(animation.stage) animation.update(); 53 | } 54 | } 55 | } 56 | 57 | public function set fps(value:int):void{ 58 | _fpsUtil.fps = value; 59 | } 60 | 61 | public function get fps():int{ 62 | return _fpsUtil.fps; 63 | } 64 | 65 | public function dispose():void{ 66 | _starlingRoot.removeEventListener(Event.ENTER_FRAME,enterFrame); 67 | 68 | _starlingRoot = null; 69 | _fpsUtil = null; 70 | _animations = null; 71 | } 72 | 73 | 74 | 75 | 76 | } 77 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/blendmode/SwfBlendMode.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.blendmode 2 | { 3 | import starling.display.DisplayObject; 4 | 5 | public class SwfBlendMode 6 | { 7 | 8 | public static const modes:Object = { 9 | "auto":true, 10 | "none":true, 11 | "normal":true, 12 | "add":true, 13 | "multiply":true, 14 | "screen":true, 15 | "erase":true, 16 | "below":true 17 | } 18 | 19 | public static function setBlendMode(display:DisplayObject,blendMode:String):void{ 20 | if(modes[blendMode]){ 21 | display.blendMode = blendMode; 22 | } 23 | } 24 | 25 | } 26 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/ComponentConfig.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components 2 | { 3 | import lzm.starling.swf.components.feathers.FeathersButton; 4 | import lzm.starling.swf.components.feathers.FeathersCheck; 5 | import lzm.starling.swf.components.feathers.FeathersProgressBar; 6 | import lzm.starling.swf.components.feathers.FeathersTextInput; 7 | 8 | public class ComponentConfig 9 | { 10 | private static var config:ComponentConfig; 11 | 12 | private var componentClass:Object = { 13 | "comp_feathers_button":FeathersButton, 14 | "comp_feathers_check":FeathersCheck, 15 | "comp_feathers_input":FeathersTextInput, 16 | "comp_feathers_progressbar":FeathersProgressBar 17 | }; 18 | 19 | public static function getInstance():ComponentConfig{ 20 | if(config == null) config = new ComponentConfig(); 21 | return config; 22 | } 23 | 24 | /** 25 | * 获取组建的类 26 | * */ 27 | public function getComponentClass(classKey:String):*{ 28 | for(var key:String in componentClass){ 29 | if(classKey.indexOf(key) == 0){ 30 | return componentClass[key]; 31 | } 32 | } 33 | return null; 34 | } 35 | 36 | /** 动态添加组件 */ 37 | public function addComponentClass(compName:String,compClass:Class):void{ 38 | componentClass[compName] = compClass; 39 | } 40 | 41 | /** 移除组件 */ 42 | public function removeComponentClass(compName:String):void{ 43 | delete componentClass[compName]; 44 | } 45 | 46 | 47 | //-----------静态方法-----------// 48 | 49 | /** 获取组建的类 */ 50 | public static function getComponentClass(classKey:String):*{ 51 | return getInstance().getComponentClass(classKey); 52 | } 53 | 54 | /** 动态添加组件 */ 55 | public static function addComponentClass(compName:String,compClass:Class):void{ 56 | getInstance().addComponentClass(compName,compClass); 57 | } 58 | 59 | /** 移除组件 */ 60 | public static function removeComponentClass(compName:String):void{ 61 | getInstance().removeComponentClass(compName); 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/ISwfComponent.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components 2 | { 3 | import lzm.starling.swf.display.SwfSprite; 4 | 5 | public interface ISwfComponent 6 | { 7 | 8 | /** 9 | * 设置 /获取 组件名称 10 | * */ 11 | function get name():String; 12 | function set name(value:String):void; 13 | 14 | /** 15 | * 初始化组件 16 | * @param componetContent 组件的基础显示内容 17 | */ 18 | function initialization(componetContent:SwfSprite):void; 19 | 20 | /** 21 | * 获取 / 设置 可编辑属性 22 | * */ 23 | function get editableProperties():Object; 24 | function set editableProperties(properties:Object):void; 25 | } 26 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/ISwfComponentForEditor.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components 2 | { 3 | public interface ISwfComponentForEditor 4 | { 5 | function init(componentConfig:ComponentConfig):void; 6 | } 7 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/feathers/FeathersButton.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components.feathers 2 | { 3 | import flash.text.TextFormat; 4 | 5 | import feathers.controls.Button; 6 | 7 | import lzm.starling.swf.components.ISwfComponent; 8 | import lzm.starling.swf.display.SwfSprite; 9 | 10 | import starling.display.DisplayObject; 11 | import starling.text.TextField; 12 | 13 | public class FeathersButton extends Button implements ISwfComponent 14 | { 15 | 16 | public function initialization(componetContent:SwfSprite):void{ 17 | var _upSkin:DisplayObject = componetContent.getChildByName("_upSkin"); 18 | var _downSkin:DisplayObject = componetContent.getChildByName("_downSkin"); 19 | var _disabledSkin:DisplayObject = componetContent.getChildByName("_disabledSkin"); 20 | 21 | var _labelTextField:TextField = componetContent.getTextField("_labelTextField"); 22 | 23 | if(_upSkin) { 24 | this.defaultSkin = _upSkin; 25 | _upSkin.removeFromParent(); 26 | } 27 | if(_downSkin){ 28 | this.downSkin = _downSkin; 29 | _downSkin.removeFromParent(); 30 | } 31 | if(_disabledSkin) { 32 | this.disabledSkin = _disabledSkin; 33 | _disabledSkin.removeFromParent(); 34 | } 35 | 36 | if(_labelTextField){ 37 | var textFormat:TextFormat = new TextFormat(); 38 | textFormat.font = _labelTextField.fontName; 39 | textFormat.size = _labelTextField.fontSize; 40 | textFormat.color = _labelTextField.color; 41 | textFormat.bold = _labelTextField.bold; 42 | textFormat.italic = _labelTextField.italic; 43 | 44 | this.defaultLabelProperties.textFormat = textFormat; 45 | this.label = _labelTextField.text; 46 | } 47 | 48 | componetContent.removeFromParent(true); 49 | } 50 | 51 | public function get editableProperties():Object{ 52 | return { 53 | label:label, 54 | isEnabled:isEnabled 55 | }; 56 | } 57 | 58 | public function set editableProperties(properties:Object):void{ 59 | for(var key:String in properties){ 60 | this[key] = properties[key]; 61 | } 62 | } 63 | 64 | } 65 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/feathers/FeathersProgressBar.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components.feathers 2 | { 3 | import feathers.controls.ProgressBar; 4 | 5 | import lzm.starling.swf.components.ISwfComponent; 6 | import lzm.starling.swf.display.SwfSprite; 7 | 8 | import starling.display.DisplayObject; 9 | 10 | public class FeathersProgressBar extends ProgressBar implements ISwfComponent 11 | { 12 | public function FeathersProgressBar() 13 | { 14 | super(); 15 | } 16 | 17 | public function initialization(componetContent:SwfSprite):void{ 18 | var _backgroundSkin:DisplayObject = componetContent.getChildByName("_backgroundSkin"); 19 | var _backgroundDisabledSkin:DisplayObject = componetContent.getChildByName("_backgroundDisabledSkin"); 20 | var _fillSkin:DisplayObject = componetContent.getChildByName("_fillSkin"); 21 | var _fillDisabledSkin:DisplayObject = componetContent.getChildByName("_fillDisabledSkin"); 22 | 23 | addChild(_backgroundSkin); 24 | addChild(_backgroundDisabledSkin); 25 | addChild(_fillSkin); 26 | addChild(_fillDisabledSkin); 27 | 28 | this.backgroundSkin = _backgroundSkin; 29 | this.backgroundDisabledSkin = _backgroundDisabledSkin; 30 | this.fillSkin = _fillSkin; 31 | this.fillDisabledSkin = _fillDisabledSkin; 32 | 33 | this.minimum = 0; 34 | this.maximum = 1; 35 | this.value = 0.3; 36 | 37 | componetContent.removeFromParent(true); 38 | } 39 | 40 | public function get editableProperties():Object{ 41 | return { 42 | isEnabled:isEnabled, 43 | minimum:minimum, 44 | maximum:maximum, 45 | value:value 46 | }; 47 | } 48 | 49 | public function set editableProperties(properties:Object):void{ 50 | for(var key:String in properties){ 51 | this[key] = properties[key]; 52 | } 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/feathers/FeathersTextInput.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components.feathers 2 | { 3 | import flash.text.TextFormat; 4 | 5 | import feathers.controls.TextInput; 6 | 7 | import lzm.starling.swf.components.ISwfComponent; 8 | import lzm.starling.swf.display.SwfSprite; 9 | 10 | import starling.display.DisplayObject; 11 | import starling.text.TextField; 12 | 13 | public class FeathersTextInput extends TextInput implements ISwfComponent 14 | { 15 | public function FeathersTextInput() 16 | { 17 | super(); 18 | } 19 | 20 | public function initialization(componetContent:SwfSprite):void{ 21 | var _backgroundSkin:DisplayObject = componetContent.getChildByName("_backgroundSkin"); 22 | var _backgroundDisabledSkin:DisplayObject = componetContent.getChildByName("_backgroundDisabledSkin"); 23 | var _backgroundFocusedSkin:DisplayObject = componetContent.getChildByName("_backgroundFocusedSkin"); 24 | 25 | var _textFormat:TextField = componetContent.getTextField("_textFormat"); 26 | 27 | if(_backgroundSkin){ 28 | this.backgroundSkin = _backgroundSkin; 29 | _backgroundSkin.removeFromParent(); 30 | } 31 | if(_backgroundDisabledSkin){ 32 | this.backgroundDisabledSkin = _backgroundDisabledSkin; 33 | _backgroundDisabledSkin.removeFromParent(); 34 | } 35 | if(_backgroundFocusedSkin){ 36 | this.backgroundFocusedSkin = _backgroundFocusedSkin; 37 | _backgroundFocusedSkin.removeFromParent(); 38 | } 39 | 40 | if(_textFormat != null){ 41 | this.textEditorProperties.fontFamily = _textFormat.fontName; 42 | this.textEditorProperties.fontSize = _textFormat.fontSize; 43 | this.textEditorProperties.color = _textFormat.color; 44 | 45 | var textFormat:TextFormat = new TextFormat(); 46 | textFormat.font = _textFormat.fontName; 47 | textFormat.size = _textFormat.fontSize; 48 | textFormat.color = _textFormat.color; 49 | 50 | this.promptProperties.textFormat = textFormat; 51 | this.prompt = _textFormat.text; 52 | } 53 | componetContent.removeFromParent(true); 54 | } 55 | 56 | public function get editableProperties():Object{ 57 | return { 58 | prompt:prompt, 59 | displayAsPassword:displayAsPassword, 60 | maxChars:maxChars, 61 | isEditable:isEditable 62 | }; 63 | } 64 | 65 | public function set editableProperties(properties:Object):void{ 66 | for(var key:String in properties){ 67 | this[key] = properties[key]; 68 | } 69 | } 70 | } 71 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/components/propertyvalues/ArrayPropertys.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.components.propertyvalues 2 | { 3 | public class ArrayPropertys 4 | { 5 | public var currentValue:Object; 6 | public var values:Array; 7 | } 8 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/display/ISwfAnimation.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.display 2 | { 3 | import starling.display.Stage; 4 | 5 | public interface ISwfAnimation 6 | { 7 | function update():void; 8 | 9 | function get stage():Stage; 10 | } 11 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/display/SwfButton.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.display 2 | { 3 | import lzm.starling.display.Button; 4 | 5 | import starling.display.DisplayObject; 6 | 7 | public class SwfButton extends Button 8 | { 9 | /** 导出的链接名 */ 10 | public var classLink:String; 11 | 12 | public function SwfButton(skin:DisplayObject, text:String=null, textFont:String=null) 13 | { 14 | super(skin, text, textFont); 15 | } 16 | } 17 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/display/SwfImage.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.display 2 | { 3 | import starling.display.Image; 4 | import starling.textures.Texture; 5 | 6 | public class SwfImage extends Image 7 | { 8 | /** 导出的链接名 */ 9 | public var classLink:String; 10 | 11 | public function SwfImage(texture:Texture) 12 | { 13 | super(texture); 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/display/SwfParticleSyetem.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.display 2 | { 3 | import extend.particlesystem.PDParticleSystem; 4 | 5 | import lzm.starling.swf.Swf; 6 | 7 | import starling.textures.Texture; 8 | 9 | public class SwfParticleSyetem extends SwfSprite implements ISwfAnimation 10 | { 11 | private var _ownerSwf:Swf;//所属swf 12 | 13 | private var _isPlay:Boolean = false; 14 | 15 | private var _pdParticle:PDParticleSystem; 16 | 17 | public function SwfParticleSyetem(config:XML, texture:Texture,ownerSwf:Swf) 18 | { 19 | _ownerSwf = ownerSwf; 20 | 21 | _pdParticle = new PDParticleSystem(config, texture); 22 | addChild(_pdParticle); 23 | 24 | start(_pdParticle.duration); 25 | } 26 | 27 | public function update():void{ 28 | if(_isPlay) _pdParticle.advanceTime(_ownerSwf.passedTime); 29 | } 30 | 31 | public function start(duration:Number=Number.MAX_VALUE):void{ 32 | _pdParticle.start(duration); 33 | 34 | _isPlay = true; 35 | _ownerSwf.swfUpdateManager.addSwfAnimation(this); 36 | } 37 | 38 | public function startPD(callBack:Function=null, delayTime:int=100):void{ 39 | _pdParticle.startPD(callBack,delayTime); 40 | 41 | _isPlay = true; 42 | _ownerSwf.swfUpdateManager.addSwfAnimation(this); 43 | } 44 | 45 | public function stop(clearParticles:Boolean=false):void{ 46 | _pdParticle.stop(clearParticles); 47 | 48 | _isPlay = false; 49 | _ownerSwf.swfUpdateManager.removeSwfAnimation(this); 50 | } 51 | 52 | public function setPostion(x:Number,y:Number):void{ 53 | _pdParticle.emitterX = x; 54 | _pdParticle.emitterY = y; 55 | // this.x = _pdParticle.pivotX = _pdParticle.emitterX = x; 56 | // this.y = _pdParticle.pivotY = _pdParticle.emitterY = y; 57 | } 58 | 59 | public override function dispose():void{ 60 | _ownerSwf.swfUpdateManager.removeSwfAnimation(this); 61 | _ownerSwf = null; 62 | 63 | _pdParticle.stop(true); 64 | _pdParticle.removeFromParent(true); 65 | 66 | super.dispose(); 67 | } 68 | 69 | } 70 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/display/SwfShapeImage.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.display 2 | { 3 | import feathers.display.TiledImage; 4 | 5 | import starling.textures.Texture; 6 | import starling.textures.TextureSmoothing; 7 | 8 | /** 9 | * 使用纹理填充的图片(纹理长宽需要为2的幂数) 10 | * @author zmliu 11 | * 12 | */ 13 | public class SwfShapeImage extends TiledImage 14 | { 15 | /** 导出的链接名 */ 16 | public var classLink:String; 17 | 18 | public function SwfShapeImage(texture:Texture) 19 | { 20 | super(texture,texture.scale); 21 | smoothing = TextureSmoothing.NONE; 22 | } 23 | } 24 | } 25 | 26 | 27 | -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/swf/filter/SwfFilter.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.swf.filter 2 | { 3 | import flash.utils.getDefinitionByName; 4 | 5 | import starling.filters.BlurFilter; 6 | import starling.filters.FragmentFilter; 7 | import starling.filters.FragmentFilterMode; 8 | 9 | 10 | /** 11 | * 滤镜管理类 12 | * @author zmliu 13 | * 14 | */ 15 | public class SwfFilter 16 | { 17 | 18 | public static const filters:Array = [ 19 | "flash.filters::GlowFilter", 20 | "flash.filters::DropShadowFilter", 21 | "flash.filters::BlurFilter" 22 | ]; 23 | 24 | /** 创建滤镜 */ 25 | public static function createFilter(filterObjects:Object):FragmentFilter{ 26 | var filterName:String; 27 | var filterData:Object; 28 | var filter:FragmentFilter; 29 | for(filterName in filterObjects){ 30 | filterData = filterObjects[filterName]; 31 | 32 | switch(filterName){ 33 | case filters[0]://描边 34 | var glow:BlurFilter = new BlurFilter(filterData.blurX / 10, filterData.blurY / 10); 35 | glow.mode = FragmentFilterMode.BELOW; 36 | glow.setUniformColor(true, filterData.color, filterData.alpha); 37 | filter = glow; 38 | break; 39 | case filters[1]://阴影 40 | var dropShadow:BlurFilter = new BlurFilter(filterData.blurX / 10, filterData.blurY / 10); 41 | dropShadow.offsetX = Math.cos(filterData.angle) * filterData.distance; 42 | dropShadow.offsetY = Math.sin(filterData.angle) * filterData.distance; 43 | dropShadow.mode = FragmentFilterMode.BELOW; 44 | dropShadow.setUniformColor(true, filterData.color, filterData.alpha); 45 | filter = dropShadow; 46 | break; 47 | case filters[2]://模糊 48 | var blur:BlurFilter = new BlurFilter(filterData.blurX / 10, filterData.blurY / 10); 49 | filter = blur; 50 | break; 51 | } 52 | 53 | } 54 | return filter; 55 | } 56 | 57 | /** 创建文本的滤镜 */ 58 | public static function createTextFieldFilter(filterObjects:Object):Array{ 59 | var filters:Array = []; 60 | var filter:Object; 61 | var filterName:String; 62 | var filterClazz:Class; 63 | for(filterName in filterObjects){ 64 | filterClazz = getDefinitionByName(filterName) as Class; 65 | filter = new filterClazz(); 66 | 67 | setPropertys(filter,filterObjects[filterName]); 68 | filters.push(filter); 69 | } 70 | return filters.length > 0 ? filters : null; 71 | } 72 | 73 | private static function setPropertys(filter:Object,propertys:Object):void{ 74 | for(var key:String in propertys){ 75 | if(filter.hasOwnProperty(key)) filter[key] = propertys[key]; 76 | } 77 | } 78 | 79 | } 80 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/starling/util/EnterFrameFPSUtil.as: -------------------------------------------------------------------------------- 1 | package lzm.starling.util 2 | { 3 | import starling.events.EnterFrameEvent; 4 | 5 | /** 6 | * 当某个enterframe事件 需要用特定的帧率 而不是stage的帧率可以使用这个工具跳帧 7 | * @author zmliu 8 | * 9 | */ 10 | public class EnterFrameFPSUtil 11 | { 12 | 13 | private var fps:int; 14 | private var fpsTime:Number; 15 | private var currentTime:Number; 16 | 17 | public function EnterFrameFPSUtil(fps:int) 18 | { 19 | this.fps = fps; 20 | this.fpsTime = 1000 / this.fps * 0.001; 21 | this.currentTime = 0; 22 | } 23 | 24 | public function update(e:EnterFrameEvent):Boolean{ 25 | this.currentTime += e.passedTime; 26 | if(this.currentTime >= this.fpsTime){ 27 | this.currentTime -= this.fpsTime; 28 | if(this.currentTime > this.fpsTime){ 29 | this.currentTime = 0; 30 | } 31 | return true; 32 | } 33 | return false; 34 | } 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/util/AutoSkip.as: -------------------------------------------------------------------------------- 1 | package lzm.util 2 | { 3 | import flash.display.Stage; 4 | import flash.utils.getTimer; 5 | 6 | public class AutoSkip 7 | { 8 | private var lastTimer:int; 9 | private var deadLine:int; 10 | private var minContiguousFrames:int; 11 | private var maxContiguousSkips:int; 12 | private var framesRendered:int; 13 | private var framesSkipped:int; 14 | /** 15 | *一种模仿PCSX2的跳帧策略 16 | * @param deadLineRate 当两次调用之间时差高于标准值多少开始跳帧,推荐1.2以上 17 | * @param minContiguousFrames 进行跳帧前最少连续渲染了多少帧,推荐1以上 18 | * @param maxContiguousSkips 最多可以连续跳过的帧数,推荐1 19 | * 20 | */ 21 | public function AutoSkip(stage:Stage,deadLineRate:Number=1.20,minContiguousFrames:int=1,maxContiguousSkips:int=1){ 22 | super(); 23 | this.lastTimer=0; 24 | this.deadLine=Math.ceil((1000/stage.frameRate)*deadLineRate); 25 | this.minContiguousFrames=minContiguousFrames; 26 | this.maxContiguousSkips=maxContiguousSkips; 27 | framesRendered=0; 28 | framesSkipped=0; 29 | }//end of Function 30 | public function requestFrameSkip():Boolean{ 31 | var rt:Boolean = false; 32 | var timer:int = getTimer(); 33 | var dtTimer:int = timer-lastTimer; 34 | if(dtTimer>deadLine&&framesRendered>=minContiguousFrames&&framesSkipped 0 && oldHeight > 0) //检查元素高宽能不能正常 19 | { 20 | if (oldWidth / oldHeight >= limitWidth / limitHeight) { 21 | newWidth = limitWidth; 22 | newHeight = (oldHeight * limitWidth) / oldWidth; 23 | } else { 24 | newHeight = limitHeight; 25 | newWidth = (oldWidth * limitHeight) / oldHeight; 26 | } 27 | } else { 28 | newWidth = 0; 29 | newHeight = 0; 30 | } 31 | var obj:Object = {}; 32 | obj.sx = newWidth/oldWidth; 33 | obj.sy = newHeight/oldHeight; 34 | return obj; 35 | } 36 | 37 | /** 38 | * @param img 显示对象 39 | * @param oldWidth 原始宽度 40 | * @param oldHeight 原始高度 41 | * @param toWidth 目标宽度 42 | * @param toHeight 目标高度 43 | * @return 按比例缩放的最大值 44 | */ 45 | public static function doMaxScale(oldWidth:Number, oldHeight:Number, limitWidth:Number, limitHeight:Number):Number{ 46 | var sx:Number = limitWidth/oldWidth; 47 | var sy:Number = limitHeight/oldHeight; 48 | return sx > sy ? sx : sy; 49 | } 50 | 51 | /** 52 | * @param img 显示对象 53 | * @param oldWidth 原始宽度 54 | * @param oldHeight 原始高度 55 | * @param toWidth 目标宽度 56 | * @param toHeight 目标高度 57 | * @return 按比例缩放的最小值 58 | */ 59 | public static function doMinScale(oldWidth:Number, oldHeight:Number, limitWidth:Number, limitHeight:Number):Number{ 60 | var sx:Number = limitWidth/oldWidth; 61 | var sy:Number = limitHeight/oldHeight; 62 | return sx < sy ? sx : sy; 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/util/HttpClient.as: -------------------------------------------------------------------------------- 1 | package lzm.util 2 | { 3 | import flash.events.Event; 4 | import flash.events.HTTPStatusEvent; 5 | import flash.events.IOErrorEvent; 6 | import flash.net.URLLoader; 7 | import flash.net.URLRequest; 8 | import flash.net.URLRequestMethod; 9 | import flash.net.URLVariables; 10 | 11 | /** 12 | * http网络请求工具 13 | * @author lzm 14 | */ 15 | public class HttpClient 16 | { 17 | /** 18 | * 请求url 19 | * @param url 20 | * @param params 21 | * @param completeFunction 22 | * @param timeoutFunction 23 | * @param method 24 | * 25 | */ 26 | public static function send(url:String,params:Object,completeFunction:Function=null,timeoutFunction:Function=null,method:String="get"):void{ 27 | var request:URLRequest; 28 | if(method=="get"){ 29 | request = getRequest(url,params); 30 | }else if(method=="post"){ 31 | request = postRequest(url,params); 32 | } 33 | 34 | var loader:URLLoader = new URLLoader(); 35 | 36 | var callback:Function = function(e:Event):void{ 37 | loader.removeEventListener(Event.COMPLETE,callback); 38 | loader.removeEventListener(IOErrorEvent.IO_ERROR,timeout); 39 | loader.removeEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,status); 40 | if(completeFunction!=null){ 41 | completeFunction(loader.data); 42 | } 43 | }; 44 | 45 | var timeout:Function = function(e:Event):void{ 46 | loader.removeEventListener(Event.COMPLETE,callback); 47 | loader.removeEventListener(IOErrorEvent.IO_ERROR,timeout); 48 | loader.removeEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,status); 49 | if(timeoutFunction != null){ 50 | timeoutFunction(loader.data); 51 | } 52 | }; 53 | 54 | var status:Function = function(e:HTTPStatusEvent):void{} 55 | 56 | loader.addEventListener(Event.COMPLETE,callback); 57 | loader.addEventListener(IOErrorEvent.IO_ERROR,timeout); 58 | loader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS,status); 59 | 60 | loader.load(request); 61 | } 62 | 63 | 64 | private static function getRequest(url:String,params:Object):URLRequest{ 65 | url += "?" 66 | var k:String; 67 | for (k in params){ 68 | url += k+"="+params[k] + "&"; 69 | } 70 | return new URLRequest(url.substring(0,url.length-1)); 71 | } 72 | 73 | private static function postRequest(url:String,params:Object):URLRequest{ 74 | var data:URLVariables = new URLVariables(); 75 | var k:String; 76 | for (k in params){ 77 | data[k] = params[k]; 78 | } 79 | var request:URLRequest = new URLRequest(url); 80 | request.method = URLRequestMethod.POST; 81 | request.data = data; 82 | return request; 83 | } 84 | } 85 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/util/OSUtil.as: -------------------------------------------------------------------------------- 1 | package lzm.util 2 | { 3 | import flash.system.Capabilities; 4 | 5 | public class OSUtil 6 | { 7 | public static function isMac():Boolean{ 8 | return Capabilities.os.toLocaleUpperCase().indexOf("MAC") != -1; 9 | } 10 | 11 | public static function isWindows():Boolean{ 12 | return Capabilities.os.toLocaleUpperCase().indexOf("WIN") != -1; 13 | } 14 | 15 | public static function isAndriod():Boolean{ 16 | return Capabilities.os.toLocaleUpperCase().indexOf("ANDROID") != -1; 17 | } 18 | 19 | public static function isIPhone():Boolean{ 20 | return Capabilities.os.toLocaleUpperCase().indexOf("IPHONE") != -1; 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/util/ParticlePool.as: -------------------------------------------------------------------------------- 1 | package lzm.util 2 | { 3 | import extend.particlesystem.PDParticleSystem; 4 | 5 | import starling.textures.Texture; 6 | 7 | public class ParticlePool 8 | { 9 | 10 | private static var _pool:Object = new Object(); 11 | 12 | /** 13 | * 获取一个粒子效果 14 | * */ 15 | public static function getParticle(name:String,xml:XML,texture:Texture):PDParticleSystem{ 16 | var particleArray:Vector. = _pool[name]; 17 | if(particleArray == null || particleArray.length == 0){ 18 | var particle:PDParticleSystem = new PDParticleSystem(xml,texture); 19 | particle.name = name; 20 | return particle; 21 | } 22 | return particleArray.shift(); 23 | } 24 | 25 | /** 26 | * 归还一个粒子效果 27 | * */ 28 | public static function returnParticle(particle:PDParticleSystem):void{ 29 | particle.stop(true); 30 | particle.removeFromParent(); 31 | 32 | var particleArray:Vector. = _pool[particle.name]; 33 | if(particleArray == null){ 34 | particleArray = new Vector.(); 35 | } 36 | particleArray.push(particle); 37 | _pool[particle.name] = particleArray; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/lzm/util/TimeUtil.as: -------------------------------------------------------------------------------- 1 | package lzm.util 2 | { 3 | import starling.utils.formatString; 4 | 5 | public class TimeUtil 6 | { 7 | /** 8 | * 将秒数转换为时间 9 | * @param s 10 | * 11 | */ 12 | public static function convertStringToDate(s:int):String{ 13 | if(s <= 0){ 14 | return "00:00:00"; 15 | } 16 | var h:int = s / (60*60); 17 | var hStr:String = h+""; 18 | hStr = hStr.length > 1 ? hStr : "0"+hStr; 19 | 20 | s -= h * (60 * 60); 21 | var m:int = s / 60; 22 | var mStr:String = m+""; 23 | mStr = mStr.length > 1 ? mStr : "0"+mStr; 24 | 25 | s -= m * 60; 26 | var sStr:String = s+""; 27 | sStr = sStr.length > 1 ? sStr : "0"+sStr; 28 | 29 | return hStr+":"+mStr+":"+sStr; 30 | } 31 | 32 | /** 33 | * 将秒数转换为时间 34 | * @param s 35 | * 36 | */ 37 | public static function convertStringToDate2(s:int):String{ 38 | if(s <= 0){ 39 | return "00:00:00"; 40 | } 41 | var h:int = s / (60*60); 42 | var hStr:String = h+""; 43 | hStr = hStr.length > 1 ? hStr : "0"+hStr; 44 | 45 | s -= h * (60 * 60); 46 | var m:int = s / 60; 47 | var mStr:String = m+""; 48 | mStr = mStr.length > 1 ? mStr : "0"+mStr; 49 | 50 | s -= m * 60; 51 | var sStr:String = s+""; 52 | sStr = sStr.length > 1 ? sStr : "0"+sStr; 53 | 54 | var d:int = h/24; 55 | h -= d*24; 56 | 57 | if(d > 0){ 58 | return formatString("{0}天 {1}小时 {2}分",d,h,m); 59 | }else if(h > 0){ 60 | return formatString("{0}小时 {1}分",h,m); 61 | }else if(m > 0){ 62 | return formatString("{0}分 {1}秒",m,s); 63 | }else{ 64 | return formatString("{0}秒",s); 65 | } 66 | } 67 | 68 | public static function parseString(dataString:String):Date{ 69 | var arr:Array = dataString.split(" "); 70 | var arr1:Array = arr[0].split("-"); 71 | var arr2:Array = arr[1].split(":"); 72 | 73 | return new Date(arr1[0],arr1[1],arr1[2],arr2[0],arr2[1],arr2[2]); 74 | } 75 | } 76 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/animation/IAnimatable.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.animation 12 | { 13 | /** The IAnimatable interface describes objects that are animated depending on the passed time. 14 | * Any object that implements this interface can be added to a juggler. 15 | * 16 | *

When an object should no longer be animated, it has to be removed from the juggler. 17 | * To do this, you can manually remove it via the method juggler.remove(object), 18 | * or the object can request to be removed by dispatching a Starling event with the type 19 | * Event.REMOVE_FROM_JUGGLER. The "Tween" class is an example of a class that 20 | * dispatches such an event; you don't have to remove tweens manually from the juggler.

21 | * 22 | * @see Juggler 23 | * @see Tween 24 | */ 25 | public interface IAnimatable 26 | { 27 | /** Advance the time by a number of seconds. @param time in seconds. */ 28 | function advanceTime(time:Number):void; 29 | } 30 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/core/starling_internal.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.core 12 | { 13 | /** 14 | * This namespace is used for undocumented APIs -- usually implementation 15 | * details -- which can't be private because they need to visible 16 | * to other classes. 17 | * 18 | * APIs in this namespace are completely unsupported and are likely to 19 | * change in future versions of Starling. 20 | */ 21 | public namespace starling_internal; 22 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/ButtonState.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2014 Gamua GmbH. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.display 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** A class that provides constant values for the states of the Button class. */ 16 | public class ButtonState 17 | { 18 | /** @private */ 19 | public function ButtonState() { throw new AbstractClassError(); } 20 | 21 | /** The button's default state. */ 22 | public static const UP:String = "up"; 23 | 24 | /** The button is pressed. */ 25 | public static const DOWN:String = "down"; 26 | 27 | /** The mouse hovers over the button. */ 28 | public static const OVER:String = "over"; 29 | 30 | /** The button was disabled altogether. */ 31 | public static const DISABLED:String = "disabled"; 32 | } 33 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsEndFill.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | /** 4 | * ... 5 | * Implementation of GraphicsEndFill 6 | */ 7 | public class GraphicsEndFill implements IGraphicsData 8 | { 9 | 10 | public function GraphicsEndFill() 11 | { 12 | 13 | } 14 | 15 | } 16 | 17 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsLine.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | 4 | /** 5 | * ... 6 | * API-breaking class GraphicsLine, allowing for line thickness, color, alpha on line segments. 7 | */ 8 | public class GraphicsLine implements IGraphicsData 9 | { 10 | protected var mThickness:Number = NaN; 11 | protected var mColor:int = 0; 12 | protected var mAlpha:Number = 1.0; 13 | 14 | public function GraphicsLine(thickness:Number = NaN, color:int = 0, alpha:Number = 1.0 ) 15 | { 16 | mThickness = thickness; 17 | mColor = color; 18 | mAlpha = alpha; 19 | } 20 | 21 | public function get thickness() : Number 22 | { 23 | return mThickness; 24 | } 25 | 26 | public function get color() : int 27 | { 28 | return mColor; 29 | } 30 | 31 | public function get alpha() : Number 32 | { 33 | return mAlpha; 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsMaterialFill.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | import starling.display.IGraphicsData; 4 | import starling.display.materials.IMaterial; 5 | import flash.geom.Matrix; 6 | 7 | /** 8 | * ... 9 | * @author Henrik Jonsson 10 | */ 11 | public class GraphicsMaterialFill implements IGraphicsData 12 | { 13 | protected var mMaterial:IMaterial; 14 | protected var mMatrix:Matrix; 15 | 16 | public function GraphicsMaterialFill(material:IMaterial, uvMatrix:Matrix = null ) 17 | { 18 | mMaterial = material; 19 | mMatrix = uvMatrix; 20 | } 21 | 22 | public function get material() : IMaterial 23 | { 24 | return mMaterial; 25 | } 26 | 27 | public function get matrix() : Matrix 28 | { 29 | return mMatrix; 30 | } 31 | } 32 | 33 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsPath.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | /** 4 | * ... 5 | * An implementation of flash.graphics.GraphicsPath 6 | */ 7 | public class GraphicsPath implements IGraphicsData 8 | { 9 | protected var mCommands:Vector.; 10 | protected var mData:Vector.; 11 | protected var mWinding:String; 12 | 13 | public function GraphicsPath(commands:Vector. = null, data:Vector. = null, winding:String = "evenOdd") 14 | { 15 | mCommands = commands; 16 | mData = data; 17 | mWinding = winding; 18 | 19 | if ( mCommands == null ) 20 | mCommands = new Vector.(); 21 | if ( mData == null ) 22 | mData = new Vector.(); 23 | } 24 | 25 | public function get data() : Vector. 26 | { 27 | return mData; 28 | } 29 | 30 | public function get commands() : Vector. 31 | { 32 | return mCommands; 33 | } 34 | 35 | public function get winding() : String 36 | { 37 | return mWinding; 38 | } 39 | 40 | public function set winding(value:String) : void 41 | { 42 | mWinding = value; 43 | } 44 | 45 | public function curveTo(controlX:Number, controlY:Number, anchorX:Number, anchorY:Number):void 46 | { 47 | mCommands.push(GraphicsPathCommands.CURVE_TO); 48 | mData.push(controlX, controlY, anchorX, anchorY); 49 | } 50 | 51 | public function lineTo(x:Number, y:Number):void 52 | { 53 | mCommands.push(GraphicsPathCommands.LINE_TO); 54 | mData.push(x, y); 55 | } 56 | 57 | public function moveTo(x:Number, y:Number):void 58 | { 59 | mCommands.push(GraphicsPathCommands.MOVE_TO); 60 | mData.push(x, y); 61 | } 62 | 63 | public function wideLineTo(x:Number, y:Number):void 64 | { 65 | mCommands.push(GraphicsPathCommands.WIDE_LINE_TO); 66 | mData.push(x, y); 67 | } 68 | 69 | public function wideMoveTo(x:Number, y:Number):void 70 | { 71 | mCommands.push(GraphicsPathCommands.WIDE_MOVE_TO); 72 | mData.push(x, y); 73 | } 74 | 75 | } 76 | 77 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsPathCommands.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | /** 4 | * ... 5 | * Porting the GraphicsPathCommands to Starling Extension Graphics 6 | */ 7 | public class GraphicsPathCommands 8 | { 9 | public static const NO_OP:int = 0; 10 | public static const MOVE_TO:int = 1; 11 | public static const LINE_TO:int = 2; 12 | public static const CURVE_TO:int = 3; 13 | public static const WIDE_MOVE_TO:int = 4; 14 | public static const WIDE_LINE_TO:int = 5; 15 | public static const CUBIC_CURVE_TO:int = 6; 16 | 17 | public function GraphicsPathCommands() 18 | { 19 | 20 | } 21 | 22 | } 23 | 24 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsSolidFill.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | import starling.display.IGraphicsData; 4 | import starling.display.materials.IMaterial; 5 | import flash.geom.Matrix; 6 | 7 | 8 | public class GraphicsSolidFill implements IGraphicsData 9 | { 10 | protected var mColor:uint; 11 | protected var mAlpha:Number; 12 | 13 | public function GraphicsSolidFill(color:uint, alpha:Number ) 14 | { 15 | mColor = color; 16 | mAlpha = alpha; 17 | } 18 | 19 | public function get color() : uint 20 | { 21 | return mColor; 22 | } 23 | 24 | public function get alpha() : Number 25 | { 26 | return mAlpha; 27 | } 28 | } 29 | 30 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/GraphicsTextureFill.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | import starling.textures.Texture; 4 | import flash.geom.Matrix; 5 | 6 | /** 7 | * ... 8 | * @author Henrik Jonsson 9 | */ 10 | public class GraphicsTextureFill implements IGraphicsData 11 | { 12 | protected var mTexture:Texture; 13 | protected var mMatrix:Matrix; 14 | 15 | public function GraphicsTextureFill(texture:Texture, matrix:Matrix = null ) 16 | { 17 | mTexture = texture; 18 | mMatrix = matrix; 19 | } 20 | 21 | public function get texture() : Texture 22 | { 23 | return mTexture; 24 | } 25 | 26 | public function get matrix() : Matrix 27 | { 28 | return mMatrix; 29 | } 30 | } 31 | 32 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/IGraphicsData.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | 4 | /** 5 | * ... 6 | * 7 | */ 8 | public interface IGraphicsData 9 | { 10 | 11 | 12 | 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/IGraphicsFill.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | 4 | /** 5 | * ... 6 | * Rudimentary IGraphicsFill 7 | */ 8 | public interface IGraphicsFill 9 | { 10 | 11 | } 12 | 13 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/Shape.as: -------------------------------------------------------------------------------- 1 | package starling.display 2 | { 3 | import starling.display.Graphics; 4 | 5 | public class Shape extends DisplayObjectContainer 6 | { 7 | private var _graphics :Graphics; 8 | 9 | public function Shape() 10 | { 11 | _graphics = new Graphics(this); 12 | } 13 | 14 | public function get graphics():Graphics 15 | { 16 | return _graphics; 17 | } 18 | 19 | /* override public function dispose() : void 20 | { 21 | if ( _graphics != null ) 22 | { 23 | _graphics.dispose(); 24 | _graphics = null; 25 | } 26 | super.dispose(); 27 | } */ 28 | } 29 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphics/StrokeVertex.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphics 2 | { 3 | 4 | public class StrokeVertex 5 | { 6 | public var x:Number; 7 | public var y:Number; 8 | public var u:Number; 9 | public var v:Number; 10 | public var r1:Number; 11 | public var g1:Number; 12 | public var b1:Number; 13 | public var a1:Number; 14 | public var r2:Number; 15 | public var g2:Number; 16 | public var b2:Number; 17 | public var a2:Number; 18 | public var thickness:Number; 19 | public var degenerate:uint; 20 | 21 | public function StrokeVertex() 22 | { 23 | 24 | } 25 | 26 | public function clone():StrokeVertex 27 | { 28 | var vertex:StrokeVertex = getInstance(); 29 | vertex.x = x; 30 | vertex.y = y; 31 | vertex.r1 = r1; 32 | vertex.g1 = g1; 33 | vertex.b1 = b1; 34 | vertex.a1 = a1; 35 | vertex.u = u; 36 | vertex.v = v; 37 | vertex.degenerate = degenerate; 38 | return vertex; 39 | } 40 | 41 | private static var pool:Vector. = new Vector.(); 42 | private static var poolLength:int = 0; 43 | 44 | public static function getInstance():StrokeVertex 45 | { 46 | if (poolLength == 0) 47 | { 48 | return new StrokeVertex(); 49 | } 50 | poolLength--; 51 | return pool.pop(); 52 | } 53 | 54 | public static function returnInstance(instance:StrokeVertex):void 55 | { 56 | pool[poolLength] = instance; 57 | poolLength++; 58 | } 59 | 60 | public static function returnInstances(instances:Vector.):void 61 | { 62 | var L:int = instances.length; 63 | for (var i:int = 0; i < L; i++) 64 | { 65 | pool[poolLength] = instances[i]; 66 | poolLength++; 67 | } 68 | } 69 | } 70 | 71 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphics/TriangleFan.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphics 2 | { 3 | import starling.core.RenderSupport; 4 | import starling.core.Starling; 5 | import starling.textures.Texture; 6 | 7 | public class TriangleFan extends Graphic 8 | { 9 | private var numVertices :int; 10 | 11 | public function TriangleFan() 12 | { 13 | vertices.push(0,0,0,1,1,1,1,0,0); 14 | numVertices++; 15 | } 16 | 17 | public function addVertex( x:Number, y:Number, u:Number = 0, v:Number = 0, r:Number = 1, g:Number = 1, b:Number = 1, a:Number = 1 ):void 18 | { 19 | vertices.push( x, y, 0, r, g, b, a, u, v ); 20 | numVertices++; 21 | 22 | minBounds.x = x < minBounds.x ? x : minBounds.x; 23 | minBounds.y = y < minBounds.y ? y : minBounds.y; 24 | maxBounds.x = x > maxBounds.x ? x : maxBounds.x; 25 | maxBounds.y = y > maxBounds.y ? y : maxBounds.y; 26 | 27 | if ( numVertices > 2 ) 28 | { 29 | indices.push( 0, numVertices-2, numVertices-1 ); 30 | } 31 | 32 | setGeometryInvalid(); 33 | } 34 | 35 | public function modifyVertexPosition(index:int, x:Number, y:Number) : void 36 | { 37 | vertices[index * 9] = x; 38 | vertices[index * 9 + 1] = y; 39 | 40 | if ( isInvalid == false ) 41 | setGeometryInvalid(); 42 | } 43 | 44 | public function clear():void 45 | { 46 | vertices.length = 0; 47 | indices.length = 0; 48 | numVertices = 0; 49 | setGeometryInvalid(); 50 | } 51 | 52 | override protected function buildGeometry():void 53 | { 54 | 55 | } 56 | } 57 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphicsEx/GraphicsExColorData.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphicsEx 2 | { 3 | 4 | public class GraphicsExColorData 5 | { 6 | // Parameters to control alpha and color along the segment 7 | public var endAlpha:Number = 1.0; 8 | public var endRed:int = 0xFF; 9 | public var endGreen:int = 0xFF; 10 | public var endBlue:int = 0xFF; 11 | 12 | public var startAlpha:Number = 1.0; 13 | public var startRed:int = 0xFF; 14 | public var startGreen:int = 0xFF; 15 | public var startBlue:int = 0xFF; 16 | 17 | public var colorCallback:Function = null; // Color callback not yet supported 18 | public var alphaCallback:Function = null; // Alpha callback not yet supported 19 | 20 | 21 | public function GraphicsExColorData(startColor:uint = 0xFFFFFF, endColor:uint = 0xFFFFFF, sAlpha:Number = 1.0, eAlpha:Number = 1.0, colorFunc:Function = null, alphaFunc:Function = null) 22 | { 23 | endAlpha = eAlpha; 24 | endRed = (( endColor >> 16 ) & 0xFF); 25 | endGreen = ( (endColor >> 8) & 0xFF ); 26 | endBlue = ( endColor & 0xFF ); 27 | 28 | startAlpha = sAlpha; 29 | 30 | startRed = (( startColor >> 16 ) & 0xFF); 31 | startGreen = ( (startColor >> 8) & 0xFF ); 32 | startBlue = ( startColor & 0xFF ); 33 | 34 | colorCallback = colorFunc; 35 | alphaCallback = alphaFunc; 36 | 37 | } 38 | 39 | public function clone() : GraphicsExColorData 40 | { 41 | var c:GraphicsExColorData = new GraphicsExColorData(); 42 | 43 | c.endAlpha = endAlpha; 44 | c.endRed = endRed; 45 | c.endGreen = endGreen; 46 | c.endBlue = endBlue; 47 | 48 | c.startAlpha = startAlpha; 49 | c.startRed = startRed; 50 | c.startGreen = startGreen; 51 | c.startBlue = startBlue; 52 | 53 | c.alphaCallback = alphaCallback; 54 | 55 | c.colorCallback = colorCallback; 56 | 57 | return c; 58 | } 59 | } 60 | 61 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphicsEx/GraphicsExThicknessData.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphicsEx 2 | { 3 | 4 | public class GraphicsExThicknessData 5 | { 6 | 7 | // Parameters to control thickness along the segment 8 | public var startThickness:Number = -1; 9 | public var endThickness:Number = -1; 10 | public var thicknessCallback:Function = null; // Callback function not yet supported 11 | 12 | public function GraphicsExThicknessData(sThick:int, eThick:int, callback:Function = null ) 13 | { 14 | startThickness = sThick; 15 | endThickness = eThick; 16 | thicknessCallback = callback; 17 | } 18 | 19 | public function clone() : GraphicsExThicknessData 20 | { 21 | var c:GraphicsExThicknessData = new GraphicsExThicknessData(startThickness, endThickness, thicknessCallback); 22 | 23 | return c; 24 | } 25 | } 26 | 27 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphicsEx/GraphicsNaturalSpline.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphicsEx 2 | { 3 | import starling.display.GraphicsPathCommands; 4 | import starling.display.IGraphicsData; 5 | 6 | /** 7 | * ... 8 | * Making the spline usable for GraphicsPath as well 9 | */ 10 | 11 | public class GraphicsNaturalSpline implements IGraphicsData 12 | { 13 | protected var mControlPoints:Array; 14 | protected var mClosed:Boolean; 15 | protected var mSteps:int; 16 | 17 | public function GraphicsNaturalSpline(controlPoints:Array = null, closed:Boolean = false, steps:int = 4) 18 | { 19 | mControlPoints = controlPoints; 20 | mClosed = closed ; 21 | mSteps = steps; 22 | if ( mControlPoints == null ) 23 | mControlPoints = []; 24 | } 25 | 26 | public function get controlPoints() : Array 27 | { 28 | return mControlPoints; 29 | } 30 | 31 | public function get closed() :Boolean 32 | { 33 | return mClosed; 34 | } 35 | 36 | public function get steps() : int 37 | { 38 | return mSteps; 39 | } 40 | 41 | } 42 | 43 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphicsEx/ShapeEx.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphicsEx 2 | { 3 | import starling.display.Graphics; 4 | import starling.display.DisplayObjectContainer; 5 | 6 | public class ShapeEx extends DisplayObjectContainer 7 | { 8 | private var _graphics :GraphicsEx; 9 | 10 | public function ShapeEx() 11 | { 12 | _graphics = new GraphicsEx(this); 13 | } 14 | 15 | public function get graphics():GraphicsEx 16 | { 17 | return _graphics; 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/graphicsEx/StrokeEx.as: -------------------------------------------------------------------------------- 1 | package starling.display.graphicsEx 2 | { 3 | import flash.display.GraphicsStroke; 4 | import starling.textures.Texture; 5 | import starling.display.graphics.Stroke; 6 | import starling.display.graphics.StrokeVertex; 7 | 8 | public class StrokeEx extends Stroke 9 | { 10 | protected var _lineLength:Number = 0; 11 | 12 | public function StrokeEx() 13 | { 14 | super(); 15 | } 16 | 17 | // Added to support post processing 18 | public function get strokeVertices() : Vector. 19 | { 20 | return _line; 21 | } 22 | 23 | override public function clear() : void 24 | { 25 | super.clear(); 26 | _lineLength = 0; 27 | } 28 | 29 | public function invalidate() : void 30 | { 31 | isInvalid = true; 32 | } 33 | 34 | public function strokeLength() : Number 35 | { 36 | if ( _lineLength == 0 ) 37 | { 38 | if ( _line == null || _line.length < 2 ) 39 | return 0; 40 | else 41 | return calcStrokeLength(); 42 | } 43 | else 44 | return _lineLength; 45 | } 46 | 47 | protected function calcStrokeLength() : Number 48 | { 49 | if ( _line == null || _line.length < 2 ) 50 | _lineLength = 0; 51 | else 52 | { 53 | var i:int = 1; 54 | var prevVertex:StrokeVertex = _line[0]; 55 | var thisVertex:StrokeVertex = null; 56 | 57 | for ( i = 1 ; i < _numVertices; ++i ) 58 | { 59 | thisVertex = _line[i]; 60 | 61 | var dx:Number = thisVertex.x - prevVertex.x; 62 | var dy:Number = thisVertex.y - prevVertex.y; 63 | var d:Number = Math.sqrt(dx * dx + dy * dy); 64 | _lineLength += d; 65 | prevVertex = thisVertex; 66 | } 67 | } 68 | return _lineLength; 69 | } 70 | } 71 | 72 | } 73 | -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/materials/FlatColorMaterial.as: -------------------------------------------------------------------------------- 1 | package starling.display.materials 2 | { 3 | import starling.display.shaders.IShader; 4 | 5 | public class FlatColorMaterial extends StandardMaterial 6 | { 7 | public function FlatColorMaterial(color:uint = 0xFFFFFF) 8 | { 9 | this.color = color; 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/materials/IMaterial.as: -------------------------------------------------------------------------------- 1 | package starling.display.materials 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.display3D.IndexBuffer3D; 5 | import flash.display3D.VertexBuffer3D; 6 | import flash.geom.Matrix3D; 7 | 8 | import starling.display.shaders.IShader; 9 | import starling.textures.Texture; 10 | 11 | public interface IMaterial 12 | { 13 | function dispose():void 14 | function set alpha(value:Number):void; 15 | function get alpha():Number; 16 | function set color(value:uint):void; 17 | function get color():uint; 18 | function set vertexShader( value:IShader ):void; 19 | function get vertexShader():IShader; 20 | function set fragmentShader( value:IShader ):void 21 | function get fragmentShader():IShader; 22 | function get textures():Vector.; 23 | function set textures(value:Vector.):void; 24 | function drawTriangles( context:Context3D, matrix:Matrix3D, vertexBuffer:VertexBuffer3D, indexBuffer:IndexBuffer3D, alpha:Number = 1, numTriangles:int = -1 ):void; 25 | function restoreOnLostContext():void; 26 | } 27 | 28 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/materials/TextureMaterial.as: -------------------------------------------------------------------------------- 1 | package starling.display.materials 2 | { 3 | import starling.display.shaders.IShader; 4 | import starling.display.shaders.fragment.TextureFragmentShader; 5 | import starling.display.shaders.fragment.TextureVertexColorFragmentShader; 6 | import starling.display.shaders.fragment.VertexColorFragmentShader; 7 | import starling.display.shaders.vertex.StandardVertexShader; 8 | import starling.textures.Texture; 9 | 10 | public class TextureMaterial extends StandardMaterial 11 | { 12 | public function TextureMaterial(texture:Texture, color:uint = 0xFFFFFF) 13 | { 14 | super(new StandardVertexShader(), new TextureVertexColorFragmentShader()); 15 | textures[0] = texture; 16 | this.color = color; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/AbstractShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders 2 | { 3 | import com.adobe.utils.AGALMiniAssembler; 4 | 5 | import flash.display3D.Context3D; 6 | import flash.display3D.Context3DProgramType; 7 | import flash.utils.ByteArray; 8 | 9 | public class AbstractShader implements IShader 10 | { 11 | private static var assembler:AGALMiniAssembler; 12 | 13 | protected var _opCode :ByteArray; 14 | 15 | public function AbstractShader() 16 | { 17 | 18 | } 19 | 20 | protected function compileAGAL( shaderType:String, agal:String ):void 21 | { 22 | if ( assembler == null ) 23 | { 24 | assembler = new AGALMiniAssembler(); 25 | } 26 | assembler.assemble( shaderType, agal ); 27 | _opCode = assembler.agalcode; 28 | } 29 | 30 | public function get opCode():ByteArray 31 | { 32 | return _opCode; 33 | } 34 | 35 | public function setConstants( context:Context3D, firstRegister:int ):void 36 | { 37 | 38 | } 39 | } 40 | 41 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/IShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.utils.ByteArray; 5 | 6 | public interface IShader 7 | { 8 | function get opCode():ByteArray 9 | function setConstants( context:Context3D, firstRegister:int ):void 10 | } 11 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/fragment/TextureFragmentShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders.fragment 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.display3D.Context3DProgramType; 5 | import flash.display3D.textures.Texture; 6 | 7 | import starling.display.shaders.AbstractShader; 8 | 9 | /* 10 | * A pixel shader that multiplies a single texture with constants (the color transform). 11 | */ 12 | public class TextureFragmentShader extends AbstractShader 13 | { 14 | public function TextureFragmentShader() 15 | { 16 | var agal:String = 17 | "tex ft1, v1, fs0 <2d, repeat, linear> \n" + 18 | "mul oc, ft1, fc0"; 19 | 20 | compileAGAL( Context3DProgramType.FRAGMENT, agal ); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/fragment/TextureVertexColorFragmentShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders.fragment 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.display3D.Context3DProgramType; 5 | import flash.display3D.textures.Texture; 6 | 7 | import starling.display.shaders.AbstractShader; 8 | 9 | /* 10 | * A pixel shader that multiplies a single texture with constants (the color transform) and vertex color 11 | */ 12 | public class TextureVertexColorFragmentShader extends AbstractShader 13 | { 14 | public function TextureVertexColorFragmentShader() 15 | { 16 | var agal:String = 17 | "tex ft1, v1, fs0 <2d, repeat, linear> \n" + 18 | "mul ft2, v0, fc0 \n" + 19 | "mul oc, ft1, ft2" 20 | 21 | compileAGAL( Context3DProgramType.FRAGMENT, agal ); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/fragment/VertexColorFragmentShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders.fragment 2 | { 3 | import flash.display3D.Context3DProgramType; 4 | 5 | import starling.display.shaders.AbstractShader; 6 | 7 | /* 8 | * A pixel shader that multiplies the vertex color by the material color transform. 9 | */ 10 | public class VertexColorFragmentShader extends AbstractShader 11 | { 12 | public function VertexColorFragmentShader() 13 | { 14 | var agal:String = "mul oc, v0, fc0"; 15 | compileAGAL( Context3DProgramType.FRAGMENT, agal ); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/vertex/AnimateUVVertexShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders.vertex 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.display3D.Context3DProgramType; 5 | import flash.utils.getTimer; 6 | 7 | import starling.display.shaders.AbstractShader; 8 | 9 | public class AnimateUVVertexShader extends AbstractShader 10 | { 11 | public var uSpeed :Number = 1; 12 | public var vSpeed :Number = 1; 13 | 14 | public function AnimateUVVertexShader( uSpeed:Number = 1, vSpeed:Number = 1 ) 15 | { 16 | this.uSpeed = uSpeed; 17 | this.vSpeed = vSpeed; 18 | 19 | var agal:String = 20 | "m44 op, va0, vc0 \n" + // Apply matrix 21 | "mov v0, va1 \n" + // Copy color to v0 22 | "sub vt0, va2, vc4 \n" + 23 | "mov v1, vt0 \n" 24 | 25 | compileAGAL( Context3DProgramType.VERTEX, agal ); 26 | } 27 | 28 | override public function setConstants( context:Context3D, firstRegister:int ):void 29 | { 30 | var phase:Number = getTimer()/1000; 31 | var uOffset:Number = phase * uSpeed; 32 | var vOffset:Number = phase * vSpeed; 33 | 34 | context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, firstRegister, Vector.([ uOffset, vOffset, 0, 0 ]) ); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/vertex/RippleVertexShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders.vertex 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.display3D.Context3DProgramType; 5 | import flash.utils.getTimer; 6 | import starling.display.shaders.AbstractShader; 7 | 8 | public class RippleVertexShader extends AbstractShader 9 | { 10 | public function RippleVertexShader() 11 | { 12 | var agal:String = 13 | "mul vt0, va0.x, vc4.y \n" + // Calculate vert.x * frequency. Store in 0 14 | "add vt1, vc4.x, vt0 \n" + // Calculate phase + scaledX. Store in 1 15 | "sin vt2, vt1 \n" + 16 | "mul vt3, vt2, vc4.z \n" + 17 | "add vt4, va0.y, vt3 \n" + 18 | "mov vt5, va0 \n" + 19 | "mov vt5.y, vt4 \n" + 20 | 21 | "m44 op, vt5, vc0 \n" + // Apply view matrix 22 | 23 | "mov v0, va1 \n" + // Copy color to v0 24 | "mov v1, va2 \n" // Copy UV to v1 25 | 26 | compileAGAL( Context3DProgramType.VERTEX, agal ); 27 | } 28 | 29 | override public function setConstants( context:Context3D, firstRegister:int ):void 30 | { 31 | var phase:Number = getTimer()/200; 32 | var frequency:Number = 0.02; 33 | var amplitude:Number = 5; 34 | context.setProgramConstantsFromVector( Context3DProgramType.VERTEX, firstRegister, Vector.([ phase, frequency, amplitude, 1 ]) ); 35 | } 36 | } 37 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/display/shaders/vertex/StandardVertexShader.as: -------------------------------------------------------------------------------- 1 | package starling.display.shaders.vertex 2 | { 3 | import flash.display3D.Context3DProgramType; 4 | import starling.display.shaders.AbstractShader; 5 | 6 | public class StandardVertexShader extends AbstractShader 7 | { 8 | public function StandardVertexShader() 9 | { 10 | var agal:String = 11 | "m44 op, va0, vc0 \n" + // Apply matrix 12 | "mov v0, va1 \n" + // Copy color to v0 13 | "mov v1, va2 \n" // Copy UV to v1 14 | 15 | compileAGAL( Context3DProgramType.VERTEX, agal ); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/errors/AbstractClassError.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.errors 12 | { 13 | /** An AbstractClassError is thrown when you attempt to create an instance of an abstract 14 | * class. */ 15 | public class AbstractClassError extends Error 16 | { 17 | /** Creates a new AbstractClassError object. */ 18 | public function AbstractClassError(message:*="Cannot instantiate abstract class", id:*=0) 19 | { 20 | super(message, id); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/errors/AbstractMethodError.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.errors 12 | { 13 | /** An AbstractMethodError is thrown when you attempt to call an abstract method. */ 14 | public class AbstractMethodError extends Error 15 | { 16 | /** Creates a new AbstractMethodError object. */ 17 | public function AbstractMethodError(message:*="Method needs to be implemented in subclass", id:*=0) 18 | { 19 | super(message, id); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/errors/MissingContextError.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.errors 12 | { 13 | /** A MissingContextError is thrown when a Context3D object is required but not (yet) 14 | * available. */ 15 | public class MissingContextError extends Error 16 | { 17 | /** Creates a new MissingContextError object. */ 18 | public function MissingContextError(message:*="Starling context is missing", id:*=0) 19 | { 20 | super(message, id); 21 | } 22 | } 23 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/errors/NotSupportedError.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2015 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.errors 12 | { 13 | /** A NotSupportedError is thrown when you attempt to use a feature that is not supported 14 | * on the current platform. */ 15 | public class NotSupportedError extends Error 16 | { 17 | /** Creates a new NotSupportedError object. */ 18 | public function NotSupportedError(message:* = "", id:* = 0) 19 | { 20 | super(message, id); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/events/EnterFrameEvent.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.events 12 | { 13 | /** An EnterFrameEvent is triggered once per frame and is dispatched to all objects in the 14 | * display tree. 15 | * 16 | * It contains information about the time that has passed since the last frame. That way, you 17 | * can easily make animations that are independent of the frame rate, taking the passed time 18 | * into account. 19 | */ 20 | public class EnterFrameEvent extends Event 21 | { 22 | /** Event type for a display object that is entering a new frame. */ 23 | public static const ENTER_FRAME:String = "enterFrame"; 24 | 25 | /** Creates an enter frame event with the passed time. */ 26 | public function EnterFrameEvent(type:String, passedTime:Number, bubbles:Boolean=false) 27 | { 28 | super(type, bubbles, passedTime); 29 | } 30 | 31 | /** The time that has passed since the last frame (in seconds). */ 32 | public function get passedTime():Number { return data as Number; } 33 | } 34 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/events/ResizeEvent.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.events 12 | { 13 | import flash.geom.Point; 14 | 15 | /** A ResizeEvent is dispatched by the stage when the size of the Flash container changes. 16 | * Use it to update the Starling viewport and the stage size. 17 | * 18 | *

The event contains properties containing the updated width and height of the Flash 19 | * player. If you want to scale the contents of your stage to fill the screen, update the 20 | * Starling.current.viewPort rectangle accordingly. If you want to make use of 21 | * the additional screen estate, update the values of stage.stageWidth and 22 | * stage.stageHeight as well.

23 | * 24 | * @see starling.display.Stage 25 | * @see starling.core.Starling 26 | */ 27 | public class ResizeEvent extends Event 28 | { 29 | /** Event type for a resized Flash player. */ 30 | public static const RESIZE:String = "resize"; 31 | 32 | /** Creates a new ResizeEvent. */ 33 | public function ResizeEvent(type:String, width:int, height:int, bubbles:Boolean=false) 34 | { 35 | super(type, bubbles, new Point(width, height)); 36 | } 37 | 38 | /** The updated width of the player. */ 39 | public function get width():int { return (data as Point).x; } 40 | 41 | /** The updated height of the player. */ 42 | public function get height():int { return (data as Point).y; } 43 | } 44 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/events/TouchPhase.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.events 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** A class that provides constant values for the phases of a touch object. 16 | * 17 | *

A touch moves through at least the following phases in its life:

18 | * 19 | * BEGAN -> MOVED -> ENDED 20 | * 21 | *

Furthermore, a touch can enter a STATIONARY phase. That phase does not 22 | * trigger a touch event itself, and it can only occur in multitouch environments. Picture a 23 | * situation where one finger is moving and the other is stationary. A touch event will 24 | * be dispatched only to the object under the moving finger. In the list of touches 25 | * of that event, you will find the second touch in the stationary phase.

26 | * 27 | *

Finally, there's the HOVER phase, which is exclusive to mouse input. It is 28 | * the equivalent of a MouseOver event in Flash when the mouse button is 29 | * not pressed.

30 | */ 31 | public final class TouchPhase 32 | { 33 | /** @private */ 34 | public function TouchPhase() { throw new AbstractClassError(); } 35 | 36 | /** Only available for mouse input: the cursor hovers over an object without a 37 | * pressed button. */ 38 | public static const HOVER:String = "hover"; 39 | 40 | /** The finger touched the screen just now, or the mouse button was pressed. */ 41 | public static const BEGAN:String = "began"; 42 | 43 | /** The finger moves around on the screen, or the mouse is moved while the button is 44 | * pressed. */ 45 | public static const MOVED:String = "moved"; 46 | 47 | /** The finger or mouse (with pressed button) has not moved since the last frame. */ 48 | public static const STATIONARY:String = "stationary"; 49 | 50 | /** The finger was lifted from the screen or from the mouse button. */ 51 | public static const ENDED:String = "ended"; 52 | } 53 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/filters/FragmentFilterMode.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.filters 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** A class that provides constant values for filter modes. The values are used in the 16 | * FragmentFilter.mode property and define how a filter result is combined with the 17 | * original object. */ 18 | public class FragmentFilterMode 19 | { 20 | /** @private */ 21 | public function FragmentFilterMode() { throw new AbstractClassError(); } 22 | 23 | /** The filter is displayed below the filtered object. */ 24 | public static const BELOW:String = "below"; 25 | 26 | /** The filter is replacing the filtered object. */ 27 | public static const REPLACE:String = "replace"; 28 | 29 | /** The filter is displayed above the filtered object. */ 30 | public static const ABOVE:String = "above"; 31 | } 32 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/text/TextFieldAutoSize.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.text 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** This class is an enumeration of constant values used in setting the 16 | * autoSize property of the TextField class. */ 17 | public class TextFieldAutoSize 18 | { 19 | /** @private */ 20 | public function TextFieldAutoSize() { throw new AbstractClassError(); } 21 | 22 | /** No auto-sizing will happen. */ 23 | public static const NONE:String = "none"; 24 | 25 | /** The text field will grow to the right; no line-breaks will be added. 26 | * The height of the text field remains unchanged. */ 27 | public static const HORIZONTAL:String = "horizontal"; 28 | 29 | /** The text field will grow to the bottom, adding line-breaks when necessary. 30 | * The width of the text field remains unchanged. */ 31 | public static const VERTICAL:String = "vertical"; 32 | 33 | /** The text field will grow to the right and bottom; no line-breaks will be added. */ 34 | public static const BOTH_DIRECTIONS:String = "bothDirections"; 35 | } 36 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/textures/ConcreteVideoTexture.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2015 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.textures 12 | { 13 | import flash.display3D.Context3DTextureFormat; 14 | import flash.display3D.textures.TextureBase; 15 | import flash.utils.getQualifiedClassName; 16 | 17 | /** A concrete texture that may only be used for a 'VideoTexture' base. 18 | * For internal use only. */ 19 | internal class ConcreteVideoTexture extends ConcreteTexture 20 | { 21 | /** Creates a new VideoTexture. 'base' must be of type 'VideoTexture'. */ 22 | public function ConcreteVideoTexture(base:TextureBase, scale:Number = 1) 23 | { 24 | // we must not reference the "VideoTexture" class directly 25 | // because it's only available in AIR. 26 | 27 | var format:String = Context3DTextureFormat.BGRA; 28 | var width:Number = "videoWidth" in base ? base["videoWidth"] : 0; 29 | var height:Number = "videoHeight" in base ? base["videoHeight"] : 0; 30 | 31 | super(base, format, width, height, false, false, false, scale, false); 32 | 33 | if (getQualifiedClassName(base) != "flash.display3D.textures::VideoTexture") 34 | throw new ArgumentError("'base' must be VideoTexture"); 35 | } 36 | 37 | /** The actual width of the video in pixels. */ 38 | override public function get nativeWidth():Number 39 | { 40 | return base["videoWidth"]; 41 | } 42 | 43 | /** The actual height of the video in pixels. */ 44 | override public function get nativeHeight():Number 45 | { 46 | return base["videoHeight"]; 47 | } 48 | 49 | /** inheritDoc */ 50 | override public function get width():Number 51 | { 52 | return nativeWidth / scale; 53 | } 54 | 55 | /** inheritDoc */ 56 | override public function get height():Number 57 | { 58 | return nativeHeight / scale; 59 | } 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/textures/GradientTexture.as: -------------------------------------------------------------------------------- 1 | package starling.textures 2 | { 3 | import flash.display.BitmapData; 4 | import flash.display.Shape; 5 | import flash.geom.Matrix; 6 | import starling.textures.Texture; 7 | 8 | public class GradientTexture 9 | { 10 | static public function create(width:Number, height:Number, type:String, colors:Array, alphas:Array, ratios:Array, matrix:Matrix=null, spreadMethod:String="pad", interpolationMethod:String="rgb", focalPointRatio:Number=0):Texture 11 | { 12 | var shape:Shape = new Shape(); 13 | shape.graphics.beginGradientFill( type, colors, alphas, ratios, matrix, spreadMethod, interpolationMethod, focalPointRatio ); 14 | shape.graphics.drawRect(0, 0, width, height); 15 | 16 | var bitmapData:BitmapData = new BitmapData(width, height, true); 17 | bitmapData.draw( shape ); 18 | 19 | return Texture.fromBitmapData(bitmapData); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/textures/TextureSmoothing.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.textures 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** A class that provides constant values for the possible smoothing algorithms of a texture. */ 16 | public class TextureSmoothing 17 | { 18 | /** @private */ 19 | public function TextureSmoothing() { throw new AbstractClassError(); } 20 | 21 | /** No smoothing, also called "Nearest Neighbor". Pixels will scale up as big rectangles. */ 22 | public static const NONE:String = "none"; 23 | 24 | /** Bilinear filtering. Creates smooth transitions between pixels. */ 25 | public static const BILINEAR:String = "bilinear"; 26 | 27 | /** Trilinear filtering. Highest quality by taking the next mip map level into account. */ 28 | public static const TRILINEAR:String = "trilinear"; 29 | 30 | /** Determines whether a smoothing value is valid. */ 31 | public static function isValid(smoothing:String):Boolean 32 | { 33 | return smoothing == NONE || smoothing == BILINEAR || smoothing == TRILINEAR; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/HAlign.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** A class that provides constant values for horizontal alignment of objects. */ 16 | public final class HAlign 17 | { 18 | /** @private */ 19 | public function HAlign() { throw new AbstractClassError(); } 20 | 21 | /** Left alignment. */ 22 | public static const LEFT:String = "left"; 23 | 24 | /** Centered alignement. */ 25 | public static const CENTER:String = "center"; 26 | 27 | /** Right alignment. */ 28 | public static const RIGHT:String = "right"; 29 | 30 | /** Indicates whether the given alignment string is valid. */ 31 | public static function isValid(hAlign:String):Boolean 32 | { 33 | return hAlign == LEFT || hAlign == CENTER || hAlign == RIGHT; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/MathUtil.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | import flash.geom.Point; 14 | import flash.geom.Vector3D; 15 | 16 | import starling.errors.AbstractClassError; 17 | 18 | /** A utility class containing methods you might need for maths problems. */ 19 | public class MathUtil 20 | { 21 | private static const TWO_PI:Number = Math.PI * 2.0; 22 | 23 | /** @private */ 24 | public function MathUtil() { throw new AbstractClassError(); } 25 | 26 | /** Calculates the intersection point between the xy-plane and an infinite line 27 | * that is defined by two 3D points. */ 28 | public static function intersectLineWithXYPlane(pointA:Vector3D, pointB:Vector3D, 29 | resultPoint:Point=null):Point 30 | { 31 | if (resultPoint == null) resultPoint = new Point(); 32 | 33 | var vectorX:Number = pointB.x - pointA.x; 34 | var vectorY:Number = pointB.y - pointA.y; 35 | var vectorZ:Number = pointB.z - pointA.z; 36 | var lambda:Number = -pointA.z / vectorZ; 37 | 38 | resultPoint.x = pointA.x + lambda * vectorX; 39 | resultPoint.y = pointA.y + lambda * vectorY; 40 | 41 | return resultPoint; 42 | } 43 | 44 | /** Moves a radian angle into the range [-PI, +PI], while keeping the direction intact. */ 45 | public static function normalizeAngle(angle:Number):Number 46 | { 47 | // move to equivalent value in range [0 deg, 360 deg] without a loop 48 | angle = angle % TWO_PI; 49 | 50 | // move to [-180 deg, +180 deg] 51 | if (angle < -Math.PI) angle += TWO_PI; 52 | if (angle > Math.PI) angle -= TWO_PI; 53 | 54 | return angle; 55 | } 56 | 57 | /** Moves 'value' into the range between 'min' and 'max'. */ 58 | public static function clamp(value:Number, min:Number, max:Number):Number 59 | { 60 | return value < min ? min : (value > max ? max : value); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/ScaleMode.as: -------------------------------------------------------------------------------- 1 | package starling.utils 2 | { 3 | import starling.errors.AbstractClassError; 4 | 5 | /** A class that provides constant values for the 'RectangleUtil.fit' method. */ 6 | public class ScaleMode 7 | { 8 | /** @private */ 9 | public function ScaleMode() { throw new AbstractClassError(); } 10 | 11 | /** Specifies that the rectangle is not scaled, but simply centered within the 12 | * specified area. */ 13 | public static const NONE:String = "none"; 14 | 15 | /** Specifies that the rectangle fills the specified area without distortion 16 | * but possibly with some cropping, while maintaining the original aspect ratio. */ 17 | public static const NO_BORDER:String = "noBorder"; 18 | 19 | /** Specifies that the entire rectangle will be scaled to fit into the specified 20 | * area, while maintaining the original aspect ratio. This might leave empty bars at 21 | * either the top and bottom, or left and right. */ 22 | public static const SHOW_ALL:String = "showAll"; 23 | 24 | /** Indicates whether the given scale mode string is valid. */ 25 | public static function isValid(scaleMode:String):Boolean 26 | { 27 | return scaleMode == NONE || scaleMode == NO_BORDER || scaleMode == SHOW_ALL; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/VAlign.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | import starling.errors.AbstractClassError; 14 | 15 | /** A class that provides constant values for vertical alignment of objects. */ 16 | public final class VAlign 17 | { 18 | /** @private */ 19 | public function VAlign() { throw new AbstractClassError(); } 20 | 21 | /** Top alignment. */ 22 | public static const TOP:String = "top"; 23 | 24 | /** Centered alignment. */ 25 | public static const CENTER:String = "center"; 26 | 27 | /** Bottom alignment. */ 28 | public static const BOTTOM:String = "bottom"; 29 | 30 | /** Indicates whether the given alignment string is valid. */ 31 | public static function isValid(vAlign:String):Boolean 32 | { 33 | return vAlign == TOP || vAlign == CENTER || vAlign == BOTTOM; 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/cleanMasterString.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2014 Gamua GmbH. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | /** Replaces a string's "master string" — the string it was built from — 14 | * with a single character to save memory. Find more information about this AS3 oddity 15 | * here. 16 | * 17 | * @param str String to clean 18 | * @return The input string, but with a master string only one character larger than it. 19 | * @author Jackson Dunstan, JacksonDunstan.com 20 | */ 21 | public function cleanMasterString(str:String):String 22 | { 23 | return ("_" + str).substr(1); 24 | } 25 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/deg2rad.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | /** Converts an angle from degrees into radians. */ 14 | public function deg2rad(deg:Number):Number 15 | { 16 | return deg / 180.0 * Math.PI; 17 | } 18 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/execute.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | /** Executes a function with the specified arguments. If the argument count does not match 14 | * the function, the argument list is cropped / filled up with null values. */ 15 | public function execute(func:Function, ...args):void 16 | { 17 | if (func != null) 18 | { 19 | var i:int; 20 | var maxNumArgs:int = func.length; 21 | 22 | for (i=args.length; i 0 && (number & (number - 1)) == 0) // see: http://goo.gl/D9kPj 17 | return number; 18 | else 19 | { 20 | var result:int = 1; 21 | number -= 0.000000001; // avoid floating point rounding errors 22 | 23 | while (result < number) result <<= 1; 24 | return result; 25 | } 26 | } 27 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/rad2deg.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | /** Converts an angle from radians into degrees. */ 14 | public function rad2deg(rad:Number):Number 15 | { 16 | return rad / Math.PI * 180.0; 17 | } 18 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/starling/utils/transformCoords.as: -------------------------------------------------------------------------------- 1 | // ================================================================================================= 2 | // 3 | // Starling Framework 4 | // Copyright 2011-2014 Gamua. All Rights Reserved. 5 | // 6 | // This program is free software. You can redistribute and/or modify it 7 | // in accordance with the terms of the accompanying license agreement. 8 | // 9 | // ================================================================================================= 10 | 11 | package starling.utils 12 | { 13 | import flash.geom.Matrix; 14 | import flash.geom.Point; 15 | 16 | /** Uses a matrix to transform 2D coordinates into a different space. If you pass a 17 | * 'resultPoint', the result will be stored in this point instead of creating a new object.*/ 18 | public function transformCoords(matrix:Matrix, x:Number, y:Number, 19 | resultPoint:Point=null):Point 20 | { 21 | if (!deprecationNotified) 22 | { 23 | deprecationNotified = true; 24 | trace("[Starling] The method 'transformCoords' is deprecated. " + 25 | "Please use 'MatrixUtil.transformCoords' instead."); 26 | } 27 | 28 | if (resultPoint == null) resultPoint = new Point(); 29 | 30 | resultPoint.x = matrix.a * x + matrix.c * y + matrix.tx; 31 | resultPoint.y = matrix.d * y + matrix.b * x + matrix.ty; 32 | 33 | return resultPoint; 34 | } 35 | } 36 | 37 | var deprecationNotified:Boolean = false; -------------------------------------------------------------------------------- /StarlingFeathers/src/swallow/events/TimerEvent2D.as: -------------------------------------------------------------------------------- 1 | package swallow.events 2 | { 3 | import swallow.utils.Timer2D; 4 | /** 5 | * 计时器对象 6 | * @author 7 | */ 8 | public class TimerEvent2D 9 | { 10 | 11 | /** 12 | * 计时器 13 | */ 14 | public static var TIMER:String = "EVENT2D_TIMER"; 15 | 16 | /** 17 | * 计时器执行结束 18 | */ 19 | public static var TIMER_END:String = "EVENT2D_END"; 20 | 21 | /** 22 | * 计时器重置 23 | */ 24 | public static var TIMER_RESET:String = "EVENT2D_TIMER_RESET"; 25 | 26 | /** 27 | * 计时器被启动 28 | */ 29 | public static var TIMER_SRATR:String = "EVENT2D_TIMER_SRATR"; 30 | 31 | /** 32 | * 计时器被停止 33 | */ 34 | public static var TIMER_STOP:String = "EVENT2D_TIMER_STOP"; 35 | 36 | /** 37 | * 当前执行次数 38 | */ 39 | public var targetRepeatCount:int 40 | 41 | /** 42 | * 总运行次数 43 | */ 44 | public var repeatCount:int 45 | public var target:Timer2D 46 | public function TimerEvent2D() 47 | { 48 | 49 | } 50 | 51 | } 52 | 53 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/swallow/filters/AdvancedFilter.as: -------------------------------------------------------------------------------- 1 | package swallow.filters 2 | { 3 | import flash.display3D.Context3D; 4 | import flash.display3D.Context3DBlendFactor; 5 | import flash.display3D.Context3DProgramType; 6 | import flash.display3D.Program3D; 7 | import starling.core.Starling; 8 | import starling.filters.FragmentFilter; 9 | import starling.textures.Texture; 10 | import starling.utils.getNextPowerOfTwo; 11 | 12 | /** 13 | * 色调滤镜 14 | * @-式神- 15 | */ 16 | public class AdvancedFilter extends FragmentFilter 17 | { 18 | 19 | private var mShaderProgram:Program3D; 20 | private var maddR:Number = 0; 21 | private var maddG:Number = 0; 22 | private var maddB:Number = 0; 23 | private var maddA:Number = 0; 24 | 25 | /** 26 | * 创建一个色调滤镜 27 | */ 28 | public function AdvancedFilter(r:Number=0,g:Number=0,b:Number=0,a:Number=0) 29 | { 30 | this.maddG = r; 31 | this.maddG = r; 32 | this.maddB = b; 33 | this.maddA = a; 34 | } 35 | 36 | public override function dispose():void 37 | { 38 | if (mShaderProgram) mShaderProgram.dispose(); 39 | super.dispose(); 40 | } 41 | 42 | protected override function createPrograms():void 43 | { 44 | 45 | var fragmentProgramCode:String = 46 | "tex ft0, v0,fs0 <2d,repeat,linear,mipnone>\n" + 47 | "mul ft1,fc0,ft0.wwww\n" + 48 | "add ft0,ft0,ft1\n" + 49 | "mov oc, ft0\n"; 50 | 51 | mShaderProgram = assembleAgal(fragmentProgramCode); 52 | } 53 | 54 | protected override function activate(pass:int, context:Context3D, texture:Texture):void 55 | { 56 | Starling.context.setScissorRectangle(null) 57 | context.setProgramConstantsFromVector(Context3DProgramType.FRAGMENT,0, Vector.([maddR,maddG,maddB,maddA]) ); 58 | context.setProgram(mShaderProgram); 59 | } 60 | override protected function deactivate(pass:int, context:Context3D, texture:Texture):void 61 | { 62 | 63 | } 64 | 65 | /** 66 | * 红色增量 67 | */ 68 | public function get addR():Number { return maddR }; 69 | public function set addR(value:Number):void { maddR = value }; 70 | 71 | /** 72 | * 绿色增量 73 | */ 74 | public function get addG():Number { return maddG }; 75 | public function set addG(value:Number):void { maddG = value }; 76 | 77 | /** 78 | * 蓝色增量 79 | */ 80 | public function get addB():Number { return maddB }; 81 | public function set addB(value:Number):void { maddB = value }; 82 | 83 | /** 84 | * 透明度增量 85 | */ 86 | public function get addA():Number { return maddA }; 87 | public function set addA(value:Number):void { maddA = value }; 88 | } 89 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/swallow/filters/Screenshot.as: -------------------------------------------------------------------------------- 1 | package swallow.filters 2 | { 3 | import flash.display.BitmapData; 4 | import flash.display3D.Context3D; 5 | import flash.display3D.Program3D; 6 | import starling.core.Starling; 7 | import starling.display.Quad; 8 | import starling.display.Sprite; 9 | import starling.filters.FragmentFilter; 10 | import starling.textures.Texture; 11 | 12 | /** 13 | * 14 | * 截图类,因为截取屏幕需要插入到starling的绘制循序中去,这样就必须改动底层的一些代码,我这个是一个取巧的方法,利用滤镜deactivate方法深入到他的绘制流程中去截图. 15 | * 使用方法: 16 | var screenshot:Screenshot = new Screenshot(游戏场景,width,height,bitmapdata,function(value:BitmapData):void{ 17 | //value是当前截图的数据,回调会一直执行,你可以通过自己判断选择截图几次 18 | }); 19 | 20 | //删除 21 | screenshot.dispose(); 22 | * @-式神- 23 | */ 24 | public class Screenshot extends FragmentFilter 25 | { 26 | private var mShaderProgram:Program3D; 27 | private var canvas:BitmapData; 28 | private var canvasQuad:Quad 29 | private var canvasW:Number 30 | private var canvasH:Number 31 | private var callBack:Function 32 | private var scene:Sprite 33 | public function Screenshot(scene:Sprite,w:Number=100,h:Number=100,callBack:Function=null) 34 | { 35 | this.canvasW = w; 36 | this.canvasH = h; 37 | this.callBack = callBack; 38 | this.scene = scene; 39 | canvasQuad = new Quad(1,1); 40 | canvasQuad.filter = this; 41 | scene.addChild(canvasQuad); 42 | } 43 | public override function dispose():void 44 | { 45 | canvasQuad.filter = null; 46 | scene.removeChild(canvasQuad); 47 | if (mShaderProgram) mShaderProgram.dispose(); 48 | super.dispose(); 49 | } 50 | 51 | protected override function createPrograms():void 52 | { 53 | var fragmentProgramCode:String = 54 | "tex ft0, v0, fs0 <2d,repeat,linear,mipnone>\n"+ 55 | "mov oc, ft0" 56 | mShaderProgram = assembleAgal(fragmentProgramCode); 57 | } 58 | 59 | protected override function activate(pass:int, context:Context3D, texture:Texture):void 60 | { 61 | context.setProgram(mShaderProgram); 62 | } 63 | 64 | override protected function deactivate(pass:int, context:Context3D, texture:Texture):void 65 | { 66 | if (canvas == null) 67 | canvas = new BitmapData(canvasW,canvasH, true, 0xffffffff); 68 | Starling.context.drawToBitmapData(canvas); 69 | if(callBack!=null) 70 | callBack(canvas); 71 | } 72 | } 73 | } -------------------------------------------------------------------------------- /StarlingFeathers/src/swallow/utils/TimerLists.as: -------------------------------------------------------------------------------- 1 | package swallow.utils 2 | { 3 | import flash.events.Event; 4 | import flash.events.TimerEvent; 5 | import flash.utils.Timer; 6 | import starling.core.Starling; 7 | /** 8 | * 计时器容器数组 9 | * @author TK 10 | */ 11 | public class TimerLists 12 | { 13 | /** 14 | * 单例对象 15 | */ 16 | private static var _target:TimerLists 17 | 18 | private static var timerLists:Vector.; 19 | 20 | private var tiemr:Timer 21 | private var index:int 22 | /** 23 | * 创建一个计时器容器池 24 | */ 25 | public function TimerLists() 26 | { 27 | timerLists = new Vector.(); 28 | 29 | Starling.current.nativeStage.addEventListener(Event.ENTER_FRAME,run) 30 | } 31 | 32 | private function run(e:Event):void 33 | { 34 | index++ 35 | if (index > 100000) 36 | { 37 | tiemr.reset(); 38 | tiemr.start(); 39 | } 40 | TimerLists.run() 41 | } 42 | 43 | /** 44 | * 返回容器对象 45 | */ 46 | public static function get target():TimerLists 47 | { 48 | if (_target == null) 49 | { 50 | _target = new TimerLists(); 51 | } 52 | return _target; 53 | } 54 | 55 | /** 56 | * 暂停 57 | * @param value 58 | */ 59 | public function suspend(value:int):void 60 | { 61 | for (var i:int = 0; i < timerLists.length; i++) 62 | { 63 | timerLists[i].suspend(value); 64 | } 65 | } 66 | 67 | /** 68 | * 添加计时器 69 | * @param timer 70 | */ 71 | public function addTimer(timer:Timer2D):void 72 | { 73 | timerLists.push(timer); 74 | } 75 | 76 | /** 77 | * 删除计时器 78 | * @param timer 79 | */ 80 | public function removeTimer(timer:Timer2D):void 81 | { 82 | timerLists.splice(timerLists.indexOf(timer), 1); 83 | } 84 | 85 | /** 86 | * 线程 87 | */ 88 | public static function run():void 89 | { 90 | var len:int = timerLists.length; 91 | for (var i:int = 0; i