This page was saved using jaction on 2006-09-04 8:33:56.
Address: http://flexdocs.kr/docs/flex2/langref/Object.html
Title: Object (Flex™ 2 레퍼런스 가이드)  •  Size: 54954
Package톱 레벨
Classpublic dynamic class Object
SubclassesAbstractMessage , AbstractTarget , Accessibility , AccessibilityProperties , ActionScriptVersion , AddChild , AntiAliasType , ApplicationDomain , arguments , Array , ArrayUtil , AxisLabel , AxisLabelSet , Back , BaseListData , BindingUtils , BitmapData , BitmapDataChannel , BitmapFill , BitmapFilter , BitmapFilterQuality , BitmapFilterType , BlendMode , Boolean , Bounce , BoundedValue , BoxDirection , ButtonLabelPlacement , ByteArray , Capabilities , CapsStyle , ChangeWatcher , ChartState , Circular , Class , ClassFactory , CollectionEventKind , ColorTransform , ColorUtil , ComponentDescriptor , Conflict , ConflictDetector , ContainerCreationPolicy , ContainerLayout , ContextMenuBuiltInItems , CreditCardValidatorCardType , CSMSettings , Cubic , CuePointManager , CurrencyValidatorAlignSymbol , CursorBookmark , CursorManager , CursorManagerPriority , DataDescription , DataGridEventReason , DataService , Date , DateBase , DateChooserEventDetail , DefaultDataDescriptor , DeferredInstanceFromClass , DeferredInstanceFromFunction , DescribeTypeCache , Dictionary , DisplacementMapFilterMode , DragManager , DragSource , EdgeMetrics , EffectTargetFilter , Elastic , Endian , Error , Event , EventDispatcher , EventPhase , EventPriority , Exponential , ExternalInterface , FileFilter , FlexPrintJob , FlexPrintJobScaleType , FocusManager , Font , FontStyle , FontType , Formatter , FormItemDirection , FrameLabel , Function , GradientEntry , GradientType , Graphics , GraphicsUtil , GridFitType , HaloColors , HistoryManager , HitData , ID3Info , IMEConversionMode , InstanceCache , int , InterpolationMethod , ItemResponder , JointStyle , Keyboard , KeyLocation , LegendData , Linear , LineScaleMode , LineSeriesSegment , ListBaseSeekPending , ListBaseSelectionData , ListEventReason , ListRowInfo , LoaderConfig , LoaderContext , Locale , Log , LogEventLevel , Managed , Math , Matrix , MBeanFeatureInfo , MBeanInfo , Mouse , Namespace , NameUtil , Number , NumberBase , NumberBaseRoundType , Object , ObjectEncoding , ObjectInstance , ObjectName , ObjectUtil , PageInformation , PixelSnapping , Point , PopUpManager , PopUpManagerChildList , PrintJobOptions , PrintJobOrientation , ProgressBarDirection , ProgressBarLabelPlacement , ProgressBarMode , PropertyChangeEventKind , PropertyChanges , Proxy , QName , Quadratic , Quartic , Quintic , Rectangle , RectangularDropShadow , RegExp , RemoveChild , RenderData , ResourceBundle , Responder , Scene , ScrollBarDirection , ScrollEventDetail , ScrollEventDirection , ScrollPolicy , Security , SecurityDomain , SecurityPanel , ServerConfig , SetProperty , SetStyle , SharedObjectFlushStatus , SimpleXMLDecoder , SimpleXMLEncoder , Sine , SliderDirection , SliderEventClickTarget , SOAPHeader , SolidColor , SoundLoaderContext , SoundMixer , SoundTransform , SpreadMethod , StageAlign , StageQuality , StageScaleMode , String , StringUtil , Stroke , StyleManager , SWFVersion , SwitchSymbolFormatter , System , TextColorType , TextDisplayMode , TextFieldAutoSize , TextFieldType , TextFormat , TextFormatAlign , TextLineMetrics , TextRange , TextRenderer , TextSnapshot , TileBaseDirection , TileDirection , Transform , Transition , UIComponentCachePolicy , UIDUtil , uint , UpdateCollectionRange , URLLoaderDataFormat , URLRequest , URLRequestHeader , URLRequestMethod , URLUtil , URLVariables , ValidationResult , XML , XMLList , XMLNode , XMLNodeType , XMLUtil , ZipCodeValidatorDomainType

