Solved

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

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
FLV versus SWF 11 277
Action Script coding 1 175
PowerPoint 2010 – some controls on this presentation can’t be activated. 2 399
Install adobe flash plugin for Firefox win 7 9 70
First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
Here are some practices and techniques that can be adopted into your Flash/Flex application development process. Note: Not all "performance tips" provide an immediately-recognizable benefit.   This article does not include timing validation data,…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to how to record live broadcast.

776 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