パッケージflash.display
public class Shape
継承Shape Inheritance DisplayObject Inheritance EventDispatcher Inheritance Object
SubclassesFlexShape

Shape クラスは、ActionScript 描画アプリケーションプログラムインターフェイス (API) を使用して単純なシェイプを作成するときに使用されます。Shape クラスには、Graphics クラスからメソッドにアクセスできる graphics プロパティがあります。

Sprite クラスにも graphics プロパティがあり、これには Shape クラスでは使用できない他の機能があります。たとえば、Sprite オブジェクトは表示オブジェクトコンテナであるのに対し、Shape オブジェクトはそうではありません (子表示オブジェクトも持てません)。したがって、同じグラフィックが含まれていても、使用されるメモリ量は Shape オブジェクトの方が Sprite オブジェクトよりも少なくなります。

例の表示

関連項目

flash.display.Graphics
表示アーキテクチャについて


パブリックプロパティ
 プロパティ定義
 InheritedaccessibilityProperties : AccessibilityProperties
この表示オブジェクトの現在のアクセシビリティオプションです。
DisplayObject
 Inheritedalpha : Number
指定されたオブジェクトのアルファ透明度値を示します。
DisplayObject
 InheritedblendMode : String
使用するブレンドモードを指定する BlendMode クラスの値です。
DisplayObject
 InheritedcacheAsBitmap : Boolean
true に設定されている場合、表示オブジェクトの内部ビットマップ表現が Flash Player にキャッシュされます。
DisplayObject
 Inheritedconstructor : Object
特定のオブジェクトインスタンスのクラスオブジェクトまたはコンストラクタ関数への参照です。
Object
 Inheritedfilters : Array
表示オブジェクトに現在関連付けられている各フィルタオブジェクトが格納されているインデックス付きの配列です。
DisplayObject
  graphics : Graphics
[read-only] ベクターの描画コマンドが発生する、この Shape オブジェクトに属する Graphics オブジェクトを指定します。
Shape
 Inheritedheight : Number
表示オブジェクトの高さを示します (ピクセル単位)。
DisplayObject
 InheritedloaderInfo : LoaderInfo
この表示オブジェクトが属するファイルのロード情報を含む LoaderInfo オブジェクトを返します。
DisplayObject
 Inheritedmask : DisplayObject
呼び出し元の表示オブジェクトは、指定された mask オブジェクトによってマスクされます。
DisplayObject
 InheritedmouseX : Number
マウス位置の x 座標を示します (ピクセル単位)。
DisplayObject
 InheritedmouseY : Number
マウス位置の y 座標を示します (ピクセル単位)。
DisplayObject
 Inheritedname : String
DisplayObject のインスタンス名を示します。
DisplayObject
 InheritedopaqueBackground : Object
表示オブジェクトが特定の背景色で不透明であるかどうかを指定します。
DisplayObject
 Inheritedparent : DisplayObjectContainer
この表示オブジェクトを含む DisplayObjectContainer オブジェクトを示します。
DisplayObject
 Inheritedprototype : Object
[static] クラスまたは関数オブジェクトのプロトタイプオブジェクトへの参照です。
Object
 Inheritedroot : DisplayObject
ロードされた SWF ファイル内の表示オブジェクトの場合、root プロパティはその SWF ファイルが表す表示リストのツリー構造部分の一番上にある表示オブジェクトとなります。
DisplayObject
 Inheritedrotation : Number
DisplayObject インスタンスの元の位置からの回転角を度単位で示します。
DisplayObject
 Inheritedscale9Grid : Rectangle
現在有効な拡大 / 縮小グリッドです。
DisplayObject
 InheritedscaleX : Number
基準点から適用されるオブジェクトの水平スケール (percentage) を示します。
DisplayObject
 InheritedscaleY : Number
オブジェクトの基準点から適用されるオブジェクトの垂直スケール (percentage) を示します。
DisplayObject
 InheritedscrollRect : Rectangle
表示オブジェクトのスクロール矩形の境界。
DisplayObject
 Inheritedstage : Stage