Object 클래스는, ActionScript 클래스 계층 루트에 있습니다. object는,new 연산자 문장구조법을 사용한 constructor    으로 작성되어 property를 동적으로 할당할 수가 있습니다. 또, 다음과 같이 object 리터럴을 할당해 작성할 수도 있습니다.
var obj:Object = {a:"foo", b:"bar"}

명시적인 기본 클래스를 선언하고 있지 않은 클래스는 모두, 빌트인 의 Object 클래스를 확장합니다.

Object 클래스를 사용해,결합 배열을 작성할 수 있습니다. 기본적으로, 결합 배열은 Object 클래스의 인스턴스이며, 키치 페어는 property와 그 값이라고 하는 형식에서 표현됩니다. Object 데이터 타입을 사용해 결합 배열을 선언하는 다른 이유는, 그렇다면, object 리터럴을 사용해 결합 배열에 데이터를 설정할 수 있기 때문입니다 (다만, 선언시만). 다음의 예에서는, object 리터럴을 사용해 결합 배열을 작성해, 닷 연산자와 배열 액세스 연산자를 양쪽 모두 사용해 항목에 액세스 합니다. 그 후, 새로운 property를 작성하는 것으로 새로운 키치 페어를 추가합니다.

 var myAssocArray:Object = {fname:"John", lname:"Public"};
 trace(myAssocArray.fname);     // Output: John
 trace(myAssocArray["lname"]);  // Output: Public
 myAssocArray.initial = "Q";
 trace(myAssocArray.initial);   // Output: Q

ActionScript 3.0 에는, 클래스 Inheritance과 prototype Inheritance의 2 개의 타입의 Inheritance이 있습니다.

다음의 예와 같이, 클래스 Inheritance과 prototype Inheritance은 공존 가능합니다.

 class A {
     var x = 1
     prototype.px = 2
 }
 dynamic class B extends A {
     var y = 3
     prototype.py = 4
 }
  
 var b = new B()
 b.x // 1 via class inheritance
 b.px // 2 via prototype inheritance from A.prototype
 b.y // 3
 b.py // 4 via prototype inheritance from B.prototype
  
 B.prototype.px = 5
 b.px // now 5 because B.prototype hides A.prototype
  
 b.px = 6
 b.px // now 6 because b hides B.prototype

클래스 대신에 함수를 사용하면, custom prototype Inheritance 트리를 작성할 수 있습니다. 클래스를 사용하면, prototype Inheritance 트리는 클래스 Inheritance 트리를 밀러 합니다. 다만, prototype object는 동적이기 때문에, prototype 베이스의 property를 실행시에 추가 및 삭제할 수 있습니다.

View the examples

See also

prototype
데이터형의 상세


Public property
 property정의
  constructor : Object
특정의 object 인스턴스의 클래스 object 또는 constructor    함수에의 참조입니다.
Object
  prototype : Object
[static] 클래스 또는 함수 object의 prototype object에의 참조입니다.
Object
Public Methods
 Methods정의
  Object ()
Object object를 작성해, 그 object의 constructor    Methods에의 참조를 object의 constructor property에 포함합니다.
Object
  hasOwnProperty (name:String ):Boolean
object로 지정된 property가 정의되고 있는지 어떤지를 나타냅니다.
Object
  isPrototypeOf (theClass:Object ):Boolean
Object 클래스의 인스턴스가, Parameters로서 지정된 object의 prototype 체인내에 있을지 어떨지를 나타냅니다.
Object
  propertyIsEnumerable (name:String ):Boolean
지정된 property가 존재해, 열거 가능한가 어떤가를 나타냅니다.
Object
  setPropertyIsEnumerable (name:String , isEnum:Boolean = true):void
루프 처리에 대한 다이나믹 property의 가용성을 설정합니다.
Object
  toString ():String
지정된 object의 string 표현을 돌려줍니다.
Object
  valueOf ():Object
지정된 object의 원시적치를 돌려줍니다.
Object
property의 상세
constructorproperty
public var constructor:Object

