flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CodeGirl <MichelleNicho...@yahoo.com>
Subject Re: EventListener null reference error
Date Sun, 28 Aug 2016 15:52:17 GMT
You just wonderfully described what I suspected was causing my problem and I
appreciate that it was designed that way.  Except when it came to my event
listener.  I need to know in a grand parent when an option is changed at the
grand child level.  Sure the event wont be triggered until I am in the great
grandchild.  And thats fine.  But the problem is creating the eventlistener
at the great grandparents level when the great grandchild has not yet been
instantiated.  I am not trying to pass data down.  Though I am doing that
and thanks to your description, I may need to rethink that.  But my problem
is not about passing data down but rather setting up an eventlistener up. 
Which yes, it will pass data up too.  I am using an event class to do this. 
In this case, the selected url to the texture I need to use as a skin to my
3D image.  But since my first attempt to describe what is giving me an
error, I will attempt some code.

I have the main app which displays a tab Navigator for the actual app, the
settings, and company.  Here, I am loading all the lookup tables which I do
push down to the children because I have struggled with data not displaying
properly because data has not yet loaded.  Getting the lookup data here has
solved this problem.
The first tab is a Group which is the main app.  Inside this MXML file are
two MXML components which are panels.  Also, this is where I have my event
One panel is the imagePanel which displays the 3D image with the options
selected in the Options Panel
The second panel is the Options Panel.  In that panel, I have the Navigator
Tabs which associated in each tab is the Barn Options which are the length
width, height, the pitch and barn texture.  
In the Roof Options tab, it lists the roof color, the over hang, and if you
want a facad for the over hang.
The third tab is the Misc Options such as do you want a porch or do you want
vents in the roof and such.

So the grand parent is the where I listen for changes in options and then
passes those changes to the image panel.  So, here is some of my code.  The
first is from the Grand Parent creation complete function.
Notice I have the roof color event listener commented out so my app runs
without error.  Notice that the barn event listeners are fine since that tab
is instantiated automatically.  But I need the roof color changed event
listener.  Well and I will need event listeners for all the other options in
all the options tabs.

			protected function group1_creationCompleteHandler(event:FlexEvent):void
				defaultColorURL = colors.lookupColorByID(defaultcolorID).url;
				defaultRoofColorURL = colors.lookupColorByID(defaultroofcolorID).url;
				imagePanel.barn = new Barn(defaultWidth, defaultLength, defaultHeight,
				imagePanel.barn.barnAngle = imagePanel.sidesDDL.selectedItem.angle;
				loaders = new Dictionary();
				images = new Dictionary();
				var urlLoader:URLLoader = new URLLoader();
				urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
				urlLoader.load(new URLRequest(defaultRoofColorURL));
				loaders[urlLoader] = "Roof";
				urlLoader = new URLLoader();
				urlLoader.dataFormat = URLLoaderDataFormat.BINARY;
				urlLoader.load(new URLRequest(defaultColorURL));
				loaders[urlLoader] = "Sides";

				barnSide = defaultsideID;
//				optionsView.roofOptions.addEventListener(ChangeRoofColor.CHANGED,

Just in case there might be some reason why you may need to know how I am
firing my events, here is some of the code of one of my grandchildren.

<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009" 
		 width="400" height="300"
		[Event(name="roofColorChanged", type="events.ChangeRoofColor")]
		<s:FormItem label="Colors:" height="200">
			<mx:ColorPicker id="roofColorPKR" width="200" height="50"

And here is the event class

package events
	import flash.events.Event;
	public class ChangeRoofColor extends Event
		public static const CHANGED:String = "roofColorChanged";
		public var url:String;
		public function ChangeRoofColor(type:String, url:String)
			this.url = url;

View this message in context: http://apache-flex-users.2333346.n4.nabble.com/EventListener-null-reference-error-tp13436p13450.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

View raw message