Archive for June, 2011

Quick Tip: How to right-align the dropdown List in a ComboBox Component

If you’ve got a ComboBox off to the right of the stage, and the dropdownWidth is longer than the ComboBox itself, you may run into issues where the items in the ComboBox hang off of the stage.

For example, here’s a screenshot of a ComboBox on the right with its items cut off:

Bad alignment…. notice how the items are gone

Ideally, what you’d want is for the scrollbar to align directly under the right edge of the ComboBox, and the items to extend out horizontally as necessary:

To solve this, there’s a quick modification you can do to the ComboBox through inheritance:

package com.nerdabilly
{
	import fl.controls.ComboBox;
	import flash.geom.Point;

	public class RightCombo extends ComboBox
	{

		public function RightCombo()
		{
			// constructor code
		}
		override protected function positionList():void
		{
			super.positionList();
			
			list.x = parent.localToGlobal(new Point(this.x,this.y)).x + width - list.width 
			if(list.verticalScrollBar.visible){
				list.x -= list.verticalScrollBar.width;
			}
		}
	}

}

Once this is done, simply edit the Linkage for the ComboBox (in its Properties panel) so it points to com.nerdabilly.RightCombo instead of fl.controls.ComboBox.

Advertisements

Leave a comment

Determining whether a SWF is running in the IDE or a browser

Here’s something that’s been around for a while that I didn’t learn about until just recently.

The flash.system.capabilities.playerType property can be used to tell whether you’re running in the browser, a standalone player, or the Flash IDE. It returns the following values (from Adobe’s documentation):

  • “ActiveX” for the Flash Player ActiveX control used by Microsoft Internet Explorer
  • “Desktop” for the Adobe AIR runtime (except for SWF content loaded by an HTML page, which has Capabilities.playerType set to “PlugIn”)
  • “External” for the external Flash Player or in test mode
  • “PlugIn” for the Flash Player browser plug-in (and for SWF content loaded by an HTML page in an AIR application)
  • “StandAlone” for the stand-alone Flash Player

Simply check for (flash.system.capabilities.playerType == "ActiveX" || flash.system.capabilities.playerType == "PlugIn") and you’ll know you’re in a browser.

, , ,

Leave a comment