表示オブジェクトのステージ。
DisplayObject
 Inheritedtransform : Transform
表示オブジェクトのマトリックス、カラー変換、ピクセル境界に関係するプロパティを持つオブジェクトです。
DisplayObject
 Inheritedvisible : Boolean
表示オブジェクトが可視かどうかを示します。
DisplayObject
 Inheritedwidth : Number
表示オブジェクトの幅を示します (ピクセル単位)。
DisplayObject
 Inheritedx : Number
親 DisplayObjectContainer のローカル座標を基準にした DisplayObject インスタンスの x 座標を示します。
DisplayObject
 Inheritedy : Number
親 DisplayObjectContainer のローカル座標を基準にした DisplayObject インスタンスの y 座標を示します。
DisplayObject
パブリックメソッド
 メソッド定義
  Shape()
新しい Shape オブジェクトを作成します。
Shape
 InheritedaddEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
イベントリスナーオブジェクトを EventDispatcher オブジェクトに登録し、リスナーがイベントの通知を受け取るようにします。
EventDispatcher
 InheriteddispatchEvent(event:Event):Boolean
イベントをイベントフローに送出します。
EventDispatcher
 InheritedgetBounds(targetCoordinateSpace:DisplayObject):Rectangle
targetCoordinateSpace オブジェクトの座標系を基準にして、表示オブジェクトの領域を定義する矩形を返します。
DisplayObject
 InheritedgetRect(targetCoordinateSpace:DisplayObject):Rectangle
シェイプ上の線を除き、targetCoordinateSpace パラメータによって定義された座標系に基づいて、表示オブジェクトの境界を定義する矩形を返します。
DisplayObject
 InheritedglobalToLocal(point:Point):Point
point オブジェクトをステージ (グローバル) 座標から表示オブジェクトの (ローカル) 座標に変換します。
DisplayObject
 InheritedhasEventListener(type:String):Boolean
EventDispatcher オブジェクトに、特定のイベントタイプに対して登録されたリスナーがあるかどうかを確認します。
EventDispatcher
 InheritedhasOwnProperty(name:String):Boolean
オブジェクトに指定されたプロパティが定義されているかどうかを示します。
Object
 InheritedhitTestObject(obj:DisplayObject):Boolean
表示オブジェクトを評価して、obj 表示オブジェクトと重複または交差するかどうかを調べます。
DisplayObject
 InheritedhitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
表示オブジェクトを評価して、x および y パラメータで指定されたポイントと重複または交差するかどうかを調べます。
DisplayObject
 InheritedisPrototypeOf(theClass:Object):Boolean
Object クラスのインスタンスが、パラメータとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
Object
 InheritedlocalToGlobal(point:Point):Point
point オブジェクトを表示オブジェクトの (ローカル) 座標からステージ (グローバル) 座標に変換します。
DisplayObject
 InheritedpropertyIsEnumerable(name:String):Boolean
指定されたプロパティが存在し、列挙可能かどうかを示します。
Object
 InheritedremoveEventListener(type:String, listener:Function, useCapture:Boolean = false):void
EventDispatcher オブジェクトからリスナーを削除します。
EventDispatcher
 InheritedsetPropertyIsEnumerable(name:String, isEnum:Boolean = true):void
ループ処理に対するダイナミックプロパティの可用性を設定します。
Object
 InheritedtoString():String
指定されたオブジェクトのストリング表現を返します。
Object
 InheritedvalueOf():Object
指定されたオブジェクトのプリミティブ値を返します。
Object
 InheritedwillTrigger(type:String):Boolean
