# DateField - dynamically changing dayNames & monthNames

**URL:** <https://forum.kirupa.com/t/datefield-dynamically-changing-daynames-monthnames/327405>\
**Category:** flash\
**Created:** [February 27, 2012, 2:32pm UTC](https://forum.kirupa.com/t/datefield-dynamically-changing-daynames-monthnames/327405 "2012-02-27T14:32:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tailjj](https://avatars.discourse-cdn.com/v4/letter/t/ecc23a/32.png) [@tailjj](https://forum.kirupa.com/u/tailjj)\
**Post date:** [February 27, 2012, 2:32pm UTC](https://forum.kirupa.com/t/datefield-dynamically-changing-daynames-monthnames/327405/1 "2012-02-27T14:32:11Z")

</div>

Hi all.  
I have been working with Flex and ActionScript for a few years now, but am just now getting into switching locales dynamically in one of my applications. I have set up locale bundles and have everything working well except for one thing I can’t seem to get to change…the internal labels and date formatting on a DateField component.

The DateField component is defined statically in MXML, but I am trying to change the dayNames, monthNames, and dateFormat attributes dynamically when a user changes locale, and it doesn’t seem to work. I have bound variables set up in the MXML that I am trying to change for all 3 of those attribute values, but they don’t seem to change when I change the variable values. I’ve tried making invalidateDisplayList() and invalidateProperties() calls after changing the values, but that doesn’t seem to matter. I even added a call to “initialize()” after the 2 invalidate calls thinking maybe that needed to be called, but nothing seems to make a difference in getting the labels updated within the component.

Any ideas what I could be doing wrong? I’ve verified that the newDaysArray and newMonths array are getting set up properly from the bundle that they are being read from in the actionscript below.

I should add that I’ve also tried editing the appropriate array variables in the SharedResources.properties file within the appropriate locales’ framework\_rb.swc library in my Flex sdk, and that hasn’t seemed to do anything either.

Here’s code snippets:

MXML:

```auto
<mx:DateField id="dayChooser" formatString="{formatString}" dayNames="{daysArray}" monthNames="{monthsArray}" change="setDateOfInterest()" paddingLeft="0" paddingRight="0"/>

```

ActionScript:

```auto
var newDaysArray:Array = 
[ResourceManager.getInstance().getString("dashlocale", "day.character.Sunday"),  
ResourceManager.getInstance().getString("dashlocale", "day.character.Monday"),  
ResourceManager.getInstance().getString("dashlocale", "day.character.Tuesday"),  
ResourceManager.getInstance().getString("dashlocale", "day.character.Wedday"),  
ResourceManager.getInstance().getString("dashlocale", "day.character.Thursday"),  
ResourceManager.getInstance().getString("dashlocale", "day.character.Friday"),  
ResourceManager.getInstance().getString("dashlocale", "day.character.Saturday")]; 

var newMonthsArray:Array =  
[ResourceManager.getInstance().getString("dashlocale", "month.fullname.January"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.February"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.March"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.April"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.May"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.June"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.July"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.August"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.September"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.October"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.November"),  
ResourceManager.getInstance().getString("dashlocale", "month.fullname.December")];  

daysArray = newDaysArray; 
monthsArray = newMonthsArray; 

dayChooser.formatString = ResourceManager.getInstance().getString("dashlocale", "dashboard.locale.dateFormatYYYY");

// I've tried with and without these calls and variations of just some of them: 
dayChooser.invalidateDisplayList(); 
dayChooser.invalidateProperties(); 
dayChooser.initialize();

```
