[EMAIL PROTECTED] wrote:
> Hi everyone,
> I'm pretty new to flex and have run into a problem that I could use some
> help with.
>
> I have a TabNavigator in my app the I create tabs for dynamically based on
> data. For each tab I create I add a child object that is a HList inside of a
> HBox. That child object dispatches a custom event that I want to catch in
> the main application. So my questions are, Do I add the event listener to
> the tab object or the child?
>
If the event bubbles, either one would work. If not, add it to the HList.
Based on your code, I do not think you need to enclose your
ProductViewer in the HBox. Additionally, your listener looks wrong.
Something like this should work fine:
private function addTab(catgNm:String,dsCategory:ArrayCollection):void {
var pv:ProductViewer = new ProductViewer();
pv.label=catgNm;
pv.flowerCollection=dsCategory;
pv.width= this.mainBox.width*.97
pv.addEventListener('itemAdded',addCartItem);
// or possibly this:
// pv.addEventListener(events.ShoppingCartItemEvent,addCartItem);
// assuming that events is an object and ShoppingCartItemEvent is a constant on
the events object named 'itemAdded'
tn.addChild(tb);
}
> Here is a code snippet. I hope it comes through ok cause this is my first
> post.
> (It's the ProductViewer that dispatches the event and I'm not sure about
> the event type either) I know the event is being sent, but not received.
>
> private function addTab(catgNm:String,dsCategory:ArrayCollection):void {
>
> var tb:HBox = new HBox();
> tb.label=catgNm;
> tb.horizontalScrollPolicy="off";
> var pv:ProductViewer = new ProductViewer();
> pv.flowerCollection=dsCategory;
> pv.width= this.mainBox.width*.97
>
> pv.addEventListener('events.ShoppingCartItemEvent',addCartItem);
> tb.addChild(pv);
> tn.addChild(tb);
> }
>
> Here is the event being dispatched.
> [Event(name="itemAdded",type="events.ShoppingCartItemEvent")]
>
--
Jeffry Houser
Technical Entrepreneur, Podcaster
AIM: Reboog711 | Phone: 1-203-379-0773
--
Adobe Community Expert <http://tinyurl.com/684b5h>
My Company: <http://www.dot-com-it.com>
My Podcast: <http://www.theflexshow.com>
My Blog: <http://www.jeffryhouser.com>
--
Sent From a Mine Shaft
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5576
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.37