Sorry for the confusion,

The code listed in the prior message was that of a custom component (a
Panel that I am using as an item renderer for a tileList which
iterates through a number of dates depending on what month is
selected. When I use this component and add a single label with a text
property of {date.day}, I am able to fill my tileList with the correct
number of panels for any given month that I select.

I would like to take this one step further. In my modelLocator, I have
an array called callLocations (this holds about 10 different
locations). In the code for my custom Panel component, I am trying to
add a label with the text field equal to callLocationName (ie
callLabel.text = modelLocator.callLocations[i].callLocationName;) for
each panel that is constructed, however, when I do this, I receive the
following error

TypeError: Error #1006: value is not a function.
        at
com.dynamicmedicalventures.De2ORApplication.views::CallSchedule/buildCallSchedule()[/Users/don/Documents/Flex
Builder 3/De2OR - Anesthesiology
Management/src/com/dynamicmedicalventures/De2ORApplication/views/CallSchedule.mxml:21]
        at
com.dynamicmedicalventures.De2ORApplication.views::CallSchedule/___CallSchedule_Panel1_creationComplete()[/Users/don/Documents/Flex
Builder 3/De2OR - Anesthesiology
Management/src/com/dynamicmedicalventures/De2ORApplication/views/CallSchedule.mxml:2]
        at flash.events::EventDispatcher/dispatchEventFunction()
        at flash.events::EventDispatcher/dispatchEvent()
        at
mx.core::UIComponent/dispatchEvent()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:9051]
        at mx.core::UIComponent/set
initialized()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:1167]
        at
mx.managers::LayoutManager/doPhasedInstantiation()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\managers\LayoutManager.as:698]
        at Function/http://adobe.com/AS3/2006/builtin::apply()
        at
mx.core::UIComponent/callLaterDispatcher2()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8460]
        at
mx.core::UIComponent/callLaterDispatcher()[E:\dev\3.0.x\frameworks\projects\framework\src\mx\core\UIComponent.as:8403]


Code for the tileList is as follows

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"; layout="vertical"
creationComplete="buildCallSchedule()"
        
xmlns:ns2="com.dynamicmedicalventures.De2ORApplication.views.components.*"
verticalAlign="middle" horizontalAlign="center">
        <mx:Script>
                <![CDATA[
                        import mx.collections.ArrayCollection;
                        import
com.dynamicmedicalventures.De2ORApplication.model.AppModelLocator;
                        
                        [Bindable]
                        private var modelLocator:AppModelLocator =
AppModelLocator.getInstance();
                        [Bindable]
                        public var callDates:ArrayCollection;
                        
                        public function buildCallSchedule():void {
                                var dateArray:Array = new Array();
                                var i:int; //counter for days in a month
                                var j:int; //counter for call locations
                                var numDays:Number = new Date(2008, 5, 
0).getDay() as Number;
                                var locationArray:Array = new Array();
                                
                                for (j=0; 
j<modelLocator.callLocations.length(); j++){
                                                        var callLabel:Object = 
new Object();
                                                        callLabel.text = 
modelLocator.callLocations[i].callLocationName;
                                                        
locationArray.push(callLabel);
                                        }
                        
                                for (i=0; i<numDays; i++){
                                        var obj:Object = new Object();
                                        obj.day = i;
                                        obj.text = locationArray;       
                                        }
                                callDates = new ArrayCollection(dateArray);
                        }
                ]]>
        </mx:Script>
        <ns2:CallScheduleSelectionButton>
        </ns2:CallScheduleSelectionButton>
        
        <mx:TileList dataProvider="{callDates}"
        
itemRenderer="com.dynamicmedicalventures.De2ORApplication.renderers.DailyCallPanelRenderer"
xmlns:ns1="com.dynamicmedicalventures.De2ORApplication.views.components.*"
width="100%">
        </mx:TileList>
        
</mx:Panel>



And the itemRenderer code is here

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute"
creationComplete="initComp()">
        <mx:Script>
                <![CDATA[
                        import mx.controls.Label;
                        import
com.dynamicmedicalventures.De2ORApplication.model.AppModelLocator;
                        [Bindable]
                        private var modelLocator:AppModelLocator =
AppModelLocator.getInstance();
                        
                        public function initComp():void {
                                var i:int;
                                
                                for (i=0; 
i<modelLocator.callLocations.length(); i++){
                                        var callLabel:Label = new Label();
                                        callLabel.text = 
modelLocator.callLocations[i].callLocationName;
                                        addChild(callLabel);
                                }
                        
                        trace('callLocations ' +
modelLocator.callLocations[0].callLocationName);
                        }
                ]]>
        </mx:Script>
        <mx:Label text="{data.day}"/>
        
</mx:Panel>


I hope this better clarifies my question.

Thanks

Don

Reply via email to