Solved

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

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

Accepted Solution

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

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I know the transition can be hard. We got used to the ease of use ActionScript 2 had, but honestly, it became problematic later on, especially if designers were involved in the project and found it easy to add code as they saw fit. So, this artic…
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 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.
This Micro Tutorial will teach to how to utilize bit rate in Adobe Flash Media Live Encoder.

746 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now