Customise Combobox/DropDown in Flash

I am always wonder how to customise the Combobox component in Flash . It's easy to change the skin. Simply double click the component , enter each movieclip and change the style. But ever wonder how to change text color and it's position.

I will try to point out step by step procedure for customise it.

1. First create a class which extends ComboBox. I used DropDownComboBox for class name.
2. Second create another class for Cell render which extends CellRenderer. I used DropDownCellRenderer;
3. Open a new flash document  and insert a combobox component in the stage.
4. Select ComboBox clip in the library. Right click on it and select Properties. 
5. In the properties panel change the default Class to the custom class you wrote . ie, DropDownComboBox 
6. Inside the DropSownComboBox constructer function type this code 

dropdown.setStyle('cellRenderer', DropDownCellRenderer);


7. If you need to change the Text of ComboBox type the below code
textFormat = new TextFormat(new Font2().fontName, 11, 0xCC3333);
textField.setStyle('embedFonts', true);
textField.setStyle('textFormat', textFormat); 

8. If you need to change the Text in dropDown cells  type this code inside the DropDownCellRenderer class
this.setStyle('embedFonts', true);
this.setStyle('textFormat', new TextFormat(new Font2().fontName, 11, 0x000000));

9. If you need to change the text positions override the drawLayout function 
override protected function drawLayout():void {
super.drawLayout()
textField.y += 10;
}


That's it . I have attached my code here. You can check it .


Comments

Unknown said…
Thanks for your marvelous posting! I really enjoyed reading it, you may be a great author.I will always bookmark your blog and will eventually come back in the future. I want to encourage that you continue your great posts, have a nice day! Screen monitoring
Unknown said…
I really appreciate you for those fabulous helpful post you shared with us. My extended internet look up has now been rewarded with reputable facts and techniques to share with my guests. I‘d believe that many of us website visitors are extremely endowed to dwell in a wonderful place with very many lovely individuals with very helpful tips and hints. I feel very happy to have seen your website and look forward to many
more brilliant times reading here. Thank you once more for everything
mts to mov mac
Unknown said…
In the Adobe Flash Air for Android, I have a combobox and zoom by below code. When I zoom, the dropdown of combobox isn't change size automatically. In windows application I haven't this problem.

import flash.events.MouseEvent;
import flash.events.TransformGestureEvent;
import flash.ui.Multitouch;
import flash.ui.MultitouchInputMode;

Multitouch.inputMode = MultitouchInputMode.GESTURE;

stage.addEventListener(TransformGestureEvent.GESTURE_ZOOM , onZoom);
function onZoom (e:TransformGestureEvent):void{
this.scaleX *= e.scaleX;
this.scaleY *= e.scaleY;
}

Popular posts from this blog

Configure PostgreSQL and phpPgAdmin in WAMP

Angular - 4 year road map

Flash FLV player using PHP