I have created a project in Flex Builder 3 and I do not think it is connecting to the HTTP I have assigned. It is a blog application, that is connected to a database with a PHP page. When I view the application on a HTML page, the text fields are not editable--you cannot type in them. This leads me to believe that I have assigned the HTTP incorrectly. Could this be the problem? How do I fix this?
Are you able to dsplay any data in your DataGrid?
If you set a break point in your getData HTTPService, can you catch it? In other words, is it getting called? Or, is there a fault? Add a Fault handler like this:
result="getPHPData(event)" fault="getFault(event)"
and define getFault().
Below is some of the mxml code that I am using. I am not getting any errors about not being able to connect to the database, so I don't think anything is wrong with the PHP.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="535" height="345">
<mx:Script>
<![CDATA[
import mx.events.DataGridEvent;
import mx.controls.TextInput;
import mx.rpc.events.ResultEvent;
import mx.collections.ArrayCollection;
import com.adobe.serialization.json.JSON;
[Bindable]
private var dataArray:ArrayCollection;
private function initDataGrid():void
{
dataArray = new ArrayCollection();
getData.send();
}
private function getPHPData(event:ResultEvent):void
{
var rawArray:Array;
var rawData:String = String(event.result);
rawArray = JSON.decode(rawData) as Array;
dataArray = new ArrayCollection(rawArray);
}
private function sendPHPData():void
{
var objSend:Object = new Object();
var dataString:String = JSON.encode(dataArray.toArray());
dataString = escape(dataString);
objSend.setTutorials = "true";
objSend.jsonSendData = dataString;
sendData.send(objSend);
}
private function updatedPHPDataResult(event:ResultEvent):void
{
lblStatus.text = String(event.result);
}
private function checkRating(event:DataGridEvent):void
{
var txtIn:TextInput = TextInput(event.currentTarget.itemEditorInstance);
var curValue:Number = Number(txtIn.text);
if(isNaN(curValue) || curValue < 0 || curValue > 10)
{
event.preventDefault();
lblStatus.text = "Please enter a number rating between 0 and 10";
}
}
]]>
</mx:Script>
<mx:HTTPService id="getData" url="/keishalexie/imd465/forum.php"
useProxy="false" method="GET" resultFormat="text"
result="getPHPData(event)">
<mx:request xmlns="">
<getTutorials>"true"</getTutorials>
</mx:request>
</mx:HTTPService>
<mx:HTTPService id="sendData" url="/keishalexie/imd465/forum.php"
useProxy="false" method="GET" resultFormat="text"
result="updatedPHPDataResult(event)">
</mx:HTTPService>
<mx:Binding source="dgData.dataProvider as ArrayCollection"
destination="dataArray"/>
<mx:Panel x="0" y="0" width="535" height="345" layout="absolute"
title="Forum">
<mx:DataGrid id="dgData" x="10" y="10" width="495" height="241"
dataProvider="{dataArray}" creationComplete="{initDataGrid()}"
editable="true" itemEditEnd="{checkRating(event)}">
<mx:columns>
<mx:DataGridColumn headerText="Name" dataField="name" editable="false"/>
<mx:DataGridColumn headerText="Author" dataField="author" width="115"
editable="false"/>
<mx:DataGridColumn headerText="Rating" dataField="rating" width="50"
editable="true" />
</mx:columns>
</mx:DataGrid>
<mx:Button x="10" y="259" label="UpdateDatabase" id="butUpdate"
click="{sendPHPData()}"/>
<mx:Label x="140" y="261" id="lblStatus"/>
</mx:Panel>
</mx:Application>
Related
I wrote very simple code to understand how columnstretch and calllater work but I couldn't get resizeGrid function worked. What is going on here?
<mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
public var denemelist:ArrayCollection;
private function calculateHeight(l:int):Number{
return deneme.measureHeightOfItems(0, l) + deneme.headerHeight;
}
public function resizeGrid():void{
if(denemelist && deneme)
deneme.height = calculateHeight(denemelist.length);
}
public function preinit():void {
denemelist = new ArrayCollection([
{former:"sdfad", latter:"sdfgs"},
{former:"sdfgsd", latter:"sdfgsfd"}
]);
}
public function test():void {
denemelist.addItem({former:"sdfgsdf", latter:"sdfgdsgf"});
}
]]>
</mx:Script>
<mx:VBox width="100%" height="500">
<mx:DataGrid
width="100%"
resizeEffect="Resize"
horizontalScrollPolicy="off" verticalScrollPolicy="off"
id="deneme"
variableRowHeight="true"
editable="false"
dataProvider="{denemelist}"
styleName="phrDataGrid"
columnStretch="callLater(resizeGrid)">
<mx:columns>
<mx:DataGridColumn dataField="former" headerText="former"/>
<mx:DataGridColumn dataField="latter" headerText="latter"/>
</mx:columns>
</mx:DataGrid>
<mx:Button label="deneme1" click="test()" />
</mx:VBox>
I don't think the datagrid has been updated yet at the time that you're calling the function. But you might try leaving off the height of the dg and then just setting the rowCount to the number of items in the list.
HTH;
Amy
I'm trying to implement a binding between some custom-built models and just beginning to dabble with the whole mx.binding.* collection. I tried this simple, stripped down example, but can't get the binding working correctly. Can somebody tell me where I'm going wrong?
// Model
package
{
import flash.events.EventDispatcher;
public class Model extends EventDispatcher
{
private var m_count:uint = 0;
[Bindable]
public function get Count():uint
{
return this.m_count;
}
public function set Count(c:uint):void
{
this.m_count = c;
}
}
}
And this is what the application MXML looks like
// MXML
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:core="*" creationComplete="this.init();">
<mx:Script>
<![CDATA[
import flash.events.Event;
import flash.utils.describeType;
import mx.binding.utils.ChangeWatcher;
[Bindable]
public var model:Model;
public function init():void
{
var _this:Object = this;
this.addEventListener(Event.ENTER_FRAME, function(e:Event):void {
_this.model.Count++;
});
this.model = new Model();
trace(ChangeWatcher.canWatch(this.model, "Count")); // This always returns false for some reason
trace(describeType(this.model));
}
public function UpdateText(s:String):void
{
trace(s);
}
]]>
</mx:Script>
<mx:Text text="{this.model.Count}" creationComplete="trace(this);" />
</mx:WindowedApplication>
Update: I tried an even more bare-bones version as shown below.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="this.m_init();">
<mx:Script>
<![CDATA[
import mx.binding.utils.ChangeWatcher;
[Bindable] public var m:Object = new Object();
public function m_init():void
{
trace(ChangeWatcher.canWatch(this, "m"));
}
]]>
</mx:Script>
<mx:Text text="{this.m}" />
</mx:Application>
Still. Doesn't. Work. ChangeWatcher.canWatch still returns false, although the textfield does display [object Object].
public function init():void
{
this.addEventListener(Event.ENTER_FRAME, increment);
this.model = new Model();
}
public function increment(e:Event):void
{
if(this.model)
this.model.Count++;
}
<mx:Text text="{model.Count}" creationComplete="trace(this);" /-->
i can give u one example of changeWatcher, that may be some help, right now i m working with this, it's helpful,
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">
<mx:Style source="../assets/css/scaleCSS.css"/>
<mx:Script>
<![CDATA[
import mx.binding.utils.ChangeWatcher;
import mx.controls.Text;
private var text:Text;
[Bindable]private var ti1mc:int=50;
private function init():void
{
ChangeWatcher.watch(ti1,'text',updateTextti);
ChangeWatcher.watch(ti2,'text',updateTextti);
ChangeWatcher.watch(ti3,'text',updateTextti);
ChangeWatcher.watch(ti4,'text',updateTextti);
ChangeWatcher.watch(ti5,'text',updateTextti);
}
private function updateTextti(event:Event):void
{
var str:String;
str=event.currentTarget.id.slice(2,3);
// trace("str : "+str);
// trace(Canvas(textbox.getChildAt(int(TextInput(event.currentTarget).id.slice(2,3))-1)).id);
Text(Canvas(textbox.getChildAt(int(TextInput(event.currentTarget).id.slice(2,3))-1)).getChildAt(0)).text=event.currentTarget.text;
// trace(Text(Canvas(textbox.getChildAt(int(TextInput(event.currentTarget).id.slice(2,3))-1)).getChildAt(0)).id);
// trace(event.currentTarget.id.slice(2,3));
if(Canvas(textbox.getChildAt(int(TextInput(event.currentTarget).id.slice(2,3))-1)).width>=textbox.width)
event.currentTarget.maxChars=event.currentTarget.length;
else
event.currentTarget.maxChars=50;
}
]]>
</mx:Script>
<mx:Canvas width="80%" height="80%" horizontalCenter="0" verticalCenter="0" borderStyle="solid">
<mx:VBox id="textbox" height="300" width="200" borderStyle="solid" top="50" left="100" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Canvas id="textcan1" borderStyle="solid" borderColor="#FF0000">
<mx:Text id="text1" fontFamily="Arbeka" styleName="text" rotation="20"/>
</mx:Canvas>
<mx:Canvas id="textcan2" borderStyle="solid" borderColor="#FFFF00">
<mx:Text id="text2" fontFamily="Arbeka" styleName="text" rotation="20"/>
</mx:Canvas>
<mx:Canvas id="textcan3" borderStyle="solid" borderColor="#00FF00">
<mx:Text id="text3" fontFamily="Arbeka" styleName="text" rotation="20"/>
</mx:Canvas>
<mx:Canvas id="textcan4" borderStyle="solid" borderColor="#0000FF">
<mx:Text id="text4" fontFamily="Arbeka" styleName="text" rotation="20"/>
</mx:Canvas>
<mx:Canvas id="textcan5" borderStyle="solid" borderColor="#00FFFF">
<mx:Text id="text5" fontFamily="Arbeka" styleName="text" rotation="20"/>
</mx:Canvas>
</mx:VBox>
<mx:VBox id="textinputbox" height="300" width="200" top="50" right="100" borderStyle="solid" verticalGap="0">
<mx:TextInput id="ti1" width="100%" maxChars="50"/>
<mx:TextInput id="ti2" width="100%" maxChars="50"/>
<mx:TextInput id="ti3" width="100%" maxChars="50"/>
<mx:TextInput id="ti4" width="100%" maxChars="50"/>
<mx:TextInput id="ti5" width="100%" maxChars="50"/>
</mx:VBox>
</mx:Canvas>
</mx:Application>
here ti1(textinput) text property is being watched, if there is a change in to the property, then the handler function(updatetextti) will be called
hope this helps
I removed all files inside the obj folder under the project and the problem seems to have gone away. It might have been that FlashDevelop was using older compiled binaries out of this folder, which made the output go out of sync with the source code.
Evidence to support this lies in two things. Changing the SDK did not affect the output on my own computer, which ruled out any SDK-specific issues. So I created a new project in another IDE on the same computer and copy-pasted the code into that one. This time it worked. That's when I thought it might be the cache and went in and deleted it.
In hindsight, I should have renamed it, and later tried to compile with the old cache in place again. That would have been conclusive.
I have a problem with an AdvancedDataGrid; i want the fields Actual and Estimate to change with the timer function but it doesn't work. It works only by refreshing all the adg with the collapse of the tree structure. I want that if the tree is "exploded" only actual and estimate fields refresh. Sorry for my uncorrect english.
Here's the code
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication initialize="init();" xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<![CDATA[
import mx.utils.ArrayUtil;
import mx.collections.*;
import flash.utils.Timer;
import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
[Bindable]
public var randomNumber:Number = new Number
public function randomValues():Number
{
randomNumber=Math.random()*100
randomNumber*=100
randomNumber=Math.round(randomNumber)
randomNumber/=100
trace(randomNumber)
return randomNumber
}
public var timer:Timer = new Timer(20);
public function timing():void{
timer.addEventListener(TimerEvent.TIMER,function(event:Event):void{randomValues()});
}
[Bindable]
public var dpFlat:ArrayCollection = new ArrayCollection;
public function dpCollection():ArrayCollection
{
dpFlat= new ArrayCollection([
{Continente:"Europa", Paese:"Italia", Actual:randomValues(), Estimate:randomValues()},
{Continente:"Europa", Paese:"Germania", Actual:randomValues(), Estimate:randomValues()}
]);
return dpFlat;
}
public function init():void{
dpCollection()
randomValues()
}
]]>
</mx:Script>
<mx:AdvancedDataGrid horizontalScrollPolicy="on" columnWidth="100" resizableColumns="false" id="myADG" width="469" height="223" color="0x323232" initialize="gc.refresh();">
<mx:dataProvider>
<mx:GroupingCollection id="gc" source="{dpCollection()}">
<mx:grouping>
<mx:Grouping>
<mx:GroupingField name="Continente"/>
<mx:GroupingField name="Paese"/>
</mx:Grouping>
</mx:grouping>
</mx:GroupingCollection>
</mx:dataProvider>
<mx:columns>
<mx:AdvancedDataGridColumn dataField="Continente"/>
<mx:AdvancedDataGridColumn dataField="Paese"/>
<mx:AdvancedDataGridColumn id="act" dataField="Actual"/>
<mx:AdvancedDataGridColumn id="est" dataField="Estimate"/>
</mx:columns>
</mx:AdvancedDataGrid>
<mx:TextArea text="{randomNumber}" x="477" y="10"/>
<mx:Button click="timing()" x="10" y="231" label="Start timing function"/>
<mx:Button click="timer.start()" x="161" y="231" label="Start the time"/>
<mx:Button click="timer.stop()" x="275" y="231" label="Stop the time"/>
</mx:WindowedApplication>
You are not changing the dataProvider in the Timer handler. You are just calling the randomValues() method that just returns a number.
Call gc.source = dpCollection(); from the Timer's handler.
Update: Apparently, the IGroupingCollection does not detect changes to a group automatically, so you must call the refresh() method to update the view after setting the group property.
There seem to be a work around to this issue here
When the dataProvider for an DataGrid is an array of objects, how do I set each column's dataField to a property of the object.
I have an ArrayCollection (say a) where each item is an object
For example a[i] = data:Object
Where the object data has some subproperties - data.name, data.title, data.content etc.
I have a DataGrid in which I want to display this data.
So I put:
<mx:DataGrid id="entries" dataProvider="{resultRSS}">
<mx:columns>
<mx:Array>
<mx:DataGridColumn headerText="Title" dataField="data.title"/>
<mx:DataGridColumn headerText="Date" dataField="data.created"/>
</mx:Array>
</mx:columns>
</mx:DataGrid>
This doesn't seem to work at all. I get an empty DataGrid. How should I assign the dataField property, so that it shows up properly? I've tried {data.title} too.
Thanks.
Edit: sample of my data
-[]arraycollection
--[0]
----id="id1"
----data.
------title="something"
------name="something"
------text="some html"
--[1]
----id="id2"
----data.
------title="something2"
------name="something2"
------text="some html2"
and table should be
|title |name |text |
=================================
|something |something |some html|
|something2|something2|somehtml2|
here is your answer
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="initialize()">
<mx:Script>
<![CDATA[
import mx.collections.HierarchicalData;
var a:Array = new Array();
var o:Object = {};
private function initialize():void{
o["text"]="hello";
o["desc"]="Rahul";
a.push(o);
}
]]>
</mx:Script>
<mx:AdvancedDataGrid width="100%" height="100%" sortExpertMode="true" id="adg1" designViewDataType="tree" dataProvider="{new HierarchicalData(a)}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="text" dataField="text"/>
<mx:AdvancedDataGridColumn headerText="desc" dataField="desc"/>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Application>
edit - ok now discard my previous answer according to your data try this
var a:Array = new Array();
var o:Object = {};
private function stringArrayToObjectArray():void{
o["id"]="mauj";
var oj:Object=new Object();
oj["title"]="aaa";
o["data"]=oj;
var oj1:Object=new Object();
oj1["id"]="mauj2";
var oj2:Object=new Object();
oj2["title"]="qqqq";
oj1["data"]=oj2;
a.push(o);
a.push(oj1);
}
private function some_labelFunc(item:Object,th:Object):String {
return item.data.title;
}
]]>
</mx:Script>
<mx:AdvancedDataGrid width="100%" height="100%" sortExpertMode="true" id="adg1" dataProvider="{a}">
<mx:columns>
<mx:AdvancedDataGridColumn headerText="COMPANIES" dataField="data" labelFunction="some_labelFunc"/>
</mx:columns>
</mx:AdvancedDataGrid>
</mx:Application>
try this sorry for such a bad code
Hi I am working on a search tool for my website in Flex. I want it to work exactly like the "Spotlight" tool on MAC desktop. "http://www.recipester.org/images/6/66/How_to_Use_Spotlight_to_Search_on_Mac_OS_X_42.png" The link is to an image of spotlight.
I want to create almost the same thing in FLEX.
What I currently have is a "Autocomplete" box, and I get all the data I want in it. Code for the autocomplete is below:
<auto:AutoComplete borderStyle="none" id="txt_friends_search"
textAlign="left" prompt="Search Friends" dataProvider="{all_friends_list}"
allowEditingNewValues="true" allowMultipleSelection="true" allowNewValues="true"
backspaceAction="remove" labelField="label"
autoSelectEnabled="false" matchType="anyPart"
height="23" right="400" top="1" dropDownItemRenderer="{new ClassFactory(weather.index_cloud_global_search_item_renderer)}" />
And my ItemRenderer looks like :
<?xml version="1.0" encoding="utf-8"?>
<mx:HBox
xmlns:mx="http://www.adobe.com/2006/mxml"
width="100%" height="100%"
verticalGap="0" horizontalGap="0"
creationComplete="init()"
verticalScrollPolicy="off" horizontalScrollPolicy="off"
verticalAlign="middle">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.collections.ArrayCollection;
import com.hillelcoren.utils.StringUtils;
import mx.utils.StringUtil;
import mx.events.FlexEvent;
import mx.controls.List;
public function init():void
{
}
]]>
</mx:Script>
<mx:HBox width="100%" verticalGap="0" horizontalGap="0">
<mx:HBox borderThickness="1" width="75" borderStyle="solid" horizontalAlign="left" horizontalScrollPolicy="off">
<mx:Label id="type" text="{data.type}" fontSize="12"/>
</mx:HBox>
<mx:HBox borderThickness="1" width="75" borderStyle="solid" horizontalAlign="left" horizontalScrollPolicy="off">
<!--mx:Label id="nameLabel" text="{data.label}" fontSize="12"/-->
<mx:List id="names" dataProvider="{all}"
</mx:HBox>
</mx:HBox>
<!--mx:Box id="colorBox" borderStyle="solid" width="50" height="25"/-->
<mx:Spacer width="15"/>
This shows the type and label of everything, example:
Friends ABC
Friends XYZ
Messages This is the message
Messages example for messages
Files filename1
Files filename123
I believe you get my point there.
But what I want to create is something like:
Friends ABC
XYZ
Messages This is the message
example for messages
Files filename1
filename123
MoreFiles
Can someone plz help me in this.
I actually have no idea how to move forward in this.
Let me know if you want more clarification on anything.
Regards
Zeeshan
Since you're offering a bounty, I'll submit a different answer (as the previous one is technically valid).
Step #1: Download the Adobe Autocomplete Component integrate the class into your project.
Step #2: Create a new component that is derived from AutoComplete (I called mine SpotlightField.mxml)
<?xml version="1.0" encoding="utf-8"?>
<AutoComplete
xmlns="com.adobe.flex.extras.controls.*"
xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="init()"
labelField="value"
itemRenderer="SpotlightFieldRenderer">
<mx:Script>
<![CDATA[
private function init() : void
{
this.filterFunction = substringFilterFunction;
}
private function substringFilterFunction(element:*, text:String):Boolean
{
var label:String = this.itemToLabel(element);
return(label.toLowerCase().indexOf(text.toLowerCase())!=-1);
}
]]>
</mx:Script>
</AutoComplete>
Step #3: Create the ItemRenderer you want to apply to this new component (I called mine SpotlightFieldRenderer.mxml). Note that the code is the same as the previous example, but I'll post it again for completeness.
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
]]>
</mx:Script>
<mx:HBox width="100%">
<mx:Label width="100" text="{data.type}" />
<mx:Label text="{data.value}" />
</mx:HBox>
</mx:Canvas>
Step #4: Update the AutoComplete.as class as follows:
/**
* #private
* Updates the dataProvider used for showing suggestions
*/
private function updateDataProvider():void
{
dataProvider = tempCollection;
collection.filterFunction = templateFilterFunction;
collection.refresh();
sort_and_filter(collection);
//In case there are no suggestions, check there is something in the localHistory
if(collection.length==0 && keepLocalHistory)
{
var so:SharedObject = SharedObject.getLocal("AutoCompleteData");
usingLocalHistory = true;
dataProvider = so.data.suggestions;
usingLocalHistory = false;
collection.filterFunction = templateFilterFunction;
collection.refresh();
}
}
private function sort_and_filter(source:Object):Object
{
if (source && source.length > 1) {
trace (source.length);
source.sortOn('type', Array.CASEINSENSITIVE);
var last:String = "";
for each(var entry:Object in source) {
var current:String = entry.type;
if (current != last)
last = current
else
entry.type = "";
last = entry.type;
}
}
return source;
}
You'll notice that the sort_and_filter function is defined, and called on the collection within updateDataProvider. The app now looks like this:
That's it. The sample application now looks like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<mx:Script>
<![CDATA[
[Bindable]
private var items:Array = [
{ type:'friends', value:'abc' },
{ type:'friends', value:'xyz' },
{ type:'messages', value:'this is the message' },
{ type:'messages', value:'example for messages' },
{ type:'files', value:'filename1' },
{ type:'files', value:'filename123' },
];
]]>
</mx:Script>
<local:SpotlightField dataProvider="{items}" width="400" />
</mx:Application>
Let me know if you have any further questions. There is still a bit of work to do depending on how you want to display the results, but this should get you 95% of the way there ;)
You may want to try something like this. This is just a sample I whipped up, but the basics are there for you to apply to your solution. What this is doing is creating a custom item render (as you've already done), but the container that it's rendering, it adjusts the data set slightly within set dataProvider so that it sorts and filters.
Obviously, you can expand upon this even further to add common icons, formatted text ... etc. The renderer has an explicit width set for the first "column" text. This is to better align results, but should probably be done while the list is being built (based on the string lengths of the values in the result set). Cheers ;)
Application.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*">
<mx:Script>
<![CDATA[
[Bindable]
private var items:Array = [
{ type:'friends', value:'abc' },
{ type:'friends', value:'xyz' },
{ type:'messages', value:'this is the message' },
{ type:'messages', value:'example for messages' },
{ type:'files', value:'filename1' },
{ type:'files', value:'filename123' },
];
]]>
</mx:Script>
<local:SpotlightComboBox
dataProvider="{items}"
width="400" />
</mx:Application>
SpotlightComboBox.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:ComboBox
xmlns:mx="http://www.adobe.com/2006/mxml"
itemRenderer="SpotlightComboBoxItemRenderer">
<mx:Script>
<![CDATA[
override public function set dataProvider(value:Object):void
{
super.dataProvider = sort_and_filter(value as Array);
}
private function sort_and_filter(source:Array):Array
{
if (source && source.length > 1) {
source.sortOn('type', Array.CASEINSENSITIVE);
var last:String = "";
for each(var entry:Object in source) {
var current:String = entry.type;
if (current != last)
last = current
else
entry.type = "";
last = entry.type;
}
}
return source;
}
]]>
</mx:Script>
</mx:ComboBox>
SpotlightComboBoxItemRenderer.mxml
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
]]>
</mx:Script>
<mx:HBox width="100%">
<mx:Label width="100" text="{data.type}" />
<mx:Label text="{data.value}" />
</mx:HBox>
</mx:Canvas>