2012-02-29 3 views
0

complete 이벤트를 보내기 전에 actionscript의 custom preloader 코드에서 main flex app의 함수를 호출하려고합니다.코드에서 프리 로더의 애플리케이션에서 함수 호출하기

 parentApplication = event.currentTarget.loaderInfo.content.application; 
: 또한 내가 응용 프로그램을 얻을 그래서 프리 로더 init 메소드에 다음과 같은 라인을 사용하여 응용 프로그램에서 프리 로더 코드에서 함수에 다시

감사

+0

프리 로더 코드를 공유하십시오. 문제 설명이 명확하지 않습니다. –

+0

특정 문제가 무엇이든지간에 아키텍처를 다시 고려해야합니다. 즉, 응용 프로그램이 준비되고 응용 프로그램이 준비 될 때 사라질 수있는 프리 로더의 본질입니다. 두 가지 질문은이 아이디어와 모순이됩니다. – RIAstar

+0

실제로이 작업을 수행합니다. 어떤 경우에는 모호한 것처럼 보일 수도 있지만, 우리는 주 swf 파일을로드 한 다음 데이터 시작을 위해 여분의 요청을 많이합니다. 프리 로더를 계속 실행하는 동안 시간이 좀 걸릴 수 있기 때문입니다. 유익하고 재미있는 정보를 제공하는 응용 프로그램). 기본적으로 프리 로더에 메소드를 넣고 애플리케이션이 완료되면 메소드를 통해 프리 로더에 전달되고 프리 로더는 다시 메소드를 통해 애플리케이션으로 전달되어 통신 브릿지를 만듭니다. – shaunhusain

답변

0

를 호출하는 방법을 알고 싶어요

우리는 우리의 프리 로더가 IPreloader라는 사용자 지정 인터페이스를 구현하고 우리의 응용 프로그램이 IPreloaderApp라는 사용자 지정 인터페이스를 구현, IPreloader가 정의했듯이 :

package com.roundarch.adapt.preloader 
{ 
    import mx.preloaders.IPreloaderDisplay; 

    public interface IPreloader extends IPreloaderDisplay 
    { 
     /** 
     * Setting this will update the preloader's percentage bar or graphic. 
     */ 
     function set percentage(value:Number):void; 
     function get percentage():Number; 

     /** 
     * Sets the status (if available) on the preloader. 
     */ 
     function set status(value:String):void; 

     /** 
     * This will communicate to the preloader that loading of all application 
     * properties is complete. 
     */ 
     function loadingComplete():void; 

     /** 
     * This will tell the preloader that there has been an error loading the application. 
     * 
     * The preloader will probably want to display this error message in a nice display to 
     * the user. 
     * 
     * @param errorString The error message to display. 
     * @param fatal If true, the preloader should act as if the application will not run perhaps 
     * by notifying the user that they cannot continue. 
     * @return Should return true if the error was properly handled. 
     */ 
     function displayError(errorString:String, fatal:Boolean=false):Boolean; 

     /** 
     * Returns true if this IPreloader implementation can handle displaying loading 
     * errors through the error(...) method. If false, the implementing application will 
     * need to notify the user of any errors itself. 
     */ 
     function get canDisplayErrors():Boolean; 
    } 
} 
,

앱이 프리 로더 뒤에 대신에 전면 (기본 동작) 다음 응용 프로그램에서 팝업되는 경고가 표시되지 않습니다 추가되는 경우도 IPreloaderApp

package com.roundarch.adapt.preloader 
{ 

    /** 
    * Any application which uses an IPreloader as its preloader will be 
    * required to implement this interface or throw an error. 
    */ 
    public interface IPreloaderApp 
    { 
     /** 
     * Once the application has loaded and initialized, this method will be called on the 
     * application and the preloader will be passed in so the app can make updates to it. 
     */ 
     function preloaderInit(preloader:IPreloader):void; 
    } 
} 

뭔가,주의 할 그들은 preloader 뒤에있을 것이므로 주문을 전환하고 싶을 것입니다. 여기에 우리가 해결하기 위해 사용되는 코드의 비트의 다음 parentApplication가 프리 로더 초기화 핸들러 내에서 설정

private var removedOnce : Boolean; 

    //When the Preloader class instance (this things parent) is removed from it's parent 
    //add this to the stage, allows us to dispatch the complete event at the corret time 
    //allowing the SystemManager to add the application to the stage and adding this at 
    //index 0 to allow pop-ups to show over it. 
    private function parentRemoved(event : Event) : void 
    { 
     if (!removedOnce) 
     { 
      removedOnce = true; 

      stage.addChildAt(this, 0); 
      ToolTipManager.enabled = false; 
     } 
    } 

후 우리가로 프리 로더의 제거를 잡으려고 처리기를 추가이 게시물의 상단에 그림과 같이 SystemManager가와 (눈에 보이는 깜박 거림이없는)를 재 - 추가

 //Lets the system manager know to add the application to the stage 
     //this will also remove the preloader for this reason I'm listening for the removal 
     //then adding the preloader to the stage again 
     parent.addEventListener(Event.REMOVED, parentRemoved); 
     dispatchEvent(new Event(Event.COMPLETE)); 
주목해야 할 또 한가지는 당신이에서 일을 포함하는 경우, 어떤 플렉스 클래스와 함께 프리 로더 코드를 "오염"싶어하지 않는다는 것입니다

프레임 워크를 사용하면 프리 로더가 시작되기 전에 전체 프레임 워크를 메모리에로드해야하는 번거 로움이 있습니다.

+0

좋아요, 이제 당신이하는 말을 이해합니다. 당신의 도움을 주셔서 감사합니다. – user1190524

+0

안녕하세요 저는 회사의 다른 사람들이 일했던 코드를 게시하고 싶지 않아 농장을 포기하고 싶지는 않습니다. 당신이 시작하고 게시 해야하는 부분의 단순화 된 버전. – shaunhusain