This page was saved using jaction on 2006-09-04 8:33:25.
Address: http://flexdocs.kr/docs/flex2/langref/flash/system/ApplicationDomain.html
Title: flash.system.ApplicationDomain (Flex™ 2 레퍼런스 가이드)  •  Size: 32224
Packageflash.system
Classpublic final class ApplicationDomain
InheritanceApplicationDomain Inheritance Object

ApplicationDomain 클래스는, 클래스 정의의 개별의 그룹의 컨테이너입니다. 어플리케이션 도메인은, 같은 시큐러티 도메인내에 있는 클래스를 분할하기 위해서 사용됩니다. 같은 클래스의 복수의 정의가 존재하는 것, 및 아이가 부모의 정의를 재이용하는 것이 가능하게 됩니다.

어플리케이션 도메인은, 외부 SWF 파일이 Loader 클래스에 의해 로드 되는 경우에 사용됩니다. 로드 되는 SWF 파일의 모든 ActionScript 3.0 정의는, 어플리케이션 도메인에 보존됩니다. 어플리케이션 도메인은, Loader object의 load() 또는 loadBytes() Methods의 context Parameters로서 건네주는 LoaderContext object의 applicationDomain property에 의해 지정됩니다. LoaderInfo object에도 applicationDomain property가 있습니다. 이것은 읽기 전용(read-only)입니다.

SWF 파일내의 모든 코드는, 어플리케이션 도메인내에 존재하도록(듯이) 정의됩니다. 현재의 어플리케이션 도메인은, 메인 어플리케이션이 실행되고 있는 장소입니다. 현재의 도메인 등, 모든 어플리케이션 도메인은, 시스템 도메인에 포함됩니다. 즉, 시스템 도메인에는 모든 Flash Player 클래스가 포함됩니다.

시스템 도메인을 제외한 모든 어플리케이션 도메인에는, 친도메인을 관련지을 수 있습니다. 메인 어플리케이션의 어플리케이션 도메인에 대한 친도메인은, 시스템 도메인입니다. 로드 되는 클래스는, 그 부모에 의해 아직 정의되어 있지 않은 경우에게만 정의됩니다. 로드 되는 클래스의 정의를 새로운 정의로 재정의(override) 할 수 없습니다.

어플리케이션 도메인의 사용예에 대해서는, 「ActionScript 3.0 의 프로그래밍」을 참조해 주세요.

ApplicationDomain() constructor    함수를 사용하면, ApplicationDomain object를 작성할 수 있습니다.

View the examples

See also

flash.display.Loader.load()
flash.display.Loader.loadBytes()
flash.display.LoaderInfo
flash.net.URLRequest
flash.system.LoaderContext
ApplicationDomain 클래스


Public property
 property정의
 Inheritedconstructor : Object
특정의 object 인스턴스의 클래스 object 또는 constructor    함수에의 참조입니다.
Object
  currentDomain : ApplicationDomain
[static][read-only] 코드가 실행되고 있는 현재의 어플리케이션 도메인을 취득합니다.
ApplicationDomain
  parentDomain : ApplicationDomain
[read-only] 이 어플리케이션 도메인의 친도메인을 취득합니다.
ApplicationDomain
 Inheritedprototype : Object
[static] 클래스 또는 함수 object의 prototype object에의 참조입니다.
Object
Public Methods
 Methods정의
  ApplicationDomain (parentDomain:ApplicationDomain = null)
새로운 어플리케이션 도메인을 작성합니다.
ApplicationDomain
  getDefinition (name:String ):Object
지정된 어플리케이션 도메인으로부터 일반 정의를 취득합니다.
ApplicationDomain
  hasDefinition (name:String ):Boolean
지정된 어플리케이션 도메인내에 일반 정의가 존재할지 어떨지를 확인합니다.
ApplicationDomain
 InheritedhasOwnProperty (name:String ):Boolean
object로 지정된 property가 정의되고 있는지 어떤지를 나타냅니다.
Object
 InheritedisPrototypeOf (theClass:Object ):Boolean
Object 클래스의 인스턴스가, Parameters로서 지정된 object의 prototype 체인내에 있을지 어떨지를 나타냅니다.
Object
 InheritedpropertyIsEnumerable (name:String ):Boolean
지정된 property가 존재해, 열거 가능한가 어떤가를 나타냅니다.
Object
 InheritedsetPropertyIsEnumerable (name:String , isEnum:Boolean = true):void
루프 처리에 대한 다이나믹 property의 가용성을 설정합니다.
Object
 InheritedtoString ():String
지정된 object의 string 표현을 돌려줍니다.
Object
 InheritedvalueOf ():Object
지정된 object의 원시적치를 돌려줍니다.
Object
property의 상세
currentDomainproperty
currentDomain:ApplicationDomain   [read-only]

코드가 실행되고 있는 현재의 어플리케이션 도메인을 취득합니다.

Implements
    public static function get currentDomain():ApplicationDomain

See also

parentDomainproperty 
parentDomain:ApplicationDomain   [read-only]

