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

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

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

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

例を表示

関連項目

flash.display.Graphics
flash.display.Sprite
コア表示クラス
描画 API の使用の基礎


パブリック プロパティ
 プロパティ定義元
 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
[read-only] この表示オブジェクトが属するファイルのロード情報を含む LoaderInfo オブジェクトを返します。
DisplayObject
 Inheritedmask : DisplayObject
呼び出し元の表示オブジェクトは、指定された mask オブジェクトによってマスクされます。
DisplayObject
 InheritedmouseX : Number
[read-only] マウス位置の x 座標を示します (ピクセル単位)。
DisplayObject
 InheritedmouseY : Number
[read-only] マウス位置の y 座標を示します (ピクセル単位)。
DisplayObject
 Inheritedname : String
DisplayObject のインスタンス名を示します。
DisplayObject
 InheritedopaqueBackground : Object
表示オブジェクトが特定の背景色で不透明であるかどうかを指定します。
DisplayObject
 Inheritedparent : DisplayObjectContainer
[read-only] この表示オブジェクトを含む DisplayObjectContainer オブジェクトを示します。
DisplayObject
 Inheritedprototype : Object
[static] クラスまたは関数オブジェクトのプロトタイプオブジェクトへの参照です。
Object
 Inheritedroot : DisplayObject
[read-only] ロードされた SWF ファイル内の表示オブジェクトの場合、root プロパティはその SWF ファイルが表す表示リストのツリー構造部分の一番上にある表示オブジェクトとなります。
DisplayObject
 Inheritedrotation : Number
DisplayObject インスタンスの元の位置からの回転角を度単位で示します。
DisplayObject
 Inheritedscale9Grid : Rectangle
現在有効な拡大 / 縮小グリッドです。
DisplayObject
 InheritedscaleX : Number
基準点から適用されるオブジェクトの水平スケール (percentage) を示します。
DisplayObject
 InheritedscaleY : Number
オブジェクトの基準点から適用されるオブジェクトの垂直スケール (percentage) を示します。
DisplayObject
 InheritedscrollRect : Rectangle
表示オブジェクトのスクロール矩形の境界です。
DisplayObject
 Inheritedstage : Stage
[read-only] 表示オブジェクトのステージです。
DisplayObject
 Inheritedtransform : Transform
表示オブジェクトのマトリックス、カラー変換、ピクセル境界に関係するプロパティを持つオブジェクトです。
DisplayObject
 Inheritedvisible : Boolean
表示オブジェクトが可視かどうかを示します。
DisplayObject
 Inheritedwidth : Number
表示オブジェクトの幅を示します (ピクセル単位)。
DisplayObject
 Inheritedx : Number
親 DisplayObjectContainer のローカル座標を基準にした DisplayObject インスタンスの x 座標を示します。
DisplayObject
 Inheritedy : Number
親 DisplayObjectContainer のローカル座標を基準にした DisplayObject インスタンスの y 座標を示します。
DisplayObject
パブリック メソッド
 メソッド定義元
  
新しい Shape オブジェクトを作成します。
Shape
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
イベントリスナーオブジェクトを EventDispatcher オブジェクトに登録し、リスナーがイベントの通知を受け取るようにします。
EventDispatcher
 Inherited
イベントをイベントフローに送出します。
EventDispatcher
 Inherited
getBounds(targetCoordinateSpace:DisplayObject):Rectangle
targetCoordinateSpace オブジェクトの座標系を基準にして、表示オブジェクトの領域を定義する矩形を返します。
DisplayObject
 Inherited
getRect(targetCoordinateSpace:DisplayObject):Rectangle
シェイプ上の線を除き、targetCoordinateSpace パラメータによって定義された座標系に基づいて、表示オブジェクトの境界を定義する矩形を返します。
DisplayObject
 Inherited
point オブジェクトをステージ (グローバル) 座標から表示オブジェクトの (ローカル) 座標に変換します。
DisplayObject
 Inherited
EventDispatcher オブジェクトに、特定のイベントタイプに対して登録されたリスナーがあるかどうかを確認します。
EventDispatcher
 Inherited
オブジェクトに指定されたプロパティが定義されているかどうかを示します。
Object
 Inherited
表示オブジェクトを評価して、obj 表示オブジェクトと重複または交差するかどうかを調べます。
DisplayObject
 Inherited
hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
表示オブジェクトを評価して、x および y パラメータで指定されたポイントと重複または交差するかどうかを調べます。
DisplayObject
 Inherited
Object クラスのインスタンスが、パラメータとして指定されたオブジェクトのプロトタイプチェーン内にあるかどうかを示します。
Object
 Inherited
point オブジェクトを表示オブジェクトの (ローカル) 座標からステージ (グローバル) 座標に変換します。
DisplayObject
 Inherited
指定されたプロパティが存在し列挙できるかどうかを示します。
Object
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
EventDispatcher オブジェクトからリスナーを削除します。
EventDispatcher
 Inherited
ループ処理に対するダイナミックプロパティの可用性を設定します。
Object
 Inherited
指定されたオブジェクトのストリング表現を返します。
Object
 Inherited
指定されたオブジェクトのプリミティブな値を返します。
Object
 Inherited
指定されたイベントタイプについて、この EventDispatcher オブジェクトまたはその祖先にイベントリスナーが登録されているかどうかを確認します。
EventDispatcher
イベント
 イベント 概要 定義元
 Inherited Flash Player がオペレーティングシステムのフォーカスを取得して、アクティブになったときに送出されます。EventDispatcher
 Inherited 表示オブジェクトが表示リストに追加されたときに送出されます。DisplayObject
 Inherited 表示オブジェクトが、直接、または表示オブジェクトを含むサブツリーの追加により、ステージ上の表示リストに追加されたときに送出されます。DisplayObject
 Inherited Flash Player がオペレーティングシステムのフォーカスを失って、非アクティブになったときに送出されます。EventDispatcher
 Inherited 再生ヘッドが新しいフレームに入るときに送出されます。DisplayObject
 Inherited 表示オブジェクトが表示リストから削除されようとしているときに送出されます。DisplayObject
 Inherited 表示オブジェクトが、直接、または表示オブジェクトを含むサブツリーの削除により、表示リストから削除されようとしているときに送出されます。DisplayObject
 Inherited 表示リストが更新およびレンダリングされようとしているときに送出されます。DisplayObject
プロパティの詳細
graphicsプロパティ
graphics:Graphics  [read-only]

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

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


実装
    public function get graphics():Graphics
コンストラクタの詳細
Shape()コンストラクタ
public function Shape()

言語バージョン : ActionScript 3.0
Player のバージョン : Flash Player 9

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

例の使用法
ShapeExample.as

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