Hi did not go throgh your code but the problem is that you get your data on app 
creationComplete. By the time you have the data the poanel is not created yet. 
That is why you get the error. I don't know what are you trying to accomplish 
and why are you loading another swf in the main app. My suggestion is to 
restructure you code a little bit MVC style. Get the data into a model, put a 
variable currentPlanType and wit respect to that bind to you current selected 
plan. It will work with binding as you already said, because the bindings fire 
first when null and secionnd time after you get your data and have the 
component created.
You keep duplicated code in createBreakfast , Luynch and dinner which is not 
OK. 

HTH,
C




________________________________
From: Jason B <[email protected]>
To: [email protected]
Sent: Saturday, August 1, 2009 10:07:02 PM
Subject: [flexcoders] Re: creation timing on panel component

  
I didnt include all the code I'll zip it up and email it to you.

--- In flexcod...@yahoogro ups.com, claudiu ursica <the_braniak@ ...> wrote:
>
> From what I see here the button click does not make the call to the http 
> service.
> 
> The general rule of the thumb is aftter the service call you push the data 
> into a model which usually updates the view via binding. I always parse data 
> into array collections or other strong typed objects. Having the items into 
> an array collection enables you to bind to it if you're using List based 
> components in the view. However in your case yuou could listed to the 
> collection change event and do your thing manually. Send me the code via 
> email and I'll try to debug it. I cannot figure it out from what I see. I 
> guess you make the call for the data and the result gets back before the 
> creation complete venet fopr the panel fires.
> 
> C
> 
> 
> 
> 
> ____________ _________ _________ __
> From: Jason B <nos...@...>
> To: flexcod...@yahoogro ups.com
> Sent: Saturday, August 1, 2009 9:14:34 PM
> Subject: [flexcoders] Re: creation timing on panel component
> 
> 
> 
> <mx:Button label="Create Breakfast" click="createBreakf ast()"/> 
> is in the main.mxml
> 
> --- In flexcod...@yahoogro ups.com, claudiu ursica <the_braniak@ ...> wrote:
> >
> > when are you calling the service?
> > 
> > C
> > 
> > 
> > 
> > 
> > ____________ _________ _________ __
> > From: Jason B <nospam@>
> > To: flexcod...@yahoogro ups.com
> > Sent: Saturday, August 1, 2009 5:51:26 PM
> > Subject: [flexcoders] Re: creation timing on panel component
> > 
> > 
> > Just so you know if I use this on the component it works fine
> > 
> > <mx:VBox >
> > <nutrition:Panelcre atemeal id="pnlCreateBreakf ast" meal="{nutritionDat 
> > a.breakfast} "/>
> > </mx:VBox>
> > 
> > 
> > --- In flexcod...@yahoogro ups.com, "Jason B" <nospam@> wrote:
> > >
> > > Main.mxml
> > > ------------ ------
> > > 
> > >   [Bindable]
> > >   private var nutritionData: XML;
> > > 
> > > 
> > >   //      create breakfast
> > >                   private function createBreakfast( ):void
> > >                   {
> > >                           vsMain.selectedInde x = 1;
> > >                           vsCreateMeals. selectedIndex = 0;
> > >                           plantype = 'Breakfast';
> > > 
> > > #1009 ERROR HERE BELOW !
> > >                           pnlCreateBreakfast. meal = nutritionData. 
> > > breakfast;
> > > 
> > >                   }
> > > 
> > > 
> > > <mx:HTTPService id="hsNutrition" url="/main.php/ flexnutrition/ 
> > > nutritioncal"
> > >           result="nutritionRe sultHandler( event)"
> > >           fault="nutritionFau ltHandler( event)" resultFormat= "e4x"/>
> > > 
> > > 
> > >           <mx:VBox width="100%" height="100% ">
> > >                           <mx:ViewStack width="40%" height="410" 
> > > borderStyle= "inset" borderThickness= "2" id="vsCreateMeals" >
> > > 
> > >                       <mx:VBox >
> > >                                <nutrition:Panelcre atemeal 
> > > id="pnlCreateBreakf ast" />
> > >                                   </mx:VBox>
> > > 
> > > 
> > > ------------ --------- --------- --------- --------- ---------
> > > panelcreatemeal. mxml
> > > ------------ -
> > > <?xml version="1.0" encoding="utf- 8"?>
> > > 
> > >   borderThicknessLeft ="0" borderThicknessRigh t="0" borderThicknessBott 
> > > om="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 
> > > :Panelcreatemeal item = new Panelcreatemealitem ;
> > >                                           coverflow.addChild( 
> > > panelcreatemeali tem);
> > >                                           panelcreatemealitem 
> > > .mealDetails = item;
> > >                                   }
> > >                           }
> > >                   }
> > >           ]]>
> > >   </mx:Script>
> > > 
> > >   <containers: CoverFlowContain er id="coverflow" width="100%" 
> > > height="100% " 
> > >           horizontalGap= "1" borderStyle= "inset" backgroundColor= 
> > > "0xFFFFFF" 
> > >           segments="9" reflectionEnabled= "true"/>
> > > 
> > >                <mx:HBox>
> > >                   <mx:Button label="item 1" click="parentApplic 
> > > ation.vsCreateMe als.selectedInde x=0;"/>
> > >                           <mx:Button label="side item 1" 
> > > click="parentApplic ation.vsCreateMe als.selectedInde x=1;"/>
> > >                       <mx:Button label="side item 2" click="parentApplic 
> > > ation.vsCreateMe als.selectedInde x=2;"/>
> > >                    </mx:HBox> 
> > > </mx:Panel>
> > > 
> > > 
> > > ------------ ---------
> > > panelcreatemealitem .mxml
> > > ---------
> > > <?xml version="1.0" encoding="utf- 8"?>
> > > 
> > >    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('learnAboutTh is', 
> > > true));
> > > 
> > >                   }
> > > 
> > >           ]]>
> > >   </mx:Script>
> > > 
> > >   <mx:Image source="{mealDetail s.imgsource }" width="285" height="159" />
> > > 
> > >   <mx:Label text="{mealDetails. serving}" />
> > > 
> > >   <mx:Button label="Add to Meal" click="dispatchEven t(new 
> > > Event('addToMeal' , true))"/> 
> > > 
> > >   <mx:Button label="Learn About This" click="calldispatch ()"/>
> > > 
> > > </mx:Panel>
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > 
> > > --- In flexcod...@yahoogro ups.com, claudiu ursica <the_braniak@ > 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 <nospam@>
> > > > To: flexcod...@yahoogro ups.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;
> > > >
> > >
> >
>


   


      

Reply via email to