이 어플리케이션 도메인의 친도메인을 취득합니다.

Implements
    public function get parentDomain():ApplicationDomain

See also

constructor    의 상세
ApplicationDomain()constructor   
public 함수 ApplicationDomain(parentDomain:ApplicationDomain = null)

새로운 어플리케이션 도메인을 작성합니다.

Parameters
parentDomain:ApplicationDomain (default = null) — 친도메인이 건네받지 않는 경우, 이 어플리케이션 도메인은 시스템 도메인을 친도메인으로 합니다.
Methods의 상세
getDefinition()Methods
public function getDefinition(name:String ):Object

지정된 어플리케이션 도메인으로부터 일반 정의를 취득합니다. 정의에는, 클래스, namespace, 또는 함수의 정의가 있습니다.

Parameters
name:String — 정의의 이름.

반환값
Object — 정의에 관련지을 수 있었던 object.

Throws
ReferenceError — 지정된 이름의 일반 정의는 존재하지 않습니다.
hasDefinition()Methods 
public function hasDefinition(name:String ):Boolean

지정된 어플리케이션 도메인내에 일반 정의가 존재할지 어떨지를 확인합니다. 정의에는, 클래스, namespace, 또는 함수의 정의가 있습니다.

Parameters
name:String — 정의의 이름.

반환값
Boolean — 지정된 정의가 존재하는 경우는 true 를 돌려줍니다. 포함되지 않는 경우는 false 를 돌려줍니다.
Examples

다음의 예에서는, 실행시의 클래스의 로드를 나타냅니다.

메모 :

최초로, 이하의 코드로부터 RuntimeClasses.swf 파일을 작성합니다.

  package {
  import flash.display.Sprite;
       
      public class RuntimeClasses extends Sprite {
          public function RuntimeClasses() {
           }        
       }
   }
   
  import flash.display.Sprite;
  import flash.text.TextField;
   
  class Greeter {
      private var greeting:String;
      
      public function Greeter() {
          greeting = "Hello World";
       }
       
      public function greet() :String {
          return greeting;
       }
   }
   
  class VisualGreeter extends Sprite {
      private var greeting:String;
      private var txt:TextField;
            
      public function VisualGreeter() {
          greeting = "Hello World";
          txt = new TextField();
          txt.text = greeting;
          txt.background = true;
          txt.backgroundColor = 0xFF0000;
       }
            
      public function greet() :String {
          addChild(txt);
          return txt.text
       }
  }
  

다음에, 이하의 코드를 Implements합니다.



package {
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.errors.IllegalOperationError;
    import flash.events.Event;

    public class ApplicationDomainExample extends Sprite {
        private var loader:ClassLoader;
        
        public function ApplicationDomainExample() {
            loader = new ClassLoader();
            loader.addEventListener(ClassLoader.LOAD_ERROR, loadErrorHandler);
            loader.addEventListener(ClassLoader.CLASS_LOADED, classLoadedHandler);
            loader.load("RuntimeClasses.swf");
        }
        
        private function loadErrorHandler(e:Event) :void {
            throw new IllegalOperationError("Cannot load the specified file. ");
        }
        
        private function classLoadedHandler(e:Event) :void {
            var greeterClassRef:Class = loader.getClass("Greeter");
            var greeter:Object = new greeterClassRef();
            trace(greeter.greet()); // Hello World
            
            greeterClassRef = loader.getClass("VisualGreeter");
            greeter = new greeterClassRef();
            addChild(DisplayObject(greeter));
            greeter.greet();
        }
    }
}

import flash.display.Loader;
import flash.errors.IllegalOperationError;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.events.IOErrorEvent;
import flash.events.SecurityErrorEvent;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;

class ClassLoader extends EventDispatcher {
    public static var CLASS_LOADED:String = "classLoaded";
    public static var LOAD_ERROR:String = "loadError";
    private var loader:Loader;
    private var swfLib:String;
    private var request:URLRequest;
    private var loadedClass:Class;
    
    public function ClassLoader() {
        loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
        loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
        loader.contentLoaderInfo.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
    }
    
    public function load(lib:String) :void {
        swfLib = lib;
        request = new URLRequest(swfLib);
        var context:LoaderContext = new LoaderContext();
        context.applicationDomain = ApplicationDomain.currentDomain;
        loader.load(request, context);
    }
        
    public function getClass(className:String) :Class {
        try {
            return loader.contentLoaderInfo.applicationDomain.getDefinition(className) as Class;
        }
        catch(e:Error) {
            throw new IllegalOperationError(className + " definition not found in " + swfLib);
        }
        return null;    
    }
    
    private function completeHandler(e:Event) :void {
        dispatchEvent(new Event(ClassLoader.CLASS_LOADED));
    }
    
    private function ioErrorHandler(e:Event) :void {
        dispatchEvent(new Event(ClassLoader.LOAD_ERROR));
    }
    
    private function securityErrorHandler(e:Event) :void {
        dispatchEvent(new Event(ClassLoader.LOAD_ERROR));
    }
}






 

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

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