Flash制作講座フラッシュ制作講習

FLASH制作からActionScriptによるFlashコンテンツ制作のためのフラッシュ制作講座

Spliteクラスを理解するAS3.0Flash

ActionScript3.0より追加されたクラスSpliteですが、よりわかりやすく、より理解を深めてみました。

まずActionScript3 Spriteクラスでは、タイムラインを持たない基本クラスで、子オブジェクトを持つことが可能でディスプレイリストを構成する基本的な要素です。


グラフィックスの描画クラスではShapeクラスがありますが、ベクターグラフィックの作成のみが可能で、コンテナとして機能せず子ノードを持つことができません。


なのでSpliteクラスとは、グラフィックの描画が可能なコンテナで、タイムラインの概念をもたないMovieClipという位置づけが使いやすいかもしれません。


もちろん、ActionScriptの記述でタイムラインと同等の描写や動きなどが可能で、タイムラインの指定概念こそありませんがActionScriptのみでFlashコンテンツの制作をおこなう場合は、特にMovieClipは必要ない場合もあるかもしれません。


宣言の仕方は一般の新規オブジェクトです。

var rectangle1:Sprite = new Sprite();
rectangle1.graphics.beginFill(0x000000);
rectangle1.graphics.drawRect(0, 0,120,30);
addChild(rectangle1);

上記の例では、ステージ0,0の座標に横幅120px、高さ30pxの黒の長方形のSpliteクラスを配置しました。



以下には継承されるメソッドやプロパティです。



■Spliteクラスに継承されるパブリックプロパティ

・accessibilityProperties : AccessibilityProperties
・alpha : Number
・blendMode : String
・buttonMode : Boolean
・cacheAsBitmap : Boolean
・constructor : Object
・contextMenu : ContextMenu
・doubleClickEnabled : Boolean
・dropTarget : DisplayObject
・filters : Array
・focusRect : Object
・graphics : Graphics
・height : Number
・hitArea : Sprite
・loaderInfo : LoaderInfo
・mask : DisplayObject
・mouseChildren : Boolean
・mouseEnabled : Boolean
・mouseX : Number
・mouseY : Number
・name : String
・numChildren : int
・opaqueBackground : Object
・parent : DisplayObjectContainer
・prototype : Object
・root : DisplayObject
・rotation : Number
・scale9Grid : Rectangle
・scaleX : Number
・scaleY : Number
・scrollRect : Rectangle
・soundTransform : SoundTransform
・stage : Stage
・tabChildren : Boolean
・tabEnabled : Boolean
・tabIndex : int
・textSnapshot : TextSnapshot
・transform : Transform
・useHandCursor : Boolean
・visible : Boolean
・width : Number
・x : Number
・y : Number



■Spliteクラスに継承されるパブリック メソッド

・Sprite()
・addChild(child:DisplayObject):DisplayObject
・addChildAt(child:DisplayObject, index:int):DisplayObject
・addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
・areInaccessibleObjectsUnderPoint(point:Point):Boolean
・contains(child:DisplayObject):Boolean
・dispatchEvent(event:Event):Boolean
・getBounds(targetCoordinateSpace:DisplayObject):Rectangle
・getChildAt(index:int):DisplayObject
・getChildByName(name:String):DisplayObject
・getChildIndex(child:DisplayObject):int
・getObjectsUnderPoint(point:Point):Array
・getRect(targetCoordinateSpace:DisplayObject):Rectangle
・globalToLocal(point:Point):Point
・hasEventListener(type:String):Boolean
・hasOwnProperty(name:String):Boolean
・hitTestObject(obj:DisplayObject):Boolean
・hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
・localToGlobal(point:Point):Point
・propertyIsEnumerable(name:String):Boolean
・removeChild(child:DisplayObject):DisplayObject
・removeChildAt(index:int):DisplayObject
・removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
・setChildIndex(child:DisplayObject, index:int):void
・setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void
・startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void
・stopDrag():void
・swapChildren(child1:DisplayObject, child2:DisplayObject):void
・swapChildrenAt(index1:int, index2:int):void
・toString():String
・valueOf():Object
・willTrigger(type:String):Boolean



■Spliteクラスに継承されるイベント

・activate
・added
・addedToStage
・click
・deactivate
・doubleClick
・enterFrame
・focusIn
・focusOut
・keyDown
・keyFocusChange
・keyUp
・mouseDown
・mouseFocusChange
・mouseMove
・mouseOut
・mouseOver
・mouseUp
・mouseWheel
・removed
・removedFromStage
・render
・rollOut
・rollOver
・tabChildrenChange
・tabEnabledChange
・tabIndexChange