├── .gitignore ├── README └── src ├── SkinDemo.as ├── SkinMarkupDemo.mxml ├── assets ├── images │ ├── button-down.psd │ ├── button-over.png │ ├── button-up.png │ ├── button.psd │ ├── check-box-selected.png │ ├── check-box.png │ ├── h-slider-background.png │ ├── radio-buttons.psd │ ├── right-arrow.png │ ├── slider-thumb.png │ ├── switch.psd │ └── text-input-background.png └── pf_ronda_seven.ttf └── com ├── bit101 ├── charts │ ├── BarChart.as │ ├── Chart.as │ ├── LineChart.as │ └── PieChart.as └── components │ ├── Accordion.as │ ├── Calendar.as │ ├── CheckBox.as │ ├── ColorChooser.as │ ├── ComboBox.as │ ├── Component.as │ ├── FPSMeter.as │ ├── HBox.as │ ├── HRangeSlider.as │ ├── HScrollBar.as │ ├── HScrollSlider.as │ ├── HSlider.as │ ├── HUISlider.as │ ├── IndicatorLight.as │ ├── InputText.as │ ├── Knob.as │ ├── Label.as │ ├── List.as │ ├── ListItem.as │ ├── Meter.as │ ├── NumericStepper.as │ ├── Panel.as │ ├── ProgressBar.as │ ├── PushButton.as │ ├── RadioButton.as │ ├── RangeSlider.as │ ├── RotarySelector.as │ ├── ScrollBar.as │ ├── ScrollSlider.as │ ├── Slider.as │ ├── Style.as │ ├── Text.as │ ├── TextArea.as │ ├── UISlider.as │ ├── VBox.as │ ├── VRangeSlider.as │ ├── VScrollBar.as │ ├── VScrollSlider.as │ ├── VSlider.as │ ├── VUISlider.as │ ├── WheelMenu.as │ └── Window.as └── dgrigg ├── components ├── Application.as └── Container.as ├── minimalcomps ├── events │ └── SkinPartEvent.as ├── graphics │ ├── BitmapImage.as │ ├── CubicBezier.as │ ├── Ellipse.as │ ├── Geometry.as │ ├── GradientFill.as │ ├── GradientItem.as │ ├── GradientStroke.as │ ├── IFill.as │ ├── IGeometry.as │ ├── IGraphic.as │ ├── IStroke.as │ ├── Line.as │ ├── Move.as │ ├── Path.as │ ├── QuadraticBezier.as │ ├── Rect.as │ ├── Shape.as │ ├── SolidFill.as │ └── SolidStroke.as └── skins │ ├── CheckBoxSkin.as │ ├── ComboBoxSkin.as │ ├── HScrollBarSkin.as │ ├── HScrollSliderSkin.as │ ├── HSliderSkin.as │ ├── ISkin.as │ ├── ISkinElement.as │ ├── LabelSkin.as │ ├── ListItemSkin.as │ ├── ListSkin.as │ ├── PushButtonDownArrowSkin.as │ ├── PushButtonLeftArrowSkin.as │ ├── PushButtonRightArrowSkin.as │ ├── PushButtonSkin.as │ ├── PushButtonUpArrowSkin.as │ ├── Skin.as │ ├── TextAreaSkin.as │ ├── TextSkin.as │ ├── VScrollBarSkin.as │ ├── VScrollSliderSkin.as │ └── VSliderSkin.as ├── skins ├── ButtonImageSkin.mxml ├── ButtonSkin.mxml ├── CheckBoxImageSkin.mxml ├── CheckBoxSkin.mxml ├── HSliderImageSkin.mxml ├── HSliderSkin.mxml ├── TextImageSkin.mxml └── TextSkin.mxml └── utils └── Logger.as /.gitignore: -------------------------------------------------------------------------------- 1 | /.settings/* 2 | 3 | /html-template/* 4 | /bin-debug/* 5 | /bin-release/* 6 | /bin/* 7 | docs/* 8 | obj/* 9 | 10 | .actionScriptProperties 11 | .flexProperties 12 | .flexLibProperties 13 | .FlexUnitSettings 14 | .project 15 | 16 | *.air 17 | 18 | Icon 19 | Thumbs.db 20 | .DS_Store 21 | .psd 22 | dist/* 23 | report/* 24 | doc/* 25 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | This is an extension of the Minimal Components set created by Keith Peters (http://www.minimalcomps.com/). The components are super lightweight however they lack the ability to be easily skinned (http://www.bit-101.com/blog/?p=2535). 2 | 3 | In order to make the components more flexible from a visual standpoint yet retain the minimal footprint a basic set of classes for drawing shapes and fills and the required logic to handle skinning was added. If you have worked with Flex 4 or Degrafa it should be quite obvious how the components and skins interact and how skins are created. 4 | 5 | There are two demo files, one is a straight AS3 class, SkinDemo.as, the other SkinMarkupDemo.mxml is an mxml file that is compiled by mxmlc, however it doesn't include the Flex framework when it gets compiled, it only uses the framework to allow coding in markup. 6 | 7 | It was used to simplify the creation (using markup vs script). It should also be more familiar to Flex developers. You can read this post to see how to setup projects to use this method, http://www.dgrigg.com/post.cfm/04/12/2010/When-Flex-goes-on-a-SlimFast-diet or follow these steps. 8 | 9 | In Flash Builder (Flex Builder) create a new AS3 Project. After the setup is done 10 | 1. go to the project properties 11 | 2. select Actionscript Build Path 12 | 3. select Library path 13 | 4. Add SWC(s) 14 | 5. Browse to the 'framework.swc' in the Flex SDK dir you are using (ie /flex_sdk_4.1.0.14965/frameworks/libs) and select it. 15 | 6. Browse to the 'framework_rb.swc' in the Flex SDK dir you are using (ie /flex_sdk_4.1.0.14965/frameworks/locale/en_US) and select it. 16 | 17 | Documentation coming soon. 18 | 19 | Creating new skins 20 | ------------------ 21 | When creating a new skin there are a few things to keep in mind: 22 | 23 | 1. You need to extend the com.dgrigg.minimalcomps.skins.Skin class 24 | 25 | 2. If you want the hostComponent to be aware of the skin parts when they are added, you need to give each skin part a name, either in the markup or programmatically: 26 | 27 | 28 | or 29 | 30 | var label:Label = new Label(); 31 | label.name = "skinLabel"; 32 | 33 | the name value is how you can differentiate the skin parts in the component as they are added, see the 'skinPartAdded' method in com.bit101.components.Component 34 | 35 | 3. In the skin you can access the host component via the 'hostComponent' property 36 | 37 | 4. To apply a skin to a component 38 | 39 | 40 | or 41 | 42 | button.skinClass = com.dgrigg.skins.ButtonImageSkin; 43 | 44 | 45 | Releases 46 | -------- 47 | 4/28/2010 Label, PushButton, Checkbox, Text, HSlider and VSlider have been refactored to use skinning. 48 | 49 | Derrick Grigg 50 | www.dgrigg.com -------------------------------------------------------------------------------- /src/SkinDemo.as: -------------------------------------------------------------------------------- 1 | /** 2 | * SkinDemo.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Demo application to show the Skinnable Minimal Compoenents. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package 31 | { 32 | import com.bit101.components.*; 33 | import com.dgrigg.skins.ButtonImageSkin; 34 | 35 | import flash.display.Sprite; 36 | 37 | public class SkinDemo extends Sprite 38 | { 39 | public function SkinDemo() 40 | { 41 | super(); 42 | 43 | var vbox:VBox = new VBox(this, 10, 10); 44 | vbox.setSize(400, 400); 45 | vbox.width = 400; 46 | vbox.height = 400; 47 | 48 | 49 | var label:Label = new Label(vbox); 50 | label.text = "Hello World"; 51 | 52 | var button:PushButton = new PushButton(vbox); 53 | button.skinClass = com.dgrigg.skins.ButtonImageSkin; 54 | button.label = "Push me to"; 55 | 56 | 57 | var checkbox:CheckBox = new CheckBox(vbox); 58 | checkbox.label = "Check me"; 59 | 60 | var hslider:HSlider = new HSlider(vbox); 61 | 62 | var text:Text = new Text(vbox); 63 | text.text = "Hello World"; 64 | } 65 | } 66 | } -------------------------------------------------------------------------------- /src/SkinMarkupDemo.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur adipiscing viverra mattis. Nam egestas laoreet massa, a convallis velit commodo eu. Aenean fringilla volutpat lorem, nec euismod nunc aliquam nec. Maecenas cursus libero sit amet metus scelerisque placerat. Duis libero tortor, congue sit amet scelerisque vel, tempus dictum erat. Vestibulum dignissim sodales nunc, eget auctor nunc blandit nec. 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /src/assets/images/button-down.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/button-down.psd -------------------------------------------------------------------------------- /src/assets/images/button-over.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/button-over.png -------------------------------------------------------------------------------- /src/assets/images/button-up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/button-up.png -------------------------------------------------------------------------------- /src/assets/images/button.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/button.psd -------------------------------------------------------------------------------- /src/assets/images/check-box-selected.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/check-box-selected.png -------------------------------------------------------------------------------- /src/assets/images/check-box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/check-box.png -------------------------------------------------------------------------------- /src/assets/images/h-slider-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/h-slider-background.png -------------------------------------------------------------------------------- /src/assets/images/radio-buttons.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/radio-buttons.psd -------------------------------------------------------------------------------- /src/assets/images/right-arrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/right-arrow.png -------------------------------------------------------------------------------- /src/assets/images/slider-thumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/slider-thumb.png -------------------------------------------------------------------------------- /src/assets/images/switch.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/switch.psd -------------------------------------------------------------------------------- /src/assets/images/text-input-background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/images/text-input-background.png -------------------------------------------------------------------------------- /src/assets/pf_ronda_seven.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dgrigg/SkinnableMinimalComponents/022785d6c4d41f59d18364810a1750b3b6282ecb/src/assets/pf_ronda_seven.ttf -------------------------------------------------------------------------------- /src/com/bit101/charts/BarChart.as: -------------------------------------------------------------------------------- 1 | /** 2 | * BarChart.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A chart component for graphing an array of numeric data as a bar graph. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.charts 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class BarChart extends Chart 34 | { 35 | protected var _spacing:Number = 2; 36 | private var _barColor:uint = 0x999999; 37 | 38 | /** 39 | * Constructor 40 | * @param parent The parent DisplayObjectContainer on which to add this Label. 41 | * @param xpos The x position to place this component. 42 | * @param ypos The y position to place this component. 43 | * @param data The array of numeric values to graph. 44 | */ 45 | public function BarChart(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, data:Array=null) 46 | { 47 | super(parent, xpos, ypos, data); 48 | } 49 | 50 | /** 51 | * Graphs the numeric data in the chart. 52 | */ 53 | protected override function drawChart():void 54 | { 55 | var border:Number = 2; 56 | var totalSpace:Number = _spacing * _data.length; 57 | var barWidth:Number = (_width - border - totalSpace) / _data.length; 58 | var chartHeight:Number = _height - border; 59 | _chartHolder.x = 0; 60 | _chartHolder.y = _height; 61 | var xpos:Number = border; 62 | var max:Number = getMaxValue(); 63 | var min:Number = getMinValue(); 64 | var scale:Number = chartHeight / (max - min); 65 | for(var i:int = 0; i < _data.length; i++) 66 | { 67 | if(_data[i] != null) 68 | { 69 | _chartHolder.graphics.beginFill(_barColor); 70 | _chartHolder.graphics.drawRect(xpos, 0, barWidth, (_data[i] - min) * -scale); 71 | _chartHolder.graphics.endFill(); 72 | } 73 | xpos += barWidth + _spacing; 74 | } 75 | } 76 | 77 | 78 | 79 | /////////////////////////////////// 80 | // getter/setters 81 | /////////////////////////////////// 82 | 83 | /** 84 | * Sets/gets the amount of space shown between each bar. If this is too wide, bars may become invisible. 85 | */ 86 | public function set spacing(value:Number):void 87 | { 88 | _spacing = value; 89 | invalidate(); 90 | } 91 | public function get spacing():Number 92 | { 93 | return _spacing; 94 | } 95 | 96 | /** 97 | * Sets/gets the color of the bars. 98 | */ 99 | public function set barColor(value:uint):void 100 | { 101 | _barColor = value; 102 | invalidate(); 103 | } 104 | public function get barColor():uint 105 | { 106 | return _barColor; 107 | } 108 | 109 | 110 | } 111 | } -------------------------------------------------------------------------------- /src/com/bit101/charts/LineChart.as: -------------------------------------------------------------------------------- 1 | /** 2 | * LineChart.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A chart component for graphing an array of numeric data as a line graph. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.charts 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | 33 | public class LineChart extends Chart 34 | { 35 | protected var _lineWidth:Number = 1; 36 | private var _lineColor:uint = 0x999999; 37 | 38 | /** 39 | * Constructor 40 | * @param parent The parent DisplayObjectContainer on which to add this Label. 41 | * @param xpos The x position to place this component. 42 | * @param ypos The y position to place this component. 43 | * @param data The array of numeric values to graph. 44 | */ 45 | public function LineChart(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, data:Array=null) 46 | { 47 | super(parent, xpos, ypos, data); 48 | } 49 | 50 | /** 51 | * Graphs the numeric data in the chart. 52 | */ 53 | protected override function drawChart():void 54 | { 55 | var border:Number = 2; 56 | var lineWidth:Number = (_width - border) / (_data.length - 1); 57 | var chartHeight:Number = _height - border; 58 | _chartHolder.x = 0; 59 | _chartHolder.y = _height; 60 | var xpos:Number = border; 61 | var max:Number = getMaxValue(); 62 | var min:Number = getMinValue(); 63 | var scale:Number = chartHeight / (max - min); 64 | _chartHolder.graphics.lineStyle(_lineWidth, _lineColor); 65 | _chartHolder.graphics.moveTo(xpos, (_data[0] - min) * -scale); 66 | xpos += lineWidth; 67 | for(var i:int = 1; i < _data.length; i++) 68 | { 69 | if(_data[i] != null) 70 | { 71 | _chartHolder.graphics.lineTo(xpos, (_data[i] - min) * -scale); 72 | } 73 | xpos += lineWidth; 74 | } 75 | } 76 | 77 | 78 | 79 | /////////////////////////////////// 80 | // getter/setters 81 | /////////////////////////////////// 82 | /** 83 | * Sets/gets the width of the line in the graph. 84 | */ 85 | public function set lineWidth(value:Number):void 86 | { 87 | _lineWidth = value; 88 | invalidate(); 89 | } 90 | public function get lineWidth():Number 91 | { 92 | return _lineWidth; 93 | } 94 | 95 | /** 96 | * Sets/gets the color of the line in the graph. 97 | */ 98 | public function set lineColor(value:uint):void 99 | { 100 | _lineColor = value; 101 | invalidate(); 102 | } 103 | public function get lineColor():uint 104 | { 105 | return _lineColor; 106 | } 107 | 108 | 109 | } 110 | } -------------------------------------------------------------------------------- /src/com/bit101/components/Accordion.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Accordion.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * Essentially a VBox full of Windows. Only one Window will be expanded at any time. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | 30 | package com.bit101.components 31 | { 32 | import flash.display.DisplayObjectContainer; 33 | import flash.events.Event; 34 | 35 | public class Accordion extends Component 36 | { 37 | private var _windows:Array; 38 | private var _winWidth:Number = 100; 39 | private var _winHeight:Number = 100; 40 | private var _vbox:VBox; 41 | 42 | /** 43 | * Constructor 44 | * @param parent The parent DisplayObjectContainer on which to add this Panel. 45 | * @param xpos The x position to place this component. 46 | * @param ypos The y position to place this component. 47 | */ 48 | public function Accordion(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0) 49 | { 50 | super(parent, xpos, ypos); 51 | } 52 | 53 | /** 54 | * Initializes the component. 55 | */ 56 | protected override function init():void 57 | { 58 | super.init(); 59 | setSize(100, 120); 60 | } 61 | 62 | /** 63 | * Creates and adds the child display objects of this component. 64 | */ 65 | protected override function addChildren() : void 66 | { 67 | _vbox = new VBox(this); 68 | _vbox.spacing = 0; 69 | 70 | _windows = new Array(); 71 | for(var i:int = 0; i < 2; i++) 72 | { 73 | var window:Window = new Window(_vbox, 0, 0, "Section " + (i + 1)); 74 | window.draggable = false; 75 | window.addEventListener(Event.SELECT, onWindowSelect); 76 | if(i != 0) window.minimized = true; 77 | _windows.push(window); 78 | } 79 | } 80 | 81 | /////////////////////////////////// 82 | // public methods 83 | /////////////////////////////////// 84 | 85 | /** 86 | * Adds a new window to the bottom of the accordion. 87 | * @param title The title of the new window. 88 | */ 89 | public function addWindow(title:String):void 90 | { 91 | var window:Window = new Window(_vbox, 0, 0, title); 92 | window.minimized = true; 93 | window.draggable = false; 94 | window.addEventListener(Event.SELECT, onWindowSelect); 95 | _windows.push(window); 96 | _winHeight = _height - (_windows.length - 1) * 20; 97 | setSize(_winWidth, _winHeight); 98 | } 99 | 100 | /** 101 | * Sets the size of the component. 102 | * @param w The width of the component. 103 | * @param h The height of the component. 104 | */ 105 | override public function setSize(w:Number, h:Number) : void 106 | { 107 | super.setSize(w, h); 108 | _winWidth = w; 109 | _winHeight = h - (_windows.length - 1) * 20; 110 | draw(); 111 | } 112 | 113 | override public function draw():void 114 | { 115 | _winHeight = Math.max(_winHeight, 40); 116 | for(var i:int = 0; i < _windows.length; i++) 117 | { 118 | _windows[i].setSize(_winWidth, _winHeight); 119 | _vbox.draw(); 120 | } 121 | } 122 | 123 | /** 124 | * Returns the Window at the specified index. 125 | * @param index The index of the Window you want to get access to. 126 | */ 127 | public function getWindowAt(index:int):Window 128 | { 129 | return _windows[index]; 130 | } 131 | 132 | 133 | /////////////////////////////////// 134 | // event handlers 135 | /////////////////////////////////// 136 | 137 | /** 138 | * Called when any window is resized. If the window has been expanded, it closes all other windows. 139 | */ 140 | protected function onWindowSelect(event:Event):void 141 | { 142 | var window:Window = event.target as Window; 143 | if(window.minimized) 144 | { 145 | for(var i:int = 0; i < _windows.length; i++) 146 | { 147 | _windows[i].minimized = true; 148 | } 149 | window.minimized = false; 150 | } 151 | _vbox.draw(); 152 | } 153 | 154 | public override function set width(w:Number):void 155 | { 156 | _winWidth = w; 157 | super.width = w; 158 | } 159 | 160 | public override function set height(h:Number):void 161 | { 162 | _winHeight = h - (_windows.length - 1) * 20; 163 | super.height = h; 164 | } 165 | 166 | } 167 | } -------------------------------------------------------------------------------- /src/com/bit101/components/FPSMeter.as: -------------------------------------------------------------------------------- 1 | /** 2 | * FPSMeter.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * An simple component showing the frames per second the current movie is running at. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | import flash.events.Event; 33 | import flash.utils.getTimer; 34 | 35 | 36 | public class FPSMeter extends Component 37 | { 38 | private var _label:Label; 39 | private var _startTime:int; 40 | private var _frames:int; 41 | private var _prefix:String = ""; 42 | private var _fps:int = 0; 43 | 44 | /** 45 | * Constructor 46 | * @param parent The parent DisplayObjectContainer on which to add this ColorChooser. 47 | * @param xpos The x position to place this component. 48 | * @param ypos The y position to place this component. 49 | * @param prefix A string to put in front of the number value shown. Default is "FPS:". 50 | */ 51 | 52 | public function FPSMeter(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, prefix:String="FPS:") 53 | { 54 | super(parent, xpos, ypos); 55 | _prefix = prefix; 56 | _frames = 0; 57 | _startTime = getTimer(); 58 | setSize(50, 20); 59 | if(stage != null) 60 | { 61 | addEventListener(Event.ENTER_FRAME, onEnterFrame); 62 | } 63 | addEventListener(Event.REMOVED_FROM_STAGE, onRemovedFromStage); 64 | } 65 | 66 | protected override function addChildren():void 67 | { 68 | super.addChildren(); 69 | _label = new Label(this, 0, 0); 70 | } 71 | 72 | 73 | public override function draw():void 74 | { 75 | _label.text = _prefix + _fps.toString(); 76 | } 77 | 78 | /** 79 | * Internal enterFrame handler to measure fps and update label. 80 | */ 81 | protected function onEnterFrame(event:Event):void 82 | { 83 | // Increment frame count each frame. When more than a second has passed, 84 | // display number of accumulated frames and reset. 85 | // Thus FPS will only be calculated and displayed once per second. 86 | // There are more responsive methods that calculate FPS on every frame. 87 | // This method is uses less CPU and avoids the "jitter" of those other methods. 88 | _frames++; 89 | var time:int = getTimer(); 90 | var elapsed:int = time - _startTime; 91 | if(elapsed >= 1000) 92 | { 93 | _fps = Math.round(_frames * 1000 / elapsed); 94 | _frames = 0; 95 | _startTime = time; 96 | draw(); 97 | } 98 | } 99 | 100 | /** 101 | * Stops the meter if it is removed from stage. 102 | */ 103 | protected function onRemovedFromStage(event:Event):void 104 | { 105 | stop(); 106 | } 107 | 108 | /** 109 | * Stops the meter by removing the enterFrame listener. 110 | */ 111 | public function stop():void 112 | { 113 | removeEventListener(Event.ENTER_FRAME, onEnterFrame); 114 | } 115 | 116 | /** 117 | * Starts the meter again if it has been stopped. 118 | */ 119 | public function start():void 120 | { 121 | addEventListener(Event.ENTER_FRAME, onEnterFrame); 122 | } 123 | 124 | /** 125 | * Sets or gets the prefix shown before the number. Defaults to "FPS:". 126 | */ 127 | public function set prefix(value:String):void 128 | { 129 | _prefix = value; 130 | } 131 | public function get prefix():String 132 | { 133 | return _prefix; 134 | } 135 | 136 | /** 137 | * Returns the current calculated FPS. 138 | */ 139 | public function get fps():int 140 | { 141 | return _fps; 142 | } 143 | } 144 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HBox.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VBox.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A layout container for vertically aligning other components. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | 30 | package com.bit101.components 31 | { 32 | import flash.display.DisplayObject; 33 | import flash.display.DisplayObjectContainer; 34 | import flash.events.Event; 35 | 36 | public class HBox extends Component 37 | { 38 | private var _spacing:Number = 5; 39 | 40 | 41 | /** 42 | * Constructor 43 | * @param parent The parent DisplayObjectContainer on which to add this PushButton. 44 | * @param xpos The x position to place this component. 45 | * @param ypos The y position to place this component. 46 | */ 47 | public function HBox(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0) 48 | { 49 | super(parent, xpos, ypos); 50 | } 51 | 52 | /** 53 | * Override of addChild to force layout; 54 | */ 55 | override public function addChild(child:DisplayObject) : DisplayObject 56 | { 57 | super.addChild(child); 58 | child.addEventListener(Event.RESIZE, onResize); 59 | invalidate(); 60 | return child; 61 | } 62 | 63 | protected function onResize(event:Event):void 64 | { 65 | invalidate(); 66 | } 67 | 68 | /** 69 | * Draws the visual ui of the component, in this case, laying out the sub components. 70 | */ 71 | override public function draw() : void 72 | { 73 | _width = 0; 74 | _height = 0; 75 | var xpos:Number = 0; 76 | for(var i:int = 0; i < numChildren; i++) 77 | { 78 | var child:DisplayObject = getChildAt(i); 79 | child.x = xpos; 80 | xpos += child.width; 81 | xpos += _spacing; 82 | _width += child.width; 83 | _height = Math.max(_height, child.height); 84 | } 85 | _width += _spacing * (numChildren - 1); 86 | dispatchEvent(new Event(Event.RESIZE)); 87 | } 88 | 89 | /** 90 | * Gets / sets the spacing between each sub component. 91 | */ 92 | public function set spacing(s:Number):void 93 | { 94 | _spacing = s; 95 | invalidate(); 96 | } 97 | public function get spacing():Number 98 | { 99 | return _spacing; 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HRangeSlider.as: -------------------------------------------------------------------------------- 1 | package com.bit101.components 2 | { 3 | import flash.display.DisplayObjectContainer; 4 | 5 | public class HRangeSlider extends RangeSlider 6 | { 7 | public function HRangeSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 8 | { 9 | super(HORIZONTAL, parent, xpos, ypos, defaultHandler); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HScrollBar.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HScrollBar.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A horizontal scroll bar for use in other components. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import com.dgrigg.minimalcomps.skins.HScrollBarSkin; 32 | 33 | import flash.display.DisplayObjectContainer; 34 | 35 | /** 36 | * Constructor 37 | * @param parent The parent DisplayObjectContainer on which to add this ScrollBar. 38 | * @param xpos The x position to place this component. 39 | * @param ypos The y position to place this component. 40 | * @param defaultHandler The event handling function to handle the default event for this component (change in this case). 41 | */ 42 | public class HScrollBar extends ScrollBar 43 | { 44 | public function HScrollBar(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function=null) 45 | { 46 | skinClass = com.dgrigg.minimalcomps.skins.HScrollBarSkin 47 | 48 | super(Slider.HORIZONTAL, parent, xpos, ypos, defaultHandler); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HScrollSlider.as: -------------------------------------------------------------------------------- 1 | package com.bit101.components 2 | { 3 | import flash.display.DisplayObjectContainer; 4 | import com.dgrigg.minimalcomps.skins.HScrollSliderSkin; 5 | 6 | public class HScrollSlider extends ScrollSlider 7 | { 8 | public function HScrollSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0) 9 | { 10 | skinClass = com.dgrigg.minimalcomps.skins.HScrollSliderSkin; 11 | super(Slider.HORIZONTAL, parent, xpos, ypos); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HSlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HSlider.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A Horizontal Slider component for choosing values. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import com.dgrigg.minimalcomps.skins.HSliderSkin; 32 | 33 | import flash.display.DisplayObjectContainer; 34 | 35 | public class HSlider extends Slider 36 | { 37 | /** 38 | * Constructor 39 | * @param parent The parent DisplayObjectContainer on which to add this HSlider. 40 | * @param xpos The x position to place this component. 41 | * @param ypos The y position to place this component. 42 | * @param defaultHandler The event handling function to handle the default event for this component. 43 | */ 44 | public function HSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 45 | { 46 | 47 | skinClass = com.dgrigg.minimalcomps.skins.HSliderSkin; 48 | super(Slider.HORIZONTAL, parent, xpos, ypos, defaultHandler); 49 | } 50 | 51 | } 52 | } -------------------------------------------------------------------------------- /src/com/bit101/components/HUISlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * HUISlider.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A Horizontal slider with a label and a value label. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | import flash.events.Event; 33 | 34 | public class HUISlider extends UISlider 35 | { 36 | 37 | /** 38 | * Constructor 39 | * @param parent The parent DisplayObjectContainer on which to add this HUISlider. 40 | * @param xpos The x position to place this component. 41 | * @param ypos The y position to place this component. 42 | * @param label The string to use as the label for this component. 43 | * @param defaultHandler The event handling function to handle the default event for this component. 44 | */ 45 | public function HUISlider(parent:DisplayObjectContainer = null, x:Number = 0, y:Number = 0, label:String = "", defaultEventHandler:Function = null) 46 | { 47 | _sliderClass = HSlider; 48 | super(parent, x, y, label, defaultEventHandler); 49 | } 50 | 51 | /** 52 | * Initializes the component. 53 | */ 54 | override protected function init():void 55 | { 56 | super.init(); 57 | setSize(200, 18); 58 | } 59 | 60 | /** 61 | * Centers the label when label text is changed. 62 | */ 63 | override protected function positionLabel():void 64 | { 65 | _valueLabel.x = _slider.x + _slider.width + 5; 66 | } 67 | 68 | 69 | 70 | 71 | /////////////////////////////////// 72 | // public methods 73 | /////////////////////////////////// 74 | 75 | /** 76 | * Draws the visual ui of this component. 77 | */ 78 | override public function draw():void 79 | { 80 | super.draw(); 81 | _slider.x = _label.width + 5; 82 | _slider.y = height / 2 - _slider.height / 2; 83 | _slider.width = width - _label.width - 50 - 10; 84 | 85 | _valueLabel.x = _slider.x + _slider.width + 5; 86 | } 87 | 88 | /////////////////////////////////// 89 | // event handlers 90 | /////////////////////////////////// 91 | 92 | /////////////////////////////////// 93 | // getter/setters 94 | /////////////////////////////////// 95 | 96 | } 97 | } -------------------------------------------------------------------------------- /src/com/bit101/components/Label.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Label.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A Label component for displaying a single line of text. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import com.dgrigg.minimalcomps.skins.LabelSkin; 32 | import flash.display.DisplayObjectContainer; 33 | import flash.events.Event; 34 | import flash.text.TextField; 35 | import flash.text.TextFieldAutoSize; 36 | import flash.text.TextFormat; 37 | 38 | 39 | public class Label extends Component 40 | { 41 | private var _autoSize:Boolean = true; 42 | private var _text:String = ""; 43 | protected var label:TextField; 44 | 45 | /** 46 | * Constructor 47 | * @param parent The parent DisplayObjectContainer on which to add this Label. 48 | * @param xpos The x position to place this component. 49 | * @param ypos The y position to place this component. 50 | * @param text The string to use as the initial text in this component. 51 | */ 52 | public function Label(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0, text:String = "") 53 | { 54 | this.skinClass = com.dgrigg.minimalcomps.skins.LabelSkin; 55 | this.text = text; 56 | super(parent, xpos, ypos); 57 | } 58 | 59 | /** 60 | * Initializes the component. 61 | */ 62 | override protected function init():void 63 | { 64 | super.init(); 65 | mouseEnabled = false; 66 | mouseChildren = false; 67 | } 68 | 69 | /** 70 | * Creates and adds the child display objects of this component. 71 | */ 72 | override protected function addChildren():void 73 | { 74 | _height = 18; 75 | 76 | draw(); 77 | } 78 | 79 | 80 | 81 | 82 | /////////////////////////////////// 83 | // public methods 84 | /////////////////////////////////// 85 | 86 | /** 87 | * Draws the visual ui of the component. 88 | */ 89 | override public function draw():void 90 | { 91 | super.draw(); 92 | 93 | 94 | if (label) 95 | { 96 | 97 | label.text = _text; 98 | 99 | if(_autoSize) 100 | { 101 | label.autoSize = TextFieldAutoSize.LEFT; 102 | if (_width != label.width) 103 | { 104 | _width = label.width; 105 | dispatchEvent(new Event(Event.RESIZE)); 106 | } 107 | } 108 | else 109 | { 110 | label.autoSize = TextFieldAutoSize.NONE; 111 | label.width = _width; 112 | } 113 | _height = label.height = 18; 114 | } 115 | 116 | } 117 | 118 | /////////////////////////////////// 119 | // event handlers 120 | /////////////////////////////////// 121 | 122 | /////////////////////////////////// 123 | // getter/setters 124 | /////////////////////////////////// 125 | 126 | /** 127 | * Gets / sets the text of this Label. 128 | */ 129 | public function set text(t:String):void 130 | { 131 | _text = t; 132 | if(_text == null) _text = ""; 133 | 134 | invalidate(); 135 | } 136 | public function get text():String 137 | { 138 | return _text; 139 | } 140 | 141 | /** 142 | * Gets / sets whether or not this Label will autosize. 143 | */ 144 | public function set autoSize(b:Boolean):void 145 | { 146 | _autoSize = b; 147 | } 148 | public function get autoSize():Boolean 149 | { 150 | return _autoSize; 151 | } 152 | 153 | override protected function skinPartAdded(part:String, instance:Object):void 154 | { 155 | if (part == "label") 156 | { 157 | label = instance as TextField; 158 | } 159 | } 160 | 161 | /** 162 | * Gets the internal TextField of the label if you need to do further customization of it. 163 | */ 164 | 165 | public function get textField():TextField 166 | { 167 | return label; 168 | } 169 | 170 | } 171 | } -------------------------------------------------------------------------------- /src/com/bit101/components/Panel.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Panel.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A rectangular panel. Can be used as a container for other components. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | import flash.display.Shape; 33 | import flash.display.Sprite; 34 | 35 | public class Panel extends Component 36 | { 37 | private var _mask:Sprite; 38 | private var _background:Shape; 39 | private var _color:int = -1; 40 | private var _shadow:Boolean = true; 41 | 42 | 43 | /** 44 | * Container for content added to this panel. This is masked, so best to add children to content, rather than directly to the panel. 45 | */ 46 | public var content:Sprite; 47 | 48 | 49 | /** 50 | * Constructor 51 | * @param parent The parent DisplayObjectContainer on which to add this Panel. 52 | * @param xpos The x position to place this component. 53 | * @param ypos The y position to place this component. 54 | */ 55 | public function Panel(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0) 56 | { 57 | super(parent, xpos, ypos); 58 | } 59 | 60 | 61 | /** 62 | * Initializes the component. 63 | */ 64 | override protected function init():void 65 | { 66 | super.init(); 67 | setSize(100, 100); 68 | } 69 | 70 | /** 71 | * Creates and adds the child display objects of this component. 72 | */ 73 | override protected function addChildren():void 74 | { 75 | _background = new Shape(); 76 | addChild(_background); 77 | 78 | _mask = new Sprite(); 79 | _mask.mouseEnabled = false; 80 | addChild(_mask); 81 | 82 | content = new Sprite(); 83 | addChild(content); 84 | content.mask = _mask; 85 | 86 | filters = [getShadow(2, true)]; 87 | } 88 | 89 | 90 | 91 | 92 | /////////////////////////////////// 93 | // public methods 94 | /////////////////////////////////// 95 | 96 | /** 97 | * Draws the visual ui of the component. 98 | */ 99 | override public function draw():void 100 | { 101 | super.draw(); 102 | _background.graphics.clear(); 103 | _background.graphics.lineStyle(1, 0, 0.1); 104 | if(_color == -1) 105 | { 106 | _background.graphics.beginFill(Style.PANEL); 107 | } 108 | else 109 | { 110 | _background.graphics.beginFill(_color); 111 | } 112 | _background.graphics.drawRect(0, 0, _width, _height); 113 | _background.graphics.endFill(); 114 | 115 | _mask.graphics.clear(); 116 | _mask.graphics.beginFill(0xff0000); 117 | _mask.graphics.drawRect(0, 0, _width, _height); 118 | _mask.graphics.endFill(); 119 | } 120 | 121 | 122 | 123 | 124 | /////////////////////////////////// 125 | // event handlers 126 | /////////////////////////////////// 127 | 128 | /////////////////////////////////// 129 | // getter/setters 130 | /////////////////////////////////// 131 | 132 | /** 133 | * Gets / sets whether or not this Panel will have an inner shadow. 134 | */ 135 | public function set shadow(b:Boolean):void 136 | { 137 | _shadow = b; 138 | if(_shadow) 139 | { 140 | filters = [getShadow(2, true)]; 141 | } 142 | else 143 | { 144 | filters = []; 145 | } 146 | } 147 | public function get shadow():Boolean 148 | { 149 | return _shadow; 150 | } 151 | 152 | /** 153 | * Gets / sets the backgrond color of this panel. 154 | */ 155 | public function set color(c:int):void 156 | { 157 | _color = c; 158 | invalidate(); 159 | } 160 | public function get color():int 161 | { 162 | return _color; 163 | } 164 | } 165 | } -------------------------------------------------------------------------------- /src/com/bit101/components/ProgressBar.as: -------------------------------------------------------------------------------- 1 | /** 2 | * ProgressBar.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A progress bar component for showing a changing value in relation to a total. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | import flash.display.Sprite; 33 | 34 | public class ProgressBar extends Component 35 | { 36 | private var _back:Sprite; 37 | private var _bar:Sprite; 38 | private var _value:Number = 0; 39 | private var _max:Number = 1; 40 | 41 | /** 42 | * Constructor 43 | * @param parent The parent DisplayObjectContainer on which to add this ProgressBar. 44 | * @param xpos The x position to place this component. 45 | * @param ypos The y position to place this component. 46 | */ 47 | public function ProgressBar(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0) 48 | { 49 | super(parent, xpos, ypos); 50 | } 51 | 52 | 53 | /** 54 | * Initializes the component. 55 | */ 56 | override protected function init():void 57 | { 58 | super.init(); 59 | setSize(100, 10); 60 | } 61 | 62 | /** 63 | * Creates and adds the child display objects of this component. 64 | */ 65 | override protected function addChildren():void 66 | { 67 | _back = new Sprite(); 68 | _back.filters = [getShadow(2, true)]; 69 | addChild(_back); 70 | 71 | _bar = new Sprite(); 72 | _bar.x = 1; 73 | _bar.y = 1; 74 | _bar.filters = [getShadow(1)]; 75 | addChild(_bar); 76 | } 77 | 78 | /** 79 | * Updates the size of the progress bar based on the current value. 80 | */ 81 | protected function update():void 82 | { 83 | _bar.scaleX = _value / _max; 84 | } 85 | 86 | 87 | 88 | 89 | /////////////////////////////////// 90 | // public methods 91 | /////////////////////////////////// 92 | 93 | /** 94 | * Draws the visual ui of the component. 95 | */ 96 | override public function draw():void 97 | { 98 | super.draw(); 99 | _back.graphics.clear(); 100 | _back.graphics.beginFill(Style.BACKGROUND); 101 | _back.graphics.drawRect(0, 0, _width, _height); 102 | _back.graphics.endFill(); 103 | 104 | _bar.graphics.clear(); 105 | _bar.graphics.beginFill(Style.PROGRESS_BAR); 106 | _bar.graphics.drawRect(0, 0, _width - 2, _height - 2); 107 | _bar.graphics.endFill(); 108 | update(); 109 | } 110 | 111 | 112 | 113 | 114 | /////////////////////////////////// 115 | // event handlers 116 | /////////////////////////////////// 117 | 118 | /////////////////////////////////// 119 | // getter/setters 120 | /////////////////////////////////// 121 | 122 | /** 123 | * Gets / sets the maximum value of the ProgressBar. 124 | */ 125 | public function set maximum(m:Number):void 126 | { 127 | _max = m; 128 | _value = Math.min(_value, _max); 129 | update(); 130 | } 131 | public function get maximum():Number 132 | { 133 | return _max; 134 | } 135 | 136 | /** 137 | * Gets / sets the current value of the ProgressBar. 138 | */ 139 | public function set value(v:Number):void 140 | { 141 | _value = Math.min(v, _max); 142 | update(); 143 | } 144 | public function get value():Number 145 | { 146 | return _value; 147 | } 148 | 149 | } 150 | } -------------------------------------------------------------------------------- /src/com/bit101/components/Style.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Style.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A collection of style variables used by the components. 7 | * If you want to customize the colors of your components, change these values BEFORE instantiating any components. 8 | * 9 | * Copyright (c) 2010 Keith Peters 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.bit101.components 31 | { 32 | public class Style 33 | { 34 | public static var BACKGROUND:uint = 0xCCCCCC; 35 | public static var BUTTON_FACE:uint = 0xFFFFFF; 36 | public static var INPUT_TEXT:uint = 0x333333; 37 | public static var LABEL_TEXT:uint = 0x666666; 38 | public static var DROPSHADOW:uint = 0x000000; 39 | public static var PANEL:uint = 0xF3F3F3; 40 | public static var PROGRESS_BAR:uint = 0xFFFFFF; 41 | 42 | public static var embedFonts:Boolean = true; 43 | public static var fontName:String = "PF Ronda Seven"; 44 | public static var fontSize:Number = 8; 45 | } 46 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VBox.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VBox.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A layout container for vertically aligning other components. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | 30 | package com.bit101.components 31 | { 32 | import com.dgrigg.components.Container; 33 | 34 | import flash.display.DisplayObject; 35 | import flash.display.DisplayObjectContainer; 36 | import flash.events.Event; 37 | 38 | public class VBox extends Container 39 | { 40 | private var _spacing:Number = 5; 41 | 42 | 43 | /** 44 | * Constructor 45 | * @param parent The parent DisplayObjectContainer on which to add this PushButton. 46 | * @param xpos The x position to place this component. 47 | * @param ypos The y position to place this component. 48 | */ 49 | public function VBox(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0) 50 | { 51 | super(parent, xpos, ypos); 52 | } 53 | 54 | /** 55 | * Override of addChild to force layout; 56 | */ 57 | override public function addChild(child:DisplayObject) : DisplayObject 58 | { 59 | super.addChild(child); 60 | child.addEventListener(Event.RESIZE, onResize); 61 | invalidate(); 62 | return child; 63 | } 64 | 65 | /** 66 | * Internal handler for resize event of any attached component. Will redo the layout based on new size. 67 | */ 68 | protected function onResize(event:Event):void 69 | { 70 | invalidate(); 71 | } 72 | 73 | /** 74 | * Draws the visual ui of the component, in this case, laying out the sub components. 75 | */ 76 | override public function draw() : void 77 | { 78 | _width = 0; 79 | _height = 0; 80 | var ypos:Number = 0; 81 | for(var i:int = 0; i < numChildren; i++) 82 | { 83 | var child:DisplayObject = getChildAt(i); 84 | child.y = ypos; 85 | ypos += child.height; 86 | ypos += _spacing; 87 | _height += child.height; 88 | _width = Math.max(_width, child.width); 89 | } 90 | _height += _spacing * (numChildren - 1); 91 | dispatchEvent(new Event(Event.RESIZE)); 92 | } 93 | 94 | /** 95 | * Gets / sets the spacing between each sub component. 96 | */ 97 | public function set spacing(s:Number):void 98 | { 99 | _spacing = s; 100 | invalidate(); 101 | } 102 | public function get spacing():Number 103 | { 104 | return _spacing; 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VRangeSlider.as: -------------------------------------------------------------------------------- 1 | package com.bit101.components 2 | { 3 | import flash.display.DisplayObjectContainer; 4 | 5 | public class VRangeSlider extends RangeSlider 6 | { 7 | public function VRangeSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 8 | { 9 | super(VERTICAL, parent, xpos, ypos, defaultHandler); 10 | } 11 | } 12 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VScrollBar.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VScrollBar.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A vertical scroll bar for use in other components. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import com.dgrigg.minimalcomps.skins.VScrollBarSkin; 32 | 33 | import flash.display.DisplayObjectContainer; 34 | 35 | public class VScrollBar extends ScrollBar 36 | { 37 | /** 38 | * Constructor 39 | * @param parent The parent DisplayObjectContainer on which to add this ScrollBar. 40 | * @param xpos The x position to place this component. 41 | * @param ypos The y position to place this component. 42 | * @param defaultHandler The event handling function to handle the default event for this component (change in this case). 43 | */ 44 | public function VScrollBar(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function=null) 45 | { 46 | skinClass = com.dgrigg.minimalcomps.skins.VScrollBarSkin; 47 | 48 | super(Slider.VERTICAL, parent, xpos, ypos, defaultHandler); 49 | } 50 | } 51 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VScrollSlider.as: -------------------------------------------------------------------------------- 1 | package com.bit101.components 2 | { 3 | import flash.display.DisplayObjectContainer; 4 | import com.dgrigg.minimalcomps.skins.VScrollSliderSkin; 5 | 6 | public class VScrollSlider extends ScrollSlider 7 | { 8 | public function VScrollSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 9 | { 10 | skinClass = com.dgrigg.minimalcomps.skins.VScrollSliderSkin; 11 | super(Slider.VERTICAL, parent, xpos, ypos, defaultHandler); 12 | } 13 | } 14 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VSlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VSlider.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A Vertical Slider component for choosing values. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | import com.dgrigg.minimalcomps.skins.VSliderSkin; 33 | 34 | public class VSlider extends Slider 35 | { 36 | /** 37 | * Constructor 38 | * @param parent The parent DisplayObjectContainer on which to add this Slider. 39 | * @param xpos The x position to place this component. 40 | * @param ypos The y position to place this component. 41 | * @param defaultHandler The event handling function to handle the default event for this component. 42 | */ 43 | public function VSlider(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0, defaultHandler:Function = null) 44 | { 45 | super(Slider.VERTICAL, parent, xpos, ypos, defaultHandler); 46 | skinClass = com.dgrigg.minimalcomps.skins.VSliderSkin; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /src/com/bit101/components/VUISlider.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VUISlider.as 3 | * Keith Peters 4 | * version 0.9.2 5 | * 6 | * A vertical Slider with a label and value label. 7 | * 8 | * Copyright (c) 2010 Keith Peters 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in 18 | * all copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | * THE SOFTWARE. 27 | */ 28 | 29 | package com.bit101.components 30 | { 31 | import flash.display.DisplayObjectContainer; 32 | import flash.events.Event; 33 | 34 | public class VUISlider extends UISlider 35 | { 36 | 37 | 38 | /** 39 | * Constructor 40 | * @param parent The parent DisplayObjectContainer on which to add this VUISlider. 41 | * @param xpos The x position to place this component. 42 | * @param ypos The y position to place this component. 43 | * @param label The string to use as the label for this component. 44 | * @param defaultHandler The event handling function to handle the default event for this component. 45 | */ 46 | public function VUISlider(parent:DisplayObjectContainer = null, x:Number = 0, y:Number = 0, label:String = "", defaultEventHandler:Function = null) 47 | { 48 | _sliderClass = VSlider; 49 | super(parent, x, y, label, defaultEventHandler); 50 | } 51 | 52 | /** 53 | * Initializes this component. 54 | */ 55 | protected override function init():void 56 | { 57 | super.init(); 58 | setSize(20, 146); 59 | } 60 | 61 | 62 | 63 | 64 | /////////////////////////////////// 65 | // public methods 66 | /////////////////////////////////// 67 | 68 | override public function draw():void 69 | { 70 | super.draw(); 71 | _label.x = width / 2 - _label.width / 2; 72 | 73 | _slider.x = width / 2 - _slider.width / 2; 74 | _slider.y = _label.height + 5; 75 | _slider.height = height - _label.height - _valueLabel.height - 10; 76 | 77 | _valueLabel.x = width / 2 - _valueLabel.width / 2; 78 | _valueLabel.y = _slider.y + _slider.height + 5; 79 | } 80 | 81 | override protected function positionLabel():void 82 | { 83 | _valueLabel.x = width / 2 - _valueLabel.width / 2; 84 | } 85 | 86 | 87 | 88 | 89 | /////////////////////////////////// 90 | // event handlers 91 | /////////////////////////////////// 92 | 93 | /////////////////////////////////// 94 | // getter/setters 95 | /////////////////////////////////// 96 | 97 | override public function get width():Number 98 | { 99 | if(_label == null) return _width; 100 | return Math.max(_width, _label.width); 101 | } 102 | 103 | } 104 | } -------------------------------------------------------------------------------- /src/com/dgrigg/components/Application.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Application.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * An application container to add content to. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | package com.dgrigg.components 30 | { 31 | import com.bit101.components.Component; 32 | 33 | import flash.display.DisplayObjectContainer; 34 | import flash.events.Event; 35 | 36 | 37 | public class Application extends Container 38 | { 39 | public function Application() 40 | { 41 | super(); 42 | Component.initStage(stage); 43 | 44 | } 45 | } 46 | } -------------------------------------------------------------------------------- /src/com/dgrigg/components/Container.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Container.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * A container to add components to. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.components 31 | { 32 | import flash.display.DisplayObject; 33 | import flash.display.DisplayObjectContainer; 34 | import flash.display.Sprite; 35 | 36 | import com.bit101.components.Component; 37 | 38 | [DefaultProperty("children")] 39 | public class Container extends Component 40 | { 41 | private var _children:Vector. 42 | 43 | public function Container(parent:DisplayObjectContainer = null, xpos:Number = 0, ypos:Number = 0) 44 | { 45 | super(parent, xpos, ypos); 46 | } 47 | 48 | 49 | public function set children(value:Vector.):void 50 | { 51 | if (value != _children) 52 | { 53 | 54 | while (numChildren > 0) 55 | { 56 | removeChildAt(0); 57 | } 58 | 59 | _children = value; 60 | var child:DisplayObject 61 | for each (child in _children) 62 | { 63 | this.addChild(child) 64 | } 65 | } 66 | } 67 | 68 | public function get children():Vector. 69 | { 70 | return _children; 71 | 72 | } 73 | 74 | } 75 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/events/SkinPartEvent.as: -------------------------------------------------------------------------------- 1 | /** 2 | * SkinPartEvent.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Event to notify when skin parts have been added or removed from skins. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.events 31 | { 32 | import flash.events.Event; 33 | 34 | public class SkinPartEvent extends Event 35 | { 36 | public static const PART_ADDED:String = "skinPartAdded"; 37 | public static const PART_REMOVED:String = "skinPartRemoved"; 38 | 39 | public var instance:Object; 40 | public var name:String; 41 | 42 | public function SkinPartEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) 43 | { 44 | super(type, bubbles, cancelable); 45 | } 46 | 47 | override public function clone():Event 48 | { 49 | var e:SkinPartEvent = new SkinPartEvent(type, bubbles, cancelable); 50 | e.name = name; 51 | e.instance = instance; 52 | return e; 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/BitmapImage.as: -------------------------------------------------------------------------------- 1 | /** 2 | * BitmapImage.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * A component for adding raster images (ie png, jpg). 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | import com.dgrigg.minimalcomps.skins.ISkinElement; 33 | 34 | import flash.display.Bitmap; 35 | import flash.display.BitmapData; 36 | import flash.display.DisplayObject; 37 | import flash.display.Graphics; 38 | import flash.display.Sprite; 39 | import flash.events.Event; 40 | import flash.geom.Rectangle; 41 | import flash.utils.describeType; 42 | 43 | 44 | public class BitmapImage extends Sprite implements ISkinElement 45 | { 46 | public var _source:Class; 47 | 48 | //using a Display object so we can straight Bitmaps 49 | //or Bitmaps with Scale9 applied which convert to Sprites 50 | protected var _image:DisplayObject; 51 | 52 | protected var _height:Number = 0; 53 | protected var _width:Number = 0; 54 | 55 | public function BitmapImage() 56 | { 57 | super(); 58 | 59 | } 60 | 61 | override public function set height(value:Number):void 62 | { 63 | _height = value; 64 | invalidate(); 65 | } 66 | 67 | override public function get height():Number 68 | { 69 | return _height; 70 | } 71 | 72 | override public function set width(value:Number):void 73 | { 74 | _width = value; 75 | invalidate(); 76 | } 77 | 78 | override public function get width():Number 79 | { 80 | return _width; 81 | } 82 | 83 | public function set image(value:DisplayObject):void 84 | { 85 | if (_image) 86 | { 87 | removeChild(_image); 88 | } 89 | 90 | _image = value; 91 | addChild(value); 92 | 93 | } 94 | 95 | public function get image():DisplayObject 96 | { 97 | return _image; 98 | } 99 | 100 | public function set source(value:Class):void 101 | { 102 | if (_image) 103 | { 104 | this.removeChild(_image); 105 | } 106 | 107 | image = new value(); 108 | 109 | } 110 | 111 | public function get source():Class 112 | { 113 | return _source; 114 | } 115 | 116 | 117 | 118 | public function validate():void 119 | { 120 | invalidate(); 121 | } 122 | 123 | protected function invalidate():void 124 | { 125 | addEventListener(Event.ENTER_FRAME, onInvalidate, false, 0, true); 126 | } 127 | 128 | protected function onInvalidate(event:Event):void 129 | { 130 | removeEventListener(Event.ENTER_FRAME, onInvalidate, false); 131 | draw(); 132 | } 133 | 134 | protected function draw():void 135 | { 136 | 137 | if (_image) 138 | { 139 | _image.width = _width; 140 | _image.height = _height; 141 | } 142 | 143 | } 144 | 145 | } 146 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/CubicBezier.as: -------------------------------------------------------------------------------- 1 | /** 2 | * CubicBezier.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Draws a curve using the cubic bezier formula. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | import com.dgrigg.utils.Logger; 33 | 34 | import flash.display.Graphics; 35 | import flash.geom.Point; 36 | 37 | public class CubicBezier extends Geometry 38 | { 39 | 40 | //control points 41 | public var cp1:Point; 42 | public var cp2:Point; 43 | public var cp3:Point; 44 | public var cp4:Point; 45 | 46 | //anchor points 47 | public var ap1:Point; 48 | public var ap2:Point; 49 | public var ap3:Point; 50 | public var ap4:Point; 51 | 52 | 53 | 54 | public function CubicBezier() 55 | { 56 | } 57 | 58 | /** 59 | * Ported version of Tim Grouleau's AS2 Bezier functions 60 | * http://timotheegroleau.com/Flash/articles/cubic_bezier/bezier_lib.as 61 | */ 62 | override public function set data(value:String):void 63 | { 64 | _data = value; 65 | 66 | Logger.log("data: "+ value); 67 | 68 | var args:Array = value.split(" "); 69 | if (args.length == 8) 70 | { 71 | 72 | var p1:Point = new Point (args[0], args[1]); 73 | var p2:Point = new Point (args[2], args[3]); 74 | var p3:Point = new Point (args[4], args[5]); 75 | var p4:Point = new Point (args[6], args[7]); 76 | 77 | // calculates the useful base points 78 | var pA:Point = getPointOnSegment(p1, p2, 3/4); 79 | var pB:Point = getPointOnSegment(p4, p3, 3/4); 80 | 81 | // get 1/16 of the [P3, P0] segment 82 | var dx:Number = (p4.x - p1.x)/16; 83 | var dy:Number = (p4.y - p1.y)/16; 84 | 85 | // calculates control point 1 86 | cp1 = getPointOnSegment(p1, p2, 3/8); 87 | 88 | // calculates control point 2 89 | cp2 = getPointOnSegment(pA, pB, 3/8); 90 | 91 | cp2.x -= dx; 92 | cp2.y -= dy; 93 | 94 | // calculates control point 3 95 | cp3 = getPointOnSegment(pB, pA, 3/8); 96 | cp3.x += dx; 97 | cp3.y += dy; 98 | 99 | // calculates control point 4 100 | cp4 = getPointOnSegment(p4, p3, 3/8); 101 | 102 | // calculates the 3 anchor points 103 | ap1 = getMiddle(cp1, cp2); 104 | ap2 = getMiddle(pA, pB); 105 | ap3 = getMiddle(cp3, cp4); 106 | ap4 = p4; 107 | } 108 | 109 | } 110 | 111 | 112 | override public function draw(graphics:Graphics):void 113 | { 114 | 115 | // draw the four quadratic subsegments 116 | graphics.curveTo(cp1.x, cp1.y, ap1.x, ap1.y); 117 | graphics.curveTo(cp2.x, cp2.y, ap2.x, ap2.y); 118 | graphics.curveTo(cp3.x, cp3.y, ap3.x, ap3.y); 119 | graphics.curveTo(cp4.x, cp4.y, ap4.x, ap4.y); 120 | 121 | } 122 | 123 | 124 | protected function getMiddle (p0:Point, p1:Point):Point 125 | { 126 | return new Point(((p0.x + p1.x) / 2), ((p0.y + p1.y) / 2)); 127 | } 128 | 129 | 130 | // return a point on a segment [P0, P1] which distance from P0 131 | // is ratio of the length [P0, P1] 132 | protected function getPointOnSegment (p0:Point, p1:Point, ratio:Number):Point 133 | { 134 | return new Point((p0.x + ((p1.x - p0.x) * ratio)), (p0.y + ((p1.y - p0.y) * ratio))); 135 | } 136 | 137 | 138 | 139 | 140 | } 141 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/Ellipse.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Ellipse.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * A graphic element for drawing ellipses. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | import flash.display.Graphics; 33 | import com.dgrigg.minimalcomps.graphics.Shape; 34 | 35 | 36 | public class Ellipse extends Shape 37 | { 38 | 39 | 40 | override protected function draw():void 41 | { 42 | super.draw(); 43 | graphics.drawEllipse(0,0, width, height); 44 | } 45 | 46 | 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/Geometry.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Geometry.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Base class for geometric elements. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | 33 | import flash.display.Graphics; 34 | import flash.events.EventDispatcher; 35 | import flash.events.IEventDispatcher; 36 | 37 | public class Geometry implements IGeometry 38 | { 39 | 40 | public var x:Number; 41 | public var y:Number; 42 | protected var _data:String; 43 | protected var _graphics:Graphics; 44 | 45 | public function Geometry() 46 | { 47 | //super(target); 48 | } 49 | 50 | public function set data(value:String):void 51 | { 52 | _data = value; 53 | } 54 | 55 | public function get data():String 56 | { 57 | return _data; 58 | } 59 | 60 | public function set graphics(value:Graphics):void 61 | { 62 | _graphics = value; 63 | } 64 | 65 | public function get graphics():Graphics 66 | { 67 | return null; 68 | } 69 | 70 | public function endDraw(graphics:Graphics):void 71 | { 72 | } 73 | 74 | public function draw(graphics:Graphics):void 75 | { 76 | 77 | } 78 | 79 | public function invalidate():void 80 | { 81 | 82 | } 83 | 84 | 85 | } 86 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/GradientFill.as: -------------------------------------------------------------------------------- 1 | /** 2 | * GradientFill.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * A class for creating Gradient fills 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | import com.dgrigg.minimalcomps.graphics.GradientItem; 33 | 34 | import flash.display.GradientType; 35 | import flash.display.Graphics; 36 | import flash.geom.Matrix; 37 | 38 | [DefaultProperty("colors")] 39 | public class GradientFill implements IFill 40 | { 41 | public static const TYPE:String = ""; 42 | protected var _colors:Vector.; 43 | protected var _data:String; 44 | protected var _matrix:Matrix; 45 | protected var _rotation:Number = 0; 46 | protected var _width:Number; 47 | protected var _height:Number; 48 | 49 | public var type:String = GradientType.LINEAR; 50 | protected var gradientColors:Array; 51 | protected var gradientAlphas:Array; 52 | protected var gradientRatios:Array; 53 | 54 | public function GradientFill() 55 | { 56 | 57 | } 58 | 59 | public function set width(value:Number):void 60 | { 61 | _width = value; 62 | } 63 | 64 | public function get width():Number 65 | { 66 | return _width; 67 | } 68 | 69 | public function set height(value:Number):void 70 | { 71 | _height = value; 72 | } 73 | 74 | public function get height():Number 75 | { 76 | return _height; 77 | } 78 | 79 | public function set colors(value:Vector.):void 80 | { 81 | _colors = value; 82 | 83 | gradientColors = new Array(); 84 | gradientAlphas = new Array(); 85 | gradientRatios = new Array(); 86 | 87 | var item:GradientItem; 88 | for each (item in colors) 89 | { 90 | gradientColors.push(item.color); 91 | gradientAlphas.push(item.alpha); 92 | gradientRatios.push(item.ratio); 93 | } 94 | 95 | } 96 | 97 | public function get colors():Vector. 98 | { 99 | return _colors; 100 | } 101 | 102 | public function set matrix(value:Matrix):void 103 | { 104 | _matrix = value; 105 | } 106 | 107 | public function get matrix():Matrix 108 | { 109 | return _matrix; 110 | } 111 | 112 | /** 113 | * gradient rotation in degress 114 | */ 115 | public function set rotation(value:Number):void 116 | { 117 | _rotation = value; 118 | } 119 | 120 | public function get rotation():Number 121 | { 122 | return _rotation 123 | } 124 | 125 | public function set data(value:String):void 126 | { 127 | _data = value; 128 | } 129 | 130 | public function get data():String 131 | { 132 | return _data; 133 | } 134 | 135 | 136 | 137 | public function draw(graphics:Graphics):void 138 | { 139 | var item:GradientItem; 140 | 141 | if (!_matrix) 142 | { 143 | _matrix = new Matrix(); 144 | } 145 | 146 | //convert rotation to radians 147 | var r:Number = _rotation * (Math.PI/180); 148 | _matrix.createGradientBox(_width, _height, r); 149 | 150 | graphics.beginGradientFill(type, gradientColors, gradientAlphas, gradientRatios, _matrix); 151 | } 152 | 153 | public function endDraw(graphics:Graphics):void 154 | { 155 | graphics.endFill(); 156 | } 157 | } 158 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/GradientItem.as: -------------------------------------------------------------------------------- 1 | /** 2 | * GradientItem.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Used by the GraphicFill class to define individual gradients. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | public class GradientItem 33 | { 34 | public var color:uint; 35 | public var alpha:Number; 36 | public var ratio:int; 37 | 38 | public function GradientItem() 39 | { 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/GradientStroke.as: -------------------------------------------------------------------------------- 1 | /** 2 | * GradientStroke.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * A class for creating gradient strokes. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | package com.dgrigg.minimalcomps.graphics 30 | { 31 | import com.dgrigg.minimalcomps.graphics.GradientItem; 32 | 33 | import flash.display.GradientType; 34 | import flash.display.Graphics; 35 | import flash.geom.Matrix; 36 | 37 | [DefaultProperty("colors")] 38 | public class GradientStroke implements IStroke 39 | { 40 | public static const TYPE:String = ""; 41 | protected var _colors:Vector.; 42 | protected var _data:String; 43 | protected var _matrix:Matrix; 44 | protected var _rotation:Number = 0; 45 | protected var _width:Number; 46 | protected var _height:Number; 47 | 48 | public var type:String = GradientType.LINEAR; 49 | public var thickness:Number = 0; 50 | 51 | 52 | protected var gradientColors:Array; 53 | protected var gradientAlphas:Array; 54 | protected var gradientRatios:Array; 55 | 56 | 57 | 58 | public function GradientStroke() 59 | { 60 | 61 | } 62 | 63 | public function set width(value:Number):void 64 | { 65 | _width = value; 66 | } 67 | 68 | public function get width():Number 69 | { 70 | return _width; 71 | } 72 | 73 | public function set height(value:Number):void 74 | { 75 | _height = value; 76 | } 77 | 78 | public function get height():Number 79 | { 80 | return _height; 81 | } 82 | 83 | public function set colors(value:Vector.):void 84 | { 85 | _colors = value; 86 | 87 | gradientColors = new Array(); 88 | gradientAlphas = new Array(); 89 | gradientRatios = new Array(); 90 | 91 | var item:GradientItem; 92 | for each (item in colors) 93 | { 94 | gradientColors.push(item.color); 95 | gradientAlphas.push(item.alpha); 96 | gradientRatios.push(item.ratio); 97 | } 98 | 99 | } 100 | 101 | public function get colors():Vector. 102 | { 103 | return _colors; 104 | } 105 | 106 | public function set matrix(value:Matrix):void 107 | { 108 | _matrix = value; 109 | } 110 | 111 | public function get matrix():Matrix 112 | { 113 | return _matrix; 114 | } 115 | 116 | /** 117 | * gradient rotation in degress 118 | */ 119 | public function set rotation(value:Number):void 120 | { 121 | _rotation = value; 122 | } 123 | 124 | public function get rotation():Number 125 | { 126 | return _rotation 127 | } 128 | 129 | public function set data(value:String):void 130 | { 131 | _data = value; 132 | } 133 | 134 | public function get data():String 135 | { 136 | return _data; 137 | } 138 | 139 | 140 | 141 | public function draw(graphics:Graphics):void 142 | { 143 | var item:GradientItem; 144 | 145 | if (!_matrix) 146 | { 147 | _matrix = new Matrix(); 148 | } 149 | 150 | //convert rotation to radians 151 | var r:Number = _rotation * (Math.PI/180); 152 | _matrix.createGradientBox(_width, _height, r); 153 | 154 | graphics.lineStyle(thickness); 155 | graphics.lineGradientStyle(type, gradientColors, gradientAlphas, gradientRatios, _matrix); 156 | } 157 | 158 | public function endDraw(graphics:Graphics):void 159 | { 160 | graphics.endFill(); 161 | } 162 | } 163 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/IFill.as: -------------------------------------------------------------------------------- 1 | /** 2 | * IFill.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Interface to define Fill objects. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | 33 | public interface IFill extends IGeometry 34 | { 35 | function set width(value:Number):void 36 | 37 | function get width():Number; 38 | 39 | function set height(value:Number):void 40 | 41 | function get height():Number; 42 | } 43 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/IGeometry.as: -------------------------------------------------------------------------------- 1 | /** 2 | * IGeometry.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Interface to define Geometry objects. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | import flash.display.Graphics; 33 | 34 | public interface IGeometry 35 | { 36 | function set data(value:String):void 37 | 38 | function get data():String; 39 | 40 | function draw(graphics:Graphics):void 41 | 42 | function endDraw(graphics:Graphics):void 43 | 44 | 45 | 46 | 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/IGraphic.as: -------------------------------------------------------------------------------- 1 | /** 2 | * IGraphic.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Interface to define graphic objects. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | public interface IGraphic 33 | { 34 | 35 | function set data(value:String):void 36 | 37 | function get data():String; 38 | 39 | function validate():void 40 | 41 | } 42 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/IStroke.as: -------------------------------------------------------------------------------- 1 | /** 2 | * IStroke.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Interface to define drawing strokes. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | 33 | public interface IStroke extends IGeometry 34 | { 35 | function set width(value:Number):void 36 | 37 | function get width():Number; 38 | 39 | function set height(value:Number):void 40 | 41 | function get height():Number; 42 | } 43 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/Line.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Line.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Class to draw lines in the drawing api. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | import com.dgrigg.utils.Logger; 33 | 34 | import flash.display.Graphics; 35 | 36 | public class Line extends Geometry 37 | { 38 | 39 | 40 | public function Line() 41 | { 42 | 43 | } 44 | 45 | override public function set data(value:String):void 46 | { 47 | _data = value; 48 | 49 | var args:Array = value.split(" "); 50 | if (args.length == 2) 51 | { 52 | x = args[0]; 53 | y = args[1]; 54 | } 55 | 56 | } 57 | 58 | 59 | override public function draw(graphics:Graphics):void 60 | { 61 | graphics.lineTo(x,y); 62 | } 63 | 64 | 65 | } 66 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/Move.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Move.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Class to move to points in the drawing api. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | 33 | import flash.display.Graphics; 34 | 35 | import com.dgrigg.utils.Logger; 36 | 37 | public class Move extends Geometry 38 | { 39 | 40 | 41 | public function Move() 42 | { 43 | } 44 | 45 | override public function set data(value:String):void 46 | { 47 | _data = value; 48 | 49 | var args:Array = value.split(" "); 50 | if (args.length == 2) 51 | { 52 | x = args[0]; 53 | y = args[1]; 54 | } 55 | } 56 | 57 | override public function draw(graphics:Graphics):void 58 | { 59 | graphics.moveTo(x,y); 60 | 61 | } 62 | 63 | } 64 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/graphics/Path.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Path.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Defines a path to drawing using the drawing api. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.graphics 31 | { 32 | 33 | 34 | import com.dgrigg.minimalcomps.graphics.IGraphic; 35 | import com.dgrigg.minimalcomps.graphics.Shape; 36 | import com.dgrigg.utils.Logger; 37 | 38 | import flash.display.Graphics; 39 | 40 | 41 | public class Path extends Shape implements IGraphic 42 | { 43 | 44 | 45 | protected var commands:Vector.; 46 | 47 | public function Path(value:String = null) 48 | { 49 | data = value; 50 | } 51 | 52 | /** 53 | * The following command can be used to create a drawing path, values must be space delimited 54 | * M x y - move to x y 55 | * L x y - line to x y 56 | * C cx1 cy1 cx2 cy2 x1 y1 x y - draw a cubic bezier to x y through control point cx1/cy1 and cx2/cy2 57 | * Q cx1 cy1 x y - draw a quadratic bezier to x y through control point cx1/cy1 58 | */ 59 | override public function set data(value:String):void 60 | { 61 | if (value) 62 | { 63 | 64 | //split the commands up and delimit with commas 65 | _data = value.replace(/(\s[CLMQclmq])/gi, ',$1'); 66 | 67 | commands = new Vector.; 68 | 69 | var list:Array = _data.split(","); 70 | var prevCommand:Geometry; 71 | var command:Geometry; 72 | 73 | var len:int = list.length; 74 | var c:String; 75 | var cValue:String; 76 | 77 | //trim expression 78 | var regex:RegExp = /^(\s*)([\W\w]*)(\b\s*$)/; 79 | 80 | //command expression 81 | var cRegex:RegExp = /[CLMQclmq]\s{0,}/; 82 | 83 | 84 | for (var i:int=0;i _width - 4) 149 | { 150 | label.autoSize = false; 151 | label.width = _width - 4; 152 | } 153 | else 154 | { 155 | label.autoSize = true; 156 | } 157 | 158 | 159 | label.move(_width / 2 - label.width / 2, _height / 2 - label.height / 2); 160 | } 161 | } 162 | } 163 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/skins/PushButtonUpArrowSkin.as: -------------------------------------------------------------------------------- 1 | /** 2 | * PushButtonUpArrowSkin.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Default PushButtonUpArrow skin. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.skins 31 | { 32 | import com.bit101.components.Component; 33 | import com.bit101.components.PushButton; 34 | import com.bit101.components.Style; 35 | import com.dgrigg.minimalcomps.graphics.Path; 36 | import com.dgrigg.minimalcomps.graphics.Rect; 37 | import com.dgrigg.minimalcomps.graphics.SolidFill; 38 | import com.dgrigg.minimalcomps.graphics.SolidStroke; 39 | import com.dgrigg.utils.Logger; 40 | 41 | import flash.display.Bitmap; 42 | import flash.events.Event; 43 | 44 | public class PushButtonUpArrowSkin extends Skin 45 | { 46 | public var back:Rect; 47 | public var face:Rect; 48 | public var arrow:Path; 49 | 50 | public function PushButtonUpArrowSkin() 51 | { 52 | super(); 53 | } 54 | 55 | override protected function createChildren():void 56 | { 57 | super.createChildren(); 58 | 59 | var stroke:SolidStroke; 60 | var fill:SolidFill; 61 | 62 | back = new Rect(); 63 | fill = new SolidFill(); 64 | fill.color = Style.BACKGROUND; 65 | back.fill = fill; 66 | back.filters = [getShadow(2, true)]; 67 | addChild(back); 68 | 69 | face = new Rect(); 70 | fill = new SolidFill(); 71 | fill.color = Style.BUTTON_FACE; 72 | face.x = 1; 73 | face.y = 1; 74 | face.filters = [getShadow(1)]; 75 | face.fill = fill; 76 | addChild(face); 77 | 78 | arrow = new Path(); 79 | arrow.data = "M 5 3 L 7 6 L 3 6"; 80 | fill = new SolidFill(); 81 | fill.color = Style.DROPSHADOW; 82 | arrow.fill = fill; 83 | addChild(arrow); 84 | 85 | invalidate(); 86 | 87 | } 88 | 89 | override protected function draw():void 90 | { 91 | 92 | super.draw(); 93 | 94 | if (back) 95 | { 96 | back.width = width; 97 | back.height = height; 98 | 99 | back.validate(); 100 | } 101 | 102 | if (face) 103 | { 104 | face.width = width-2; 105 | face.height = height-2; 106 | 107 | face.validate(); 108 | 109 | if (currentState == "up" || currentState == "over") 110 | { 111 | 112 | face.filters = [getShadow(1)]; 113 | } 114 | else if (currentState == "down") 115 | { 116 | face.filters = [getShadow(1, true)]; 117 | } 118 | } 119 | 120 | 121 | 122 | 123 | } 124 | } 125 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/skins/TextAreaSkin.as: -------------------------------------------------------------------------------- 1 | /** 2 | * TextAreaSkin.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Default TextArea skin. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.skins 31 | { 32 | import com.bit101.components.Panel; 33 | import com.bit101.components.Style; 34 | import com.bit101.components.Text; 35 | import com.bit101.components.VScrollBar; 36 | import com.dgrigg.utils.Logger; 37 | 38 | import flash.display.Bitmap; 39 | import flash.text.TextField; 40 | import flash.text.TextFieldType; 41 | import flash.text.TextFormat; 42 | 43 | 44 | public class TextAreaSkin extends Skin 45 | { 46 | public var panel:Panel; 47 | public var tf:TextField; 48 | public var scrollBar:VScrollBar; 49 | 50 | 51 | public function TextAreaSkin() 52 | { 53 | super(); 54 | } 55 | 56 | override protected function createChildren():void 57 | { 58 | super.createChildren(); 59 | 60 | panel = new Panel(this); 61 | panel.color = 0xffffff; 62 | 63 | tf = new TextField(); 64 | tf.name = "textField"; 65 | tf.x = 2; 66 | tf.y = 2; 67 | tf.height = _height; 68 | tf.embedFonts = Style.embedFonts; 69 | tf.multiline = true; 70 | tf.wordWrap = true; 71 | tf.selectable = true; 72 | tf.type = TextFieldType.INPUT; 73 | tf.defaultTextFormat = new TextFormat(Style.fontName, Style.fontSize, Style.LABEL_TEXT); 74 | addChild(tf); 75 | 76 | scrollBar = new VScrollBar(); 77 | scrollBar.name = "scrollBar"; 78 | scrollBar.width = 10; 79 | addChild(scrollBar); 80 | 81 | } 82 | 83 | override protected function draw():void 84 | { 85 | super.draw(); 86 | panel.setSize(width, height); 87 | panel.draw(); 88 | 89 | tf.width = width - scrollBar.width - 4; 90 | tf.height = height - 4; 91 | 92 | var host:Text = hostComponent as Text; 93 | 94 | if(host.html) 95 | { 96 | tf.htmlText = host.text; 97 | } 98 | else 99 | { 100 | tf.text = host.text; 101 | } 102 | 103 | if(host.editable) 104 | { 105 | tf.mouseEnabled = true; 106 | tf.selectable = true; 107 | tf.type = TextFieldType.INPUT; 108 | } 109 | else 110 | { 111 | tf.mouseEnabled = host.selectable; 112 | tf.selectable = host.selectable; 113 | tf.type = TextFieldType.DYNAMIC; 114 | } 115 | 116 | 117 | if (scrollBar) 118 | { 119 | scrollBar.x = _width - scrollBar.width; 120 | scrollBar.height = height; 121 | scrollBar.draw(); 122 | } 123 | 124 | } 125 | } 126 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/skins/TextSkin.as: -------------------------------------------------------------------------------- 1 | /** 2 | * TextSkin.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Default Text skin. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.skins 31 | { 32 | import com.bit101.components.Panel; 33 | import com.bit101.components.Style; 34 | import com.bit101.components.Text; 35 | 36 | import flash.display.Bitmap; 37 | import flash.text.TextField; 38 | import flash.text.TextFieldType; 39 | import flash.text.TextFormat; 40 | 41 | 42 | public class TextSkin extends Skin 43 | { 44 | public var panel:Panel; 45 | public var tf:TextField; 46 | 47 | 48 | 49 | public function TextSkin() 50 | { 51 | super(); 52 | } 53 | 54 | override protected function createChildren():void 55 | { 56 | panel = new Panel(this); 57 | panel.color = 0xffffff; 58 | 59 | tf = new TextField(); 60 | tf.name = "textField"; 61 | tf.x = 2; 62 | tf.y = 2; 63 | tf.height = _height; 64 | tf.embedFonts = Style.embedFonts; 65 | tf.multiline = true; 66 | tf.wordWrap = true; 67 | tf.selectable = true; 68 | tf.type = TextFieldType.INPUT; 69 | tf.defaultTextFormat = new TextFormat(Style.fontName, Style.fontSize, Style.LABEL_TEXT); 70 | 71 | 72 | 73 | addChild(tf); 74 | 75 | } 76 | 77 | override protected function draw():void 78 | { 79 | super.draw(); 80 | 81 | panel.setSize(width, height); 82 | panel.draw(); 83 | 84 | tf.width = width - 4; 85 | tf.height = height - 4; 86 | 87 | var host:Text = hostComponent as Text; 88 | 89 | if(host.html) 90 | { 91 | tf.htmlText = host.text; 92 | } 93 | else 94 | { 95 | tf.text = host.text; 96 | } 97 | 98 | if(host.editable) 99 | { 100 | tf.mouseEnabled = true; 101 | tf.selectable = true; 102 | tf.type = TextFieldType.INPUT; 103 | } 104 | else 105 | { 106 | tf.mouseEnabled = host.selectable; 107 | tf.selectable = host.selectable; 108 | tf.type = TextFieldType.DYNAMIC; 109 | } 110 | 111 | } 112 | } 113 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/skins/VScrollBarSkin.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VScrollBarSkin.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Default VScrollBarSkin skin. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.skins 31 | { 32 | import com.bit101.components.Component; 33 | import com.bit101.components.PushButton; 34 | import com.bit101.components.Style; 35 | import com.bit101.components.VScrollBar; 36 | import com.bit101.components.VScrollSlider; 37 | import com.bit101.components.VSlider; 38 | import com.dgrigg.minimalcomps.graphics.Rect; 39 | import com.dgrigg.minimalcomps.graphics.SolidFill; 40 | import com.dgrigg.minimalcomps.graphics.SolidStroke; 41 | import com.dgrigg.utils.Logger; 42 | 43 | public class VScrollBarSkin extends Skin 44 | { 45 | 46 | public var scrollSlider:VScrollSlider; 47 | public var upButton:PushButton; 48 | public var downButton:PushButton; 49 | 50 | public function VScrollBarSkin() 51 | { 52 | super(); 53 | } 54 | 55 | override protected function createChildren():void 56 | { 57 | super.createChildren(); 58 | 59 | scrollSlider = new VScrollSlider(); 60 | scrollSlider.name = "scrollSlider"; 61 | addChild(scrollSlider); 62 | 63 | upButton = new PushButton(); 64 | upButton.name = "upButton"; 65 | upButton.skinClass = com.dgrigg.minimalcomps.skins.PushButtonUpArrowSkin; 66 | addChild(upButton); 67 | 68 | downButton = new PushButton(); 69 | downButton.name = "downButton"; 70 | downButton.skinClass = com.dgrigg.minimalcomps.skins.PushButtonDownArrowSkin; 71 | addChild(downButton); 72 | 73 | invalidate(); 74 | 75 | } 76 | 77 | 78 | 79 | override protected function draw():void 80 | { 81 | super.draw(); 82 | 83 | if (upButton) 84 | { 85 | upButton.width = width; 86 | upButton.height = width; 87 | } 88 | 89 | if (downButton) 90 | { 91 | downButton.width = width; 92 | downButton.height = width; 93 | downButton.y = height - width; 94 | } 95 | 96 | if (scrollSlider) 97 | { 98 | scrollSlider.width = width; 99 | scrollSlider.height = height - upButton.height - downButton.height; 100 | scrollSlider.y = upButton.y + upButton.height; 101 | 102 | } 103 | 104 | 105 | } 106 | } 107 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/skins/VScrollSliderSkin.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VScrollSliderSkin.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Default VScrollSlider skin. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.skins 31 | { 32 | import com.bit101.components.Component; 33 | import com.bit101.components.Style; 34 | import com.bit101.components.VScrollSlider; 35 | import com.dgrigg.minimalcomps.graphics.Rect; 36 | import com.dgrigg.minimalcomps.graphics.SolidFill; 37 | import com.dgrigg.minimalcomps.graphics.SolidStroke; 38 | import com.dgrigg.utils.Logger; 39 | public class VScrollSliderSkin extends Skin 40 | { 41 | public var back:Rect; 42 | public var handle:Rect; 43 | 44 | public function VScrollSliderSkin() 45 | { 46 | super(); 47 | } 48 | 49 | override protected function createChildren():void 50 | { 51 | super.createChildren(); 52 | 53 | back = new Rect(); 54 | back.filters = [getShadow(2, true)]; 55 | back.name = "back"; 56 | var fill:SolidFill = new SolidFill(); 57 | fill.color = Style.BACKGROUND; 58 | back.fill = fill; 59 | 60 | addChild(back); 61 | 62 | handle = new Rect(); 63 | handle.filters = [getShadow(1)]; 64 | fill = new SolidFill(); 65 | fill.color = Style.BUTTON_FACE; 66 | handle.fill = fill; 67 | handle.x = 1; 68 | handle.y = 1; 69 | handle.name = "handle"; 70 | handle.buttonMode = true; 71 | handle.useHandCursor = true; 72 | addChild(handle); 73 | 74 | invalidate(); 75 | 76 | } 77 | 78 | 79 | 80 | override protected function draw():void 81 | { 82 | super.draw(); 83 | 84 | 85 | if (back) 86 | { 87 | back.width = width; 88 | back.height = height; 89 | } 90 | 91 | if (handle) 92 | { 93 | var host:VScrollSlider = hostComponent as VScrollSlider; 94 | handle.width = width-2; 95 | handle.height = host.getThumbPercent() * height; 96 | } 97 | 98 | } 99 | } 100 | } -------------------------------------------------------------------------------- /src/com/dgrigg/minimalcomps/skins/VSliderSkin.as: -------------------------------------------------------------------------------- 1 | /** 2 | * VSliderSkin.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 0.0.1 6 | * 7 | * Default VSlider skin. 8 | * 9 | * Copyright (c) 2010 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining a copy 12 | * of this software and associated documentation files (the "Software"), to deal 13 | * in the Software without restriction, including without limitation the rights 14 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | * copies of the Software, and to permit persons to whom the Software is 16 | * furnished to do so, subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be included in 19 | * all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | * THE SOFTWARE. 28 | */ 29 | 30 | package com.dgrigg.minimalcomps.skins 31 | { 32 | import com.bit101.components.Component; 33 | import com.bit101.components.VSlider; 34 | import com.bit101.components.Style; 35 | import com.dgrigg.minimalcomps.graphics.Rect; 36 | import com.dgrigg.minimalcomps.graphics.SolidFill; 37 | import com.dgrigg.minimalcomps.graphics.SolidStroke; 38 | 39 | public class VSliderSkin extends Skin 40 | { 41 | public var back:Rect; 42 | public var handle:Rect; 43 | 44 | public function VSliderSkin() 45 | { 46 | super(); 47 | } 48 | 49 | override protected function createChildren():void 50 | { 51 | super.createChildren(); 52 | 53 | back = new Rect(); 54 | back.filters = [getShadow(2, true)]; 55 | back.name = "back"; 56 | var fill:SolidFill = new SolidFill(); 57 | fill.color = Style.BACKGROUND; 58 | back.fill = fill; 59 | 60 | addChild(back); 61 | 62 | 63 | 64 | handle = new Rect(); 65 | handle.filters = [getShadow(1)]; 66 | fill = new SolidFill(); 67 | fill.color = Style.BUTTON_FACE; 68 | handle.fill = fill; 69 | handle.x = 1; 70 | handle.y = 1; 71 | handle.name = "handle"; 72 | handle.buttonMode = true; 73 | handle.useHandCursor = true; 74 | addChild(handle); 75 | 76 | invalidate(); 77 | 78 | } 79 | 80 | 81 | 82 | override protected function draw():void 83 | { 84 | super.draw(); 85 | 86 | 87 | if (back) 88 | { 89 | back.width = width; 90 | back.height = height; 91 | } 92 | 93 | if (handle) 94 | { 95 | 96 | handle.width = width-2; 97 | handle.height = width-2; 98 | } 99 | 100 | } 101 | } 102 | } -------------------------------------------------------------------------------- /src/com/dgrigg/skins/ButtonImageSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 31 | 37 | 38 | 39 | _width - 4) 67 | { 68 | label.autoSize = false; 69 | label.width = _width - 4; 70 | } 71 | else 72 | { 73 | label.autoSize = true; 74 | } 75 | 76 | var tf:TextFormat = label.textField.defaultTextFormat; 77 | 78 | if (currentState == "over") 79 | { 80 | tf.color = 0xffffff; 81 | } 82 | else 83 | { 84 | tf.color = 0xCCCCCC; 85 | } 86 | 87 | label.textField.defaultTextFormat = tf; 88 | 89 | label.draw(); 90 | label.move(_width / 2 - label.width / 2, _height / 2 - label.height / 2); 91 | 92 | 93 | } 94 | } 95 | 96 | 97 | ]]> 98 | 99 | 100 | 101 | 103 | 104 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/ButtonSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 37 | 38 | 39 | _width - 4) 101 | { 102 | label.autoSize = false; 103 | label.width = _width - 4; 104 | } 105 | else 106 | { 107 | label.autoSize = true; 108 | } 109 | 110 | 111 | label.move(_width / 2 - label.width / 2, _height / 2 - label.height / 2); 112 | } 113 | } 114 | 115 | 116 | ]]> 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/CheckBoxImageSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 36 | 37 | 38 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/CheckBoxSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 36 | 37 | 38 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/HSliderImageSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 36 | 37 | 38 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/HSliderSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 36 | 37 | 38 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/TextImageSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 36 | 37 | 38 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /src/com/dgrigg/skins/TextSkin.mxml: -------------------------------------------------------------------------------- 1 | 2 | 30 | 31 | 37 | 38 | 39 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | -------------------------------------------------------------------------------- /src/com/dgrigg/utils/Logger.as: -------------------------------------------------------------------------------- 1 | /** 2 | * Logger.as 3 | * Derrick Grigg 4 | * www.dgrigg.com 5 | * version 1.0.0 6 | * 7 | * Utility class to output trace and logging statements. 8 | * 9 | * Copyright (c) 2009 Derrick Grigg 10 | * 11 | * Permission is hereby granted, free of charge, to any person 12 | * obtaining a copy of this software and associated documentation 13 | * files (the "Software"), to deal in the Software without 14 | * restriction, including without limitation the rights to use, 15 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 16 | * copies of the Software, and to permit persons to whom the 17 | * Software is furnished to do so, subject to the following 18 | * conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 25 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 27 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 28 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 29 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 30 | * OTHER DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | 34 | package com.dgrigg.utils 35 | { 36 | import flash.external.ExternalInterface; 37 | 38 | public class Logger 39 | { 40 | public function Logger() 41 | { 42 | } 43 | 44 | public static function log(value:Object):void 45 | { 46 | try 47 | { 48 | if (ExternalInterface.available) 49 | { 50 | ExternalInterface.call("console.log", value.toString()); 51 | } 52 | else 53 | { 54 | trace(value.toString()); 55 | } 56 | } 57 | catch (err:Error) 58 | { 59 | 60 | } 61 | 62 | } 63 | 64 | } 65 | } --------------------------------------------------------------------------------