flex-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From CodeGirl <MichelleNicho...@yahoo.com>
Subject Bubbling to a Grandparent
Date Sat, 06 Dec 2014 21:15:37 GMT
I have created mxml files which contain datagrids for my web service data
tables.   for this question, we are going to call these files parent files. 
I have also created AS files to hold the data and the service calls to
obtain the data.  For this question, we are going to call these files child
files.   When I design a screen, I create a mxml file which instantiates
multiple of the mxml files which contain the datagrids I wish for this view. 
For this question, we are going to call these files Grandparent files.
So, I have a "GrandParent" mxml file which contains an instance of a second
mxml file:

	[Event(name="tripChanged", type="events.ChangeTrip")]
protected function tripsDG_tripChangedHandler(event:ChangeTrip):void
	tripLegsDG.tripID = event.tripID;
<s:VGroup width="100%" height="75%">
		<dg:TripsDG id="tripsDG"
					 width="100%" height="66%"

In the "Parent" mxml file called TripDG I have the change event for the

			protected function tripsDG_changeHandler(event:ListEvent):void
				var eventObject:ChangeTrip = new ChangeTrip("tripChanged",
Also in the "Parent" mxml file when a new item is entered and it is saved to
the webservice and the result is returned and the result event is triggered
then I dispatched another changeTrip event to reflect the newly assigned id
which is assigned by the Database when a new record is saved.

When this was all I had, this was working fine.   But when I moved the
datalist and the service calls to my "Child" AS file, this is when things
stopped working.

At first, I realized when I dispatched the event in the AS file, it was not
being seen by the "Parent" MXML file.   And so I bubbled the event and sure
enough, it was bubbled to the "parent"   Except when I was debugging, I
noticed the new id was not available yet in the result event which I am not
sure why but evidently this was no problem when the result function was in
the mxml file because it was bound by probably some pointer and so when the
lastresult was finally available then the datagrid was updated and then
evidently somehow the "GrandParent" was being updated as well.  

Here is the "Child" AS :

		protected function setTripResult_resultHandler(event:ResultEvent):void
			if (event.result != null)
				var thisDTO:TripDTO = setTripResult.lastResult;
				if (dataList[indx].id == 0)
					dataList[indx] = thisDTO;
					var eventObject:ChangeTrip = new ChangeTrip("tripChanged", thisDTO.id,
					var dispatch:EventDispatcher = new EventDispatcher();
				if (thisDTO.archived != null)
So, it looks like the "Child" as file is bubbling up the tripChanged event
to the "Parent" MXML file except at that moment, it only has the id as 0
instead of the return id value.   But since the event is no longer in the
"Parent" mxml file, it seems as if the link is broke some how and the event
and data is not bubbled up the "GrandParent".   I discovered this because I
put a break point to test it and it never triggered.   So, with all this
said, Does anyone know how I can make the connections so when the result
event is triggered in the "Child" As file that the tripChange event is then
fired in the "GrandParent" mxml file?

View this message in context: http://apache-flex-users.2333346.n4.nabble.com/Bubbling-to-a-Grandparent-tp8997.html
Sent from the Apache Flex Users mailing list archive at Nabble.com.

View raw message