Showing posts with label flex. Show all posts
Showing posts with label flex. Show all posts

Wednesday, May 9, 2012

the style 'backgroundalpha' is only supported by type 'mx.controls.textInput' with the theme(s) 'halo'

When I created a new project on Flash Builder 4.5 and imported an old project to this space, I saw that there are a dozen of errors. All of them are "The style 'backgroundAlpha' is only supported by type 'mx.controls.TextInput' with the theme(s) 'halo'". I remember there was no error with the project so I googled to see the problem and it seems like flex does not have this style as of version 4. But our project was in flex 3 and I remember not setting the flex version explicitly when I created the project. Flash builder automatically added this version (flex 4)  to libraries and thus the old project code stopped working. When I switched back to flex 3, it began working again. To achieve this, I clicked on the project > properties > Flex Build Path and chose flex 3.

Monday, November 28, 2011

flex likes surprises

Recently I got an odd error while working on flex.
While debugging, I saw that the following code seems to have a value in "container.eGrid.selectedItem" part. It's populated with an object of type MyObject.
But "e" of type MyObject is null. Seems nonsense right? I'm just setting what's in right to left.
A bit later, I saw that I mapped MyObject to a wrong java remoteclass. When I fixed this issue my "e" variable got populated.

var e:MyObject = container.eGrid.selectedItem as MyObject;

Tuesday, November 22, 2011

flex surprises again (this time with datefield)

In my "update" screen (in flex), I'm getting the actual date value from the model and showing it to the user. If the user changes this date value in the screen, no problem; it's working. But if he doesn't touch this date field then the value of it is null as far as I can see while debugging.

In my update screen this is the part I define the datefield.
< mx:DateField id="endingDateDatefield" text="{formatDate(myModel.endingDate)}" 
formatString="{FORMAT_STRING}" width="50%" height="25"/> 
                                  
Notice that formatDate() returns String.

The datefield is displayed correctly but when I try to save the new model I saw no value in debug. "parentPanel.endingDateDatefield.selectedDate" is null.
So I changed my code to:
< mx:DateField id="endingDateDatefield" selectedDate="{myModel.endingDate}" 
formatString="{FORMAT_STRING}" width="50%" height="25"/> 

Now I set the selectedDate field instead of text in DateField component which fixes the issue.

Wednesday, November 2, 2011

comparing dates in flex

Let's see how we can compare dates in flex.

ObjectUtil.dateCompare(firstDate, secondDate);

This call above will return you -1 if secondDate is later than the first date, 1 if it's the contrary case and 0 if they match.