특정의 object 인스턴스의 클래스 object 또는 constructor    함수에의 참조입니다. object가 클래스의 인스턴스의 경우,constructor property는 클래스 object에의 참조를 보관 유지합니다. object가 constructor    함수로 작성되고 있는 경우,constructor property는 constructor    함수에의 참조를 보관 유지합니다. constructor    함수와 클래스의 constructor    Methods를 혼동 하지 않게 주의해 주세요. constructor    함수는, object의 작성에 사용하는 Function object로, 클래스의 정의에 class 키워드를 사용하는 것 대신에 됩니다.

class 키워드를 사용해 클래스를 정의하고 있는 경우, 클래스의 prototype object에는, 클래스 object에의 참조를 보관 유지하는 constructor 라는 이름의 property를 할당할 수 있습니다. 클래스의 인스턴스는, prototype object로부터 이 property를 Inheritance합니다. 예를 들어, 다음의 코드에서는 새로운 클래스 A, 및 myA 라는 이름의 클래스 인스턴스를 작성합니다.

  dynamic class A {}
  trace(A.prototype.constructor);      // [class A]
  trace(A.prototype.constructor == A); // true
  var myA:A = new A();
  trace(myA.constructor == A);         // true

상급 유저의 경우는,class 키워드 대신에 function 키워드를 사용해, object 작성의 템플릿으로서 사용 가능한 Function object를 정의할 수 있습니다. 이러한 함수는,new 연산자와 조합해 object를 작성할 수 있기 (위해)때문에, constructor    함수로 불리고 있습니다. function 키워드를 사용해 constructor    함수를 작성하는 경우, 그 prototype object에는, constructor    함수에의 참조를 보관 유지하는 constructor 라는 이름의 property를 할당할 수 있습니다. 다음에, constructor    함수를 사용해 object를 작성하면, 그 object는 constructor    함수의 prototype object로부터 constructor property를 Inheritance합니다. 예를 들어, 다음의 코드에서는 새로운 constructor    함수 f, 및 myF 라는 이름의 object를 작성합니다.

  function f() {}
  trace(f.prototype.constructor);      // function Function() {}
  trace(f.prototype.constructor == f); // true
  var myF = new f();
  trace(myF.constructor == f);         // true

메모 :constructor property는 기입해 가능합니다. 즉, 할당 명령문(statement)를 사용해 유저 코드로 값을 변경할 수 있습니다. constructor property의 값의 변경은 추천합니다만,constructor property의 값에 의존한 코드를 쓰는 경우는, 그 값이 리셋트 되지 않게 할 필요가 있습니다. prototype object (예를 들어,className.prototype.constructor)를 사용해 property에 액세스 할 경우에만, 이 값을 변경할 수 있습니다.

See also

prototypeproperty 
public static var prototype:Object

클래스 또는 함수 object의 prototype object에의 참조입니다. prototype property는 자동적으로 작성되어 작성한 클래스 또는 함수 object에 할당할 수 있습니다. 이 property는, 작성한 클래스 또는 함수에 고유하다라고 말하는 점으로써 정적입니다. 예를 들어, 클래스를 작성하면,prototype property의 값은, 그 클래스의 모든 인스턴스로 공유되어 클래스 property로서의 보고 액세스 할 수 있습니다. 클래스의 인스턴스는,prototype property에 직접 액세스 할 수 없습니다.

클래스의 prototype object는, 그 클래스의 특별한 인스턴스이며, 클래스의 모든 인스턴스간에 상태를 공유하기 위한 메카니즘을 제공합니다. 실행시에, 클래스 인스턴스에 property가 발견되지 않는 경우는, 위양처인 클래스의 prototype object에 그 property가 없는가가 체크됩니다. prototype object에도 없는 경우는, 그 property가 발견될 때까지, prototype object의 위양처에서 체크를 실시한다고 하는 처리가 계층의 상위로 향해 연속적으로 계속됩니다.

메모: ActionScript 3.0 에서는, prototype Inheritance은 주요한 Inheritance 메카니즘이 아닙니다. ActionScript 3.0 에서의 주요한 Inheritance 메카니즘은, 클래스 정의의 고정 property를 Inheritance하는 클래스 Inheritance입니다.

See also

constructor    의 상세
Object()constructor   
public 함수 Object()

