2 Replies Latest reply on Mar 21, 2009 3:32 PM by Mainmanian

    creationComplete behavior

    Mainmanian Level 1
      In a component in my app, I have been using creationComplete event to do some initialization. As I wanted some specific state behavior, I stopped using creationComplete on that component, but I still wanted an init procedure executed every time the state changed which required the component to start from scratch in its logic and its variables. So, I decided to use enterState event in my application to trigger the init procedure.

      For some reason that I am unable to comprehend, the component does not work the same way as it did when I had creationComplete. This happens even when I start for the first time meaning when the component is initialized and not just in repeat calls to the component.

      Any insight in to why this might be is very much appreciated. Thanks
        • 1. Re: creationComplete behavior
          Gregory Lafrance Level 6
          What exactly has changed?
          • 2. Re: creationComplete behavior
            Mainmanian Level 1
            The Video Object does not seem to get created or added. basically the video does not show up. The video shows up if I use creationComplete and initApp() instead of calling enterArchivesPlayerWindow() from the main app. The pseudo code is shown below.

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Canvas creationComplete="initApp()" xmlns:mx=" http://www.adobe.com/2006/mxml"
            xmlns:ns1="myApp.components.*"
            paddingBottom="0" paddingRight="0" paddingTop="0" paddingLeft="0"
            horizontalCenter="0" verticalCenter="0"
            backgroundColor="white"
            width="575" height="323">


            <mx:Script>
            <![CDATA[
            public function initApp():void {
            this.playVideo(null);
            }
            public function enterArchivesPlayerWindow():void{
            this.playVideo(null);
            }

            public function playVideo(event:MouseEvent):void{
            var tempStr:String = this.parentApplication.getUserProfile().getUserId();
            try {
            nc=new NetConnection ;
            nc.addEventListener (NetStatusEvent.NET_STATUS,checkConnect);

            rtmpNow=this.parentApplication.getRtmpUrl();
            nc.connect (rtmpNow,this.parentApplication.getNetConnectArg());
            }catch(error:Error) {
            }
            }

            private function checkConnect (e:NetStatusEvent):void {
            trace(this.name,e.info.code);
            try{
            good=e.info.code == "NetConnection.Connect.Success";
            if (good){
            courseStream=new NetStream(nc);

            vid=new Video(width,height);
            this.rawChildren.addChild(vid);
            vid.attachNetStream (courseStream);

            courseStream.play (streamname);
            } else {
            trace("ArchivesPlayerWindow: Error", e.info.code);
            }
            }catch(err:Error){
            trace("ArchivesPlayerWindow: Error", e.info.code);
            }
            }
            ]]>
            </mx:Script>
            </mx:Canvas>