Main.mxml ------------------ [Bindable] private var nutritionData:XML;
// create breakfast private function createBreakfast():void { vsMain.selectedIndex = 1; vsCreateMeals.selectedIndex = 0; plantype = 'Breakfast'; #1009 ERROR HERE BELOW ! pnlCreateBreakfast.meal = nutritionData.breakfast; } <mx:HTTPService id="hsNutrition" url="/main.php/flexnutrition/nutritioncal" result="nutritionResultHandler(event)" fault="nutritionFaultHandler(event)" resultFormat="e4x"/> <mx:VBox width="100%" height="100%"> <mx:ViewStack width="40%" height="410" borderStyle="inset" borderThickness="2" id="vsCreateMeals"> <mx:VBox > <nutrition:Panelcreatemeal id="pnlCreateBreakfast" /> </mx:VBox> --------------------------------------------------------- panelcreatemeal.mxml ------------- <?xml version="1.0" encoding="utf-8"?> <mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" width="100%" height="390" borderThicknessLeft="0" borderThicknessRight="0" borderThicknessBottom="0" dropShadowEnabled="false" horizontalAlign="center" xmlns:containers="com.dougmccune.containers.*" title="Select An Item from below" creationPolicy="all"> <mx:Script> <![CDATA[ //import com.createmealPanel; [Bindable] private var _meal:XMLList; public function set meal(value:XMLList):void { if(value) { _meal = value; createContainers(); } } private function createContainers():void { for each(var item:Object in _meal.itemdata) { if(item.available == "yes") { var panelcreatemealitem:Panelcreatemealitem = new Panelcreatemealitem; coverflow.addChild(panelcreatemealitem); panelcreatemealitem.mealDetails = item; } } } ]]> </mx:Script> <containers:CoverFlowContainer id="coverflow" width="100%" height="100%" horizontalGap="1" borderStyle="inset" backgroundColor="0xFFFFFF" segments="9" reflectionEnabled="true"/> <mx:HBox> <mx:Button label="item 1" click="parentApplication.vsCreateMeals.selectedIndex=0;"/> <mx:Button label="side item 1" click="parentApplication.vsCreateMeals.selectedIndex=1;"/> <mx:Button label="side item 2" click="parentApplication.vsCreateMeals.selectedIndex=2;"/> </mx:HBox> </mx:Panel> --------------------- panelcreatemealitem.mxml --------- <?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" creationPolicy="all"> <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="{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> --- In flexcoders@yahoogroups.com, claudiu ursica <the_bran...@...> wrote: > > Quick and really dirty... > wrap them inside a try catch block... but then I can't believe I just said > that... Share some more code and I'll come up with something more engineering > like... > > C > > > > > ________________________________ > From: Jason B <nos...@...> > To: flexcoders@yahoogroups.com > Sent: Saturday, August 1, 2009 5:25:33 PM > Subject: [flexcoders] creation timing on panel component > > > > I'm calling a httpservice which I populate into this nutritionData > variable, I'm using a panel component to reuse it, and when I call the > #SETTER below it throws a 1009 error, I was wondering if the panel is > not yet created, if thats the case how can i wait until the panel is > created? > > [Bindable] > private var nutritionData: XML; > > #SETTER > pnlCreateBreakfast. meal = nutritionData. breakfast; >