Object object를 작성해, 그 object의 constructor    Methods에의 참조를 object의 constructor property에 포함합니다.

See also

Methods의 상세
hasOwnProperty()Methods
AS3 function hasOwnProperty(name:String ):Boolean

object로 지정된 property가 정의되고 있는지 어떤지를 나타냅니다. 타겟 object에 name Parameters로 지정된 string에 일치하는 property가 있는 경우는 true 를 돌려줍니다. 그 이외의 경우는 false 를 돌려줍니다. 다음의 타입의 property에 대해서는, object가 클래스 object는 아니고, 클래스의 인스턴스인 경우에 true 가 돌려주어집니다.

다음의 타입의 property에 대해서는, object가 클래스의 인스턴스인 경우에 false 가 돌려주어집니다.

또, ActionScript 3.0 에는, 클래스 정의의 직접적인 표현인 클래스 object가 있습니다. hasOwnProperty() Methods를 클래스 object에 대해서 호출하면, property가 그 클래스 object에 정의된 정적 property인 경우에게만,true 가 돌려주어집니다. 예를 들어, CustomArray 라고 하는 Array 의 서브 클래스를 작성해, CustomArray 에 foo 라고 하는 정적 property를 정의했을 경우,CustomArray.hasOwnProperty("foo") 를 호출하면 true 가 돌려주어집니다. 다만, Array 클래스에 정의한 정적 property DESCENDING 의 경우,CustomArray.hasOwnProperty("DESCENDING") 를 호출하면,false 가 돌려주어집니다.

메모: Object 클래스의 Methods는, Object 의 prototype에 동적으로 작성됩니다. Object 의 서브 클래스에서 이 Methods를 재정의하는 경우는,override 키워드를 사용하지 말아 주세요. 예를 들어, Object 의 서브 클래스에서는, 기본 클래스의 재정의(override)를 사용하는 대신에 function hasOwnProperty() :Boolean 가 Implements됩니다.

Parameters
name:String — object의 property입니다.

반환값
Boolean — 타겟 object에 name Parameters로 지정된 property가 있는 경우, 이 값은 true 가 되어, 그 이외의 경우는 false 가 됩니다.
isPrototypeOf()Methods 
AS3 function isPrototypeOf(theClass:Object ):Boolean

Object 클래스의 인스턴스가, Parameters로서 지정된 object의 prototype 체인내에 있을지 어떨지를 나타냅니다. 이 Methods는, object가 theClass Parameters로 지정된 object의 prototype 체인내에 있는 경우에 true 를 돌려줍니다. 타겟 object가 theClass object의 prototype 체인내에 없는 경우, 및 theClass Parameters가 object가 아닌 경우도,false 를 돌려줍니다.

메모: Object 클래스의 Methods는, Object 의 prototype에 동적으로 작성됩니다. Object 의 서브 클래스에서 이 Methods를 재정의하는 경우는,override 키워드를 사용하지 말아 주세요. 예를 들어, Object 의 서브 클래스에서는, 기본 클래스의 재정의(override)를 사용하는 대신에 function isPrototypeOf() :Boolean 가 Implements됩니다.

Parameters
theClass:Object — 지정한 object가 참조할 가능성이 있는 클래스입니다.

반환값
Boolean — object가 theClass Parameters로 지정된 object의 prototype 체인내에 있는 경우, 이 값은 true 가 되어, 그 이외의 경우는 false 가 됩니다.
propertyIsEnumerable()Methods 
AS3 function propertyIsEnumerable(name:String ):Boolean

지정된 property가 존재해, 열거 가능한가 어떤가를 나타냅니다. true 의 경우, 이 property가 존재해,for..in 루프로 열거할 수 있습니다. 이 Methods에서는 타겟 object의 prototype 체인을 체크하지 않기 때문에, property가 타겟 object상에 존재하고 있을 필요가 있습니다.

작성하는 property는 열거할 수 있습니다만, 빌트인 property는 통상 열거할 수 없습니다.

메모: Object 클래스의 Methods는, Object 의 prototype에 동적으로 작성됩니다. Object 의 서브 클래스에서 이 Methods를 재정의하는 경우는,override 키워드를 사용하지 말아 주세요. 예를 들어, Object 의 서브 클래스에서는, 기본 클래스의 재정의(override)를 사용하는 대신에 function propertyIsEnumerable() :Boolean 가 Implements됩니다.

