Avatar of JoachimPetersen
Flag for Denmark

asked on 

adding child problems - Error #1009 (Cannot access a property or method of a null)

Hello guys, I am having some problems with this, I am using stagewebviewbridge, the problem is that when I reload the stage (navigator.pushView) I get Error #1009, here is my code (it works fine on first load) at the line with addChild.
			import es.xperiments.media.StageWebViewBridge;
			import es.xperiments.media.StageWebViewBridgeEvent;
			import es.xperiments.media.StageWebViewDisk;
			import es.xperiments.media.StageWebviewDiskEvent;
			import flash.media.StageWebView;
			import mx.events.FlexEvent;
			protected var webView:StageWebViewBridge;
			private var _stageComponentHeight:Number;
			private var _stageComponentWidth:Number;
			private var _pageWidth:Number;
			private var _pageHeight:Number;
			public var tracetxt:String;
			protected function view1_addedToStageHandler(event:Event):void
				StageWebViewDisk.setDebugMode( true );
				// if we need debug mode assign it before initializaton
				// StageWebViewDisk Events. First time app launches it proceses the filesystem
				// As it can take some time, depending of the filesize of the included files
				// we provide 2 events to know when process start/finish
				StageWebViewDisk.addEventListener(StageWebviewDiskEvent.START_DISK_PARSING, onDiskCacheStart);
				StageWebViewDisk.addEventListener(StageWebviewDiskEvent.END_DISK_PARSING, onDiskCacheEnd);
				StageWebViewDisk.initialize( this.stage );
			protected function onDiskCacheStart(e:StageWebviewDiskEvent):void
				trace("SWVD parsing started");
				trace("SWVD parsing started\n");
			protected function onDiskCacheEnd(e:StageWebviewDiskEvent):void
				trace("SWVD parsing ended");
				trace("SWVD parsing ended\n");
				_stageComponentHeight= 400; //stage.height;
				_stageComponentWidth = 400; //stage.width;
				webView = new StageWebViewBridge(0,0,_stageComponentWidth,_stageComponentHeight);
				webView.addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
				//webView.addCallback('highlightSelectedPage', highlightSelectedPage );
				SWVB.addChild(webView);   //error occurs here at second load
                                //error occurs at above line.
			protected function onAddedToStage(e:Event):void	
				trace("calling the URL\n");
				trace("called added stage");
			protected function SWVB_creationCompleteHandler(event:FlexEvent):void
				// TODO Auto-generated method stub
				trace("SWVB_creationCompleteHandler called\n");

Open in new window

What can the problem be?
Here is a sample project for flash builder:
Run the program and click the button at the top on the first view.
Apache FlexAdobe Flash

Avatar of undefined
Last Comment

8/22/2022 - Mon