1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | package com.rblab.framework.utils { /** * @author Riccardo Bartoli */ public class ColorUtil { public static function rgb2hex(r : uint, g : uint, b : uint, a : uint = 255) : uint { return (a << 24) | (r << 16) | (g << 8) | b; } public static function hex2rgb(color : uint) : Object { var c : Object = {}; c.r = color >> 16 & 0xFF; c.g = color >> 8 & 0xFF; c.b = color & 0xFF; return c; } public static function hex2css( color : int ) : String { return "#" + color.toString(16); } } } |
Month: January 2011
[AS3 SNIPPET] Change textfield alignment
1 2 3 4 5 6 7 8 | public static function changeAlignment(tf : TextField, align : String) : void { var textFormat : TextFormat = new TextFormat(); textFormat.align = align; tf.setTextFormat(textFormat); tf.defaultTextFormat = textFormat; } |
[AS3 SNIPPET] Replace font of a specific textfield
1 2 3 4 5 6 7 8 9 10 | public static function replaceFont(tf : TextField, fontName : String, embedFonts : Boolean = true) : void { var textFormat : TextFormat = new TextFormat(); textFormat.font = fontName; tf.setTextFormat(textFormat); tf.defaultTextFormat = textFormat; tf.embedFonts = embedFonts; } |