指定されたイベントタイプについて、この EventDispatcher オブジェクトまたはその祖先にイベントリスナーが登録されているかどうかを確認します。
EventDispatcher
イベント
 イベント一覧定義
 Inheritedactivate Flash Player がオペレーティングシステムのフォーカスを取得して、アクティブになったときに送出されます。DisplayObject
 Inheritedadded 表示オブジェクトが表示リストに追加されたときに送出されます。DisplayObject
 Inheriteddeactivate Flash Player がオペレーティングシステムのフォーカスを失って、非アクティブになったときに送出されます。DisplayObject
 InheritedenterFrame 再生ヘッドが新しいフレームに入るときに送出されます。DisplayObject
 Inheritedremoved 表示オブジェクトが表示リストから削除されようとしているときに送出されます。DisplayObject
 Inheritedrender 表示リストが更新およびレンダリングされようとしているときに送出されます。DisplayObject
プロパティの詳細
graphicsプロパティ
graphics:Graphics  [read-only]

ベクターの描画コマンドが発生する、この Shape オブジェクトに属する Graphics オブジェクトを指定します。

実装
    public function get graphics():Graphics

関連項目

コンストラクタの詳細
Shape()コンストラクタ
public 関数 Shape()

新しい Shape オブジェクトを作成します。


次の例では、ShapeExample クラスを使用して、 円、角丸矩形、および四角形を描画します。これを行うには、以下の手順を実行します。
  1. 後で各シェイプのサイズを決定する際に使用する size プロパティを宣言します。
  2. 背景色をオレンジ色、境界線色を 濃い灰色、境界線のサイズを 0 ピクセル、角丸の半径を 9 ピクセル、 ステージの端と他のオブジェクトの間のスペースを 5 ピクセルに、それぞれ設定するプロパティを宣言します。
  3. 上記の手順で宣言したプロパティを Graphics クラスのビルトインメソッドとともに使用して、円、角丸矩形、および四角形を、座標 x = 0、y = 0 に描画します。
  4. ステージの一番上に配置された各シェイプを、x = 5、y = 5 から、 refreshLayout() を使用してシェイプ間のスペースを 5 ピクセルにして再描画します。

package {
    import flash.display.DisplayObject;
    import flash.display.Graphics;
    import flash.display.JointStyle;
    import flash.display.LineScaleMode;
    import flash.display.Shape;
    import flash.display.Sprite;

    public class ShapeExample extends Sprite {
        private var size:uint           = 80;
        private var bgColor:uint       = 0xFFCC00;
        private var borderColor:uint  = 0x666666;
        private var borderSize:uint   = 0;
        private var cornerRadius:uint = 9;
        private var gutter:uint       = 5;

        public function ShapeExample() {
            doDrawCircle();
            doDrawRoundRect();
            doDrawRect();
            refreshLayout();
        }

        private function refreshLayout():void {
            var ln:uint = numChildren;
            var child:DisplayObject;
            var lastChild:DisplayObject = getChildAt(0);
            lastChild.x = gutter;
            lastChild.y = gutter;
            for (var i:uint = 1; i < ln; i++) {
                child = getChildAt(i);
                child.x = gutter + lastChild.x + lastChild.width;
                child.y = gutter;
                lastChild = child;
            }
        }

        private function doDrawCircle():void {
            var child:Shape = new Shape();
            var halfSize:uint = Math.round(size/2);
            child.graphics.beginFill(bgColor);
            child.graphics.lineStyle(borderSize, borderColor);
            child.graphics.drawCircle(halfSize, halfSize, halfSize);
            child.graphics.endFill();
            addChild(child);
        }

        private function doDrawRoundRect():void {
            var child:Shape = new Shape();
            child.graphics.beginFill(bgColor);
            child.graphics.lineStyle(borderSize, borderColor);
            child.graphics.drawRoundRect(0, 0, size, size, cornerRadius);
            child.graphics.endFill();
            addChild(child);
        }

        private function doDrawRect():void {
            var child:Shape = new Shape();
            child.graphics.beginFill(bgColor);
            child.graphics.lineStyle(borderSize, borderColor);
            child.graphics.drawRect(0, 0, size, size);
            child.graphics.endFill();
            addChild(child);
        }
    }
}




 

このページに新しいコメントが追加された場合に、電子メールでの通知を希望する。 | コメントレポート

現在のページ: http://livedocs.adobe.com/flex/2_jp/langref/flash/display/Shape.html