Solved

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

Posted on 2014-02-20
1
535 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

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 last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.
Suggested Courses

739 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