Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hexcolor;
- var HexColor:String;
- function ConfigOutline ():Sprite
- {
- var Popup = new Panel();
- var colorPickerOver:Boolean = false;
- Popup.OutlineHex.restrict = "0-9 a-f A-F";
- Popup.text1.visible = false;
- Popup.switch2.visible = false;
- Popup.SubmitColor.addEventListener(MouseEvent.CLICK, submitHandler);
- Popup.colorPicker.addEventListener(MouseEvent.MOUSE_MOVE, colorMovedHandler);
- Popup.colorPicker.addEventListener(MouseEvent.CLICK, colorPickedHandler);
- Popup.switch1.addEventListener(MouseEvent.CLICK, switch1Handler);
- function submitHandler ()
- {
- hexcolor = Number("0x" + Popup.OutlineHex.text.substr(0,6));
- HexColor = Popup.OutlineHex.text.substr(0,6);
- _ctrl.setMemory("ColorConfig", sendColor(HexColor));
- _ctrl.sendMessage("ChangeColor", hexcolor);
- }
- function sendColor (hexcolor:String):Object
- {
- var Hexcolor:Object;
- Hexcolor = hexcolor;
- return Hexcolor;
- }
- //The switch handler is me testing out having more than one panel on it
- function switch1Handler ()
- {
- Popup.switch1.removeEventListener(MouseEvent.CLICK, switch1Handler);
- Popup.SubmitColor.removeEventListener(MouseEvent.CLICK, submitHandler);
- Popup.colorPicker.removeEventListener(MouseEvent.MOUSE_MOVE, colorMovedHandler);
- Popup.colorPicker.removeEventListener(MouseEvent.CLICK, colorPickedHandler);
- Popup.text1.visible = true;
- Popup.switch2.visible = true;
- Popup.colorPicker.visible = false;
- Popup.switch1.visible = false;
- Popup.OutlineHex.visible = false;
- Popup.SubmitColor.visible = false;
- Popup.switch2.addEventListener(MouseEvent.CLICK, switch2Handler);
- }
- function switch2Handler ()
- {
- Popup.colorPicker.addEventListener(MouseEvent.MOUSE_MOVE, colorMovedHandler);
- Popup.colorPicker.addEventListener(MouseEvent.CLICK, colorPickedHandler);
- Popup.switch1.addEventListener(MouseEvent.CLICK, switch1Handler);
- Popup.SubmitColor.addEventListener(MouseEvent.CLICK, submitHandler);
- Popup.text1.visible = false;
- Popup.switch2.visible = false;
- Popup.colorPicker.visible = true;
- Popup.switch1.visible = true;
- Popup.OutlineHex.visible = true;
- Popup.SubmitColor.visible = true;
- Popup.switch2.removeEventListener(MouseEvent.CLICK, switch2Handler);
- }
- //this is from config tut
- function getBitmapData (src :DisplayObject) :BitmapData
- {
- var bounds :Rectangle = src.getBounds(src);
- var bd :BitmapData = new BitmapData(bounds.width, bounds.height, true, 0);
- bd.draw(src, new Matrix(1, 0, 0, 1, -bounds.x, -bounds.y));
- return bd;
- }
- //this is from the config tut
- function setSwatchColor (color :uint) :void
- {
- var _swatch:Shape = new Shape();
- _swatch.graphics.beginFill(color);
- _swatch.graphics.drawRect(265, 225, 30, 30);
- _swatch.graphics.endFill();
- }
- //This is supposed to look at the color when it's moving
- function colorMovedHandler (e:MouseEvent)
- {
- var bm :BitmapData = getBitmapData(Popup.colorPicker);
- setSwatchColor(bm.getPixel(e.localX, e.localY));
- }
- //this will submit my color once they click
- function colorPickedHandler (e:MouseEvent)
- {
- var bm :BitmapData = getBitmapData(Popup.colorPicker);
- var colorPicked:uint;
- colorPicked = bm.getPixel(e.localX, e.localY);
- HexColor = colorPicked.toString(16);
- hexcolor = Number("0x" + HexColor);
- _ctrl.setMemory("ColorConfig", sendColor(HexColor));
- _ctrl.sendMessage("ChangeColor", hexcolor);
- }
- _ctrl.showPopup("Config Color", Popup, 300, 300, 0x000000, 1);
- return Popup;
- }
- _ctrl.registerCustomConfig(ConfigOutline);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement