1 2 3 4 5 6 7 8 9 10 11 | public static function resizeToFill(mc : *, maxW : Number, maxH : Number = 0, constrainProportions : Boolean = true) : void { maxH = maxH == 0 ? maxW : maxH; mc.width = maxW; mc.height = maxH; if (constrainProportions) { mc.scaleX > mc.scaleY ? mc.scaleY = mc.scaleX : mc.scaleX = mc.scaleY; } } |
Month: January 2011
[AS3 SNIPPET] Set textfield focus
1 2 3 4 5 6 7 8 | public static function setFocus(tf : TextField) : void { tf.type = TextFieldType.INPUT; tf.text = " "; tf.stage.focus = tf; tf.setSelection(tf.length, tf.length); tf.text = ""; } |
[AS3 SNIPPET] Set links style of specified TextField using CSS
1 2 3 4 5 6 7 8 9 | public static function setLinksStyle(tf : TextField, linkColor : Number = 0x000000, linkHoverColor : Number = 0x666666, underline : Boolean = true) : void { var _underline : String = underline ? "underline" : "none"; var ss : StyleSheet = new StyleSheet(); ss.parseCSS("a:link {color: " + ColorUtil.hex2css(linkColor) + "; text-decoration: " + _underline + ";}" + "a:hover {color: " + ColorUtil.hex2css(linkHoverColor) + "; text-decoration: " + _underline + ";}"); tf.styleSheet = ss; } |
You can find the ColorUtil class here.