Hello, I am attempting to build a scrollpane with multiple sets of Text Inputs, Buttons, and Date Choosers. In each set the button makes the DateChooser visible and when a date is choosen it populated the Text Input and makes itself invisible again.
The issue I am running into is in the 2nd loop when I assign values and listener events to each DateChooser. I believe what is happening is that even though I am creating a function for each DateChooser they really only sharing one function, the last, after the loop is finished. So when I select a date and the "change" event fires the last Text Input in the loop is populated instead of the Text Input in that set. Any advice would be great. function buildItemScrollpane():Void { spContent_mc.createEmptyMovieClip("contentHolder_mc",1); var zDepth:Number = 0; var component_x:Number = 240; var component_y:Number = 10; for ( var i = 0; i < selectedIssueArrayLength; i++ ){ var newTextInput:String= "newTextInput" + i; var newCalDateChooser:String = "newCalDateChooser" + i; var newCalPushButton:String = "newCalPushButton" + i; spContent_mc.contentHolder_mc.createClassObject(TextInput, newTextInput, ++zDepth, {_x:component_x, _y:component_y}); spContent_mc.contentHolder_mc.createClassObject(Button, newCalPushButton, ++zDepth,{_x:component_x + 110, _y:component_y + 1, _width:17, _height:17, icon:"icon.button.cal"}); spContent_mc.contentHolder_mc.createClassObject(DateChooser, newCalDateChooser, ++zDepth,{_x:component_x, _y:component_y - 221, visible:false} ); } populateItemScrollpane(); } function populateItemScrollpane():Void { var selectedIssueArrayLength:Number = selectedIssue.length; for ( var i = 0; i < selectedIssueArrayLength; i++ ){ var newTextInput:String= "newTextInput" + i; var newCalDateChooser:String = "newCalDateChooser" + i; var newCalPushButton:String = "newCalPushButton" + i; var thisCalInput:MovieClip = spContent_mc.contentHolder_mc[newTextInput]; var thisCalPushButton:MovieClip = spContent_mc.contentHolder_mc[newCalPushButton]; var thisCal:MovieClip = spContent_mc.contentHolder_mc[newCalDateChooser]; thisCalPushButton.calendarObj = thisCal; thisCalPushButton.onRelease = function() { this.calendarObj._visible = true; } var superCalListenerObject:Object = new Object(); superCalListenerObject.change = function(eventObj:Object) { var superCaleventSource = eventObj.target; var superCalSelectedDate = superCaleventSource.selectedDate; var superCalDate = superCalSelectedDate.getDate(); var superCalMonth = superCalSelectedDate.getMonth() + 1; var superCalYear = superCalSelectedDate.getFullYear(); var superCalformattedDate = superCalMonth + "/" + superCalDate + "/"+ superCalYear; thisCalInput.text = superCalformattedDate; eventObj.target._visible = false; }; thisCal.addEventListener("change", superCalListenerObject); thisCalInput.text = selectedIssue[i].cellValue; } } ----------------------- Shannon _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com