?
Solved

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

Posted on 2014-02-20
1
Medium Priority
?
556 Views
Last Modified: 2014-02-24
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;
			[Bindable]
			private var _pageWidth:Number;
			[Bindable]
			private var _pageHeight:Number;
			[Bindable]
			public var tracetxt:String;
			
			
			
			protected function view1_addedToStageHandler(event:Event):void
			{
				_pageWidth=this.width;
				_pageHeight=this.height;
				
				
				// OPTIONAL BEFORE INIT OPTIONS SETTING
				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");
				webView.loadURL("http://www.google.com");
				webView.reload();
				
			}
			
			protected function SWVB_creationCompleteHandler(event:FlexEvent):void
			{
				// TODO Auto-generated method stub
				trace("SWVB_creationCompleteHandler called\n");
				//webView.loadURL("http://www.indecommglobal.com");
				
			}

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.
Code:
www.speedyshare.com/DXc6Q/testingBirdge.fxp
0
Comment
Question by:JoachimPetersen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
JoachimPetersen earned 0 total points
ID: 39882095
put the addChild in the addedtostage handler
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently, I was asked to recommend a tracking system to be implemented on a clients website. As the entire site was built on flash, my first thought was to suggest custom built tracking system. However, our company at that point of time didn't h…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
Suggested Courses

718 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question