I'd add a trace statement just before it to see what type of object
event.target is - it could be that the target is the UI component, and
not the data object.

//throws error on this line
trace(event.target);
customMeals.addItem((event.target as mealitem).mealDetails);

2009/7/2 Jason B <[email protected]>:
> I've got an problem when the user clicks on button "Add to Meal" it throws an 
> error because it can't seem to reference the data in mealDetails object 
> inside the com/ directory?
>
> I'm trying to add the item to the list control.
>
> I have the code located here in case you want more details
> http://files.getdropbox.com/u/228472/mealsflex.zip
>
>
> [Bindable]
> private var customMeals:ArrayCollection = new ArrayCollection;
>
> //throws error on this line
> customMeals.addItem((event.target as mealitem).mealDetails);
>
>
>
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"; width="310" height="320"
>         title="{mealDetails.title}" horizontalAlign="center">
>
>
>        <mx:Metadata>
>                [Event(name="addToMeal")]
>                [Event(name="learnAboutThis")]
>        </mx:Metadata>
>
>        <mx:Script>
>                <![CDATA[
>                        import mx.controls.Alert;
>
>                        [Bindable]
>                        public var mealDetails:Object;
>
>
>                        private function calldispatch():void {
>                                parentApplication.createmeals_loadswf_var = 
> mealDetails.swf;
>                                dispatchEvent(new Event('learnAboutThis', 
> true));
>
>                        }
>
>                ]]>
>        </mx:Script>
>
>        <mx:Image source="{'/uploads/nutrition/' + mealDetails.imgsource }" 
> width="285" height="159"/>
>
>        <mx:Label text="{mealDetails.serving}"/>
>
>        <mx:Button label="Add to Meal" click="dispatchEvent(new 
> Event('addToMeal', true))"/>
>
>        <mx:Button label="Learn About This" click="calldispatch()"/>
>
> </mx:Panel>
>
>
>
>
> ------------------------------------
>
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Alternative FAQ location: 
> https://share.acrobat.com/adc/document.do?docid=942dbdc8-e469-446f-b4cf-1e62079f6847
> Search Archives: 
> http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo! Groups Links
>
>
>
>

Reply via email to