Showing posts with label Flex. Show all posts
Showing posts with label Flex. Show all posts

Thursday, 12 September 2013

Flex HTML ToolTip Component

To enhance the normal tool tip functionality to have html style break/ font weight for a portion of string:

You need to create a action class like this:
package com.philip
{
import mx.containers.*;
import mx.controls.Text;
import mx.controls.ToolTip;
import mx.core.*;

public class HTMLToolTip extends ToolTip
{
public function HTMLToolTip()
{    super(); }

override protected function commitProperties():void{
super.commitProperties();
textField.htmlText = text;
}
}
}

to use this set this in your main component, call this function on creationComplete:

<![CDATA[
import com.*;
private function init():void{
ToolTipManager.toolTipClass = HTMLToolTip;
myBtn.toolTip = "this is HTMLToolTip."

]]>



The original post has strong tag but that didn’t work for me in Flex 3.5 SDK worked fine



Link to the original post

Friday, 18 June 2010

Abobe Flex ArrayCollection Sort

This is a inbuilt functionality, which I used to sort the ArrayCollection.
I just wanted to put it here so this can be handy for my reference, ;)

public var availableRegions:ArrayCollection = new ArrayCollection();
/* Create the SortField object for the "data" field in the ArrayCollection object, and make sure we do a numeric sort. */
var dataSortField:SortField = new SortField();
dataSortField.name = "name";
dataSortField.caseInsensitive = true;

/* Create the Sort object and add the SortField object created earlier to the array of fields to sort on. */
var regionDataSort:Sort = new Sort();
regionDataSort.fields = [dataSortField];

/* Set the ArrayCollection object's sort property to our custom sort, and refresh the ArrayCollection. */
availableRegions.sort = regionDataSort;
availableRegions.refresh();

Action script Date Data Provider

I had a requirement to show 2 drop downs for From and To selection of months and year, values like this:

Jan, 2010
Feb, 2010 and so on

And I used the following class to get this working like this.

Based on the class from
http://flexdateutils.riaforge.org/

public function getListOfMonthsAndYear(date:Date,noOfMonths:int = 12):ArrayCollection
{
var monthArr:ArrayCollection = new ArrayCollection();
var obj:Object = new Object();
var dt:Date = new Date();
var n:int = 0;
for (var i:int = noOfMonths; i >= 0; i--)
{
n++;
dt = DateUtils.dateAdd(DateUtils.MONTH,-i, date);
obj = new Object();
obj['label'] = DateUtils.dateFormat(dt,'MMM YYYY');
obj['data'] = DateUtils.dateFormat(dt,'YYYYMM');
obj['no'] = n;
monthArr.addItem(obj);
}
return monthArr;
}

Then I created filtering on the second drop down to remove all the entries which are not relevent, like if you select in your From combo, say Month March, 2010 then you don't want user to select Jan, 2010 in To combo as that would be wrong.

Here is the filter I created on Array Collection:

/**
* From Month Change Handler
*/
private function onFromMonthChange(event:Event):void
{
var comboBox:ComboBox = null;

comboBox = event.currentTarget as ComboBox;
this.currFromMonthNo = Number( comboBox.selectedItem.no );
this.monthToDP.filterFunction = this.toMonthFilter;
this.monthToDP.refresh();
if (this.monthToDP.length > 0) this.monthsTo.selectedIndex = 0;
this.criteria.monthFrom = this.monthsFrom.selectedItem.data;
this.criteria.monthTo = this.monthsTo.selectedItem.data;
}

private function toMonthFilter(obj:Object):Boolean
{
return Number(obj.no) >= this.currFromMonthNo;
}

Actually I used a trick to store number starting from 1 to end of the list in both collections and removed the items with the no's above the selected one from To combo list

Enjoy

Adobe Flex Combo box Binding Bug

I was working on one project at 2nd Byte and hit this problem of Combo Box's data provider not being updated intermittently.

I came across one post which described the bug in SDK 3.5 (it was in previous SDK's as well.

I was doing like this:
[Bindable] public var comboDP:ArrayCollection;

myComboBox.dataProvider = comboDP;

and this wasn't getting updated values and had to do like this to get this working:

myComboBox.dropdown.dataProvider = comboDP;


Link to the post

Enjoy

Saturday, 29 May 2010

Upgrade to Flex 3.5 - removes html templates files

I came across the problem when I upgraded my Eclipse Flex Builder Plugin to use Flex 3.5 SDK.

When I was using clean my project option, it was removing html-template folders content, and solution is (I found a solution on web from one blog/ article):

Go to your project's properties (right click, Properties)
Go to Flex Compiler
Under "Html wrapper" un-check "Generate HTML wrapper file" Click "Apply"
Then check "Generate HTML wrapper file" (the same one you just unchecked)
Click "Apply"
You should now see that the html wrapper files are regenerated.

This happened to me when I used the clean option on one of my projects.

Thursday, 20 May 2010

Flex Spy (fxSpy)

This is a nice component, if you are a Flex Developer:

I found out this component today, when Anuj showed me.

This is very impressive, and useful to play with styles like you can do with firebug.



Here is the Project:

http://code.google.com/p/fxspy/



And an article by Anuj as well:

http://www.anujgakhar.com/2009/09/05/triggering-flexspy-with-a-keyboard-shortcut/



Another one from some developer:

http://blogs.warwick.ac.uk/stevencarpenter/entry/flex-spy_live_component