Parameters
name:String — object의 property입니다.

반환값
Boolean name Parameters로 지정된 property가 열거 가능한 경우, 이 값은 true 가 되어, 그 이외의 경우는 false 가 됩니다.
setPropertyIsEnumerable()Methods 
public function setPropertyIsEnumerable(name:String , isEnum:Boolean = true):void

루프 처리에 대한 다이나믹 property의 가용성을 설정합니다. 이 Methods에서는 타겟 object의 prototype 체인을 체크하지 않기 때문에, property가 타겟 object상에 존재하고 있을 필요가 있습니다.

Parameters
name:String — object의 property입니다.
 
isEnum:Boolean (default = true)false 로 설정했을 경우, 다이나믹 property는 for..in 루프에 나타나지 않고,propertyIsEnumerable() Methods는 false 를 돌려줍니다.

See also

toString()Methods 
public function toString():String

지정된 object의 string 표현을 돌려줍니다.

메모: Object 클래스의 Methods는, Object 의 prototype에 동적으로 작성됩니다. Object 의 서브 클래스에서 이 Methods를 재정의하는 경우는,override 키워드를 사용하지 말아 주세요. 예를 들어, Object 의 서브 클래스에서는, 기본 클래스의 재정의(override)를 사용하는 대신에 function toString() :String 가 Implements됩니다.

반환값
String — object의 string 표현입니다.
valueOf()Methods 
public function valueOf():Object

지정된 object의 원시적치를 돌려줍니다. 이 object에 원시적치가 없는 경우, object 자체가 돌려주어집니다.

메모: Object 클래스의 Methods는, Object 의 prototype에 동적으로 작성됩니다. Object 의 서브 클래스에서 이 Methods를 재정의하는 경우는,override 키워드를 사용하지 말아 주세요. 예를 들어, Object 의 서브 클래스에서는, 기본 클래스의 재정의(override)를 사용하는 대신에 function valueOf() :Object 가 Implements됩니다.

반환값
Object — 이 object의 원시적치, 또는 object 자체입니다.

See also

Examples

다음의 예에서는,ObjectExample 클래스와 Circle 클래스를 사용해, Object 클래스의 동적인 특징과 값object를 Shape object로 변환해, 스테이지상의 지정한 x 및 y 좌표에 추가하는 방법을 나타냅니다.

이 예에서는, 값object firstInitObjsecondInitObj 를 작성합니다. custom 클래스 Circle 는, 값object를 받아들여 대응하는 내부 property를 값object에 정의된 property로 설정하면서 루프 합니다.

package {
    import flash.display.Sprite;

    public class ObjectExample extends Sprite {
        public function ObjectExample() {
            var firstInitObj:Object = new Object();
            firstInitObj.bgColor = 0xFF0000;
            firstInitObj.radius = 25;
            firstInitObj.xCenter = 25;
            firstInitObj.yCenter = 25;
                        
            var firstCircle:Circle = new Circle(firstInitObj);
            addChild(firstCircle);
            firstCircle.x = 50;
            firstCircle.y = 50;

            var secondInitObj:Object = {bgColor:0xCCCCCC, radius:50, xCenter:50, yCenter:50};

            var secondCircle:Circle = new Circle(secondInitObj);            
            addChild(secondCircle);
            secondCircle.x = 100;
            secondCircle.y = 100;
        }
        
    }
}

import flash.display.Shape;
    
class Circle extends Shape {
    public var bgColor:Number = 0xFFFFFF;
    public var radius:Number = 0;
    public var xCenter:Number = 0;
    public var yCenter:Number = 0;
        
    public function Circle(initObj:Object) {
        for(var i:String in initObj) {
            this[i] = initObj[i];
        }
        draw();
    }
        
    public function draw() :void {
        graphics.beginFill(bgColor);
        graphics.drawCircle(xCenter, yCenter, radius);
        graphics.endFill();
    }
}






 

코멘트가 추가되었을 경우, 메일로 받기. | 코멘트 리포트

현재의 페이지: http://flexdocs.kr/docs/flex2/langref/Object.html