home *** CD-ROM | disk | FTP | other *** search
- package com.livebrush.styles
- {
- import com.livebrush.data.Exchangeable;
- import com.livebrush.data.Settings;
- import com.livebrush.data.Storable;
- import com.livebrush.utils.ColorObj;
-
- public class DecoStyle implements Exchangeable, Storable
- {
- public static const SEQUENCE_DECO:String = "sequence";
-
- public static const FIXED_DECO:String = "fixed";
-
- public static const RANDOM_DECO:String = "random";
-
- public static const A:String = "a";
-
- public static const B:String = "b";
-
- public static const CENTER:String = "center";
-
- public static const ALT:String = "alt";
-
- public static const WIDTH:String = "strokeWidth";
-
- public static const DIR:String = "strokeDirection";
-
- public static const SCATTER:String = "scatter";
-
- public static const ORBIT:String = "orbit";
-
- public static const POS_DIR:String = "posDir";
-
- public static const ROTATE:String = "rotate";
-
- public static const FIXED:String = "fixed";
-
- public static const NONE:String = "none";
-
- public static const OSC:String = "osc";
-
- public static const RANDOM:String = "random";
-
- public static const SPEED:String = "speed";
-
- public static const LIST:String = "list";
-
- public static const STROKE:String = "stroke";
-
- public static const SAMPLE:String = "sample";
-
- public static const ALIGN_CENTER:String = "center";
-
- public static const ALIGN_CORNER:String = "corner";
-
- public static const ALIGN_TL:String = "TL";
-
- public static const ALIGN_TR:String = "TR";
-
- public static const ALIGN_BL:String = "BL";
-
- public static const ALIGN_BR:String = "BR";
-
- public var defaultSettings:Settings;
-
- public var xFlip:Boolean = false;
-
- public var yFlip:Boolean = false;
-
- public var alphaSpeed:Number = 10;
-
- public var colorSteps:int = 50;
-
- public var decoHold:int = 1;
-
- public var maxTint:Number = 0;
-
- public var decoset:XML;
-
- public var decoNum:int = 1;
-
- public var tintSpeed:Number = 1;
-
- public var maxSize:Number = 1;
-
- public var minAngle:Number = 90;
-
- public var minPos:Number = 0;
-
- public var orderType:String = "sequence";
-
- private var _colorList:Array;
-
- public var minAlpha:Number = 0;
-
- public var angleType:String = "strokeDirection";
-
- public var posType:String = "alt";
-
- public var _colorObjList:Array;
-
- public var angleSpeed:Number = 25;
-
- public var style:Style;
-
- public var autoFlip:Boolean = true;
-
- private var _colorType:String = "list";
-
- public var alphaType:String = "stroke";
-
- public var styleManager:StyleManager;
-
- public var sizeSpeed:Number = 10;
-
- public var colorHold:int = 1;
-
- public var selectedDecoIndex:int = 0;
-
- public var maxAngle:Number = 360;
-
- public var posSpeed:Number = 25;
-
- public var persist:Boolean = true;
-
- public var tintType:String = "fixed";
-
- public var maxPos:Number = 1;
-
- public var sizeType:String = "speed";
-
- public var alignType:String = "corner";
-
- public var minTint:Number = 0;
-
- public var maxAlpha:Number = 1;
-
- public var minSize:Number = 0.1;
-
- public var decoSet:DecoSet;
-
- public function DecoStyle(style:Style)
- {
- super();
- this.style = style;
- this.styleManager = style.styleManager;
- this.decoSet = new DecoSet();
- this.decoSet.addDeco("Default");
- this.colorObjList = [new ColorObj(0),new ColorObj(16777215)];
- this.defaultSettings = this.settings;
- }
-
- public function die() : void
- {
- this.decoSet.die();
- delete global[this];
- }
-
- public function get selectedColor() : Number
- {
- return this.colorList[0];
- }
-
- public function get settings() : Settings
- {
- var settings:Settings = new Settings();
- settings.decos = this.decoSet.decos.slice();
- settings.selectedDecoIndex = this.decoSet.selectedDecoIndex;
- settings.orderType = this.orderType;
- settings.posType = this.posType;
- settings.minPos = this.minPos;
- settings.maxPos = this.maxPos;
- settings.posSpeed = this.posSpeed;
- settings.angleType = this.angleType;
- settings.autoFlip = this.autoFlip;
- settings.minAngle = this.minAngle;
- settings.maxAngle = this.maxAngle;
- settings.angleSpeed = this.angleSpeed;
- settings.colorType = this.colorType;
- settings.colorSteps = this.colorSteps;
- settings.colorObjList = Settings.copyArrayOfObjects(this.colorObjList);
- settings.colorHold = this.colorHold;
- settings.alphaType = this.alphaType;
- settings.minAlpha = this.minAlpha;
- settings.maxAlpha = this.maxAlpha;
- settings.alphaSpeed = this.alphaSpeed;
- settings.tintType = this.tintType;
- settings.minTint = this.minTint;
- settings.maxTint = this.maxTint;
- settings.tintSpeed = this.tintSpeed;
- settings.sizeType = this.sizeType;
- settings.minSize = this.minSize;
- settings.maxSize = this.maxSize;
- settings.sizeSpeed = this.sizeSpeed;
- settings.decoNum = this.decoNum;
- settings.decoHold = this.decoHold;
- settings.persist = this.persist;
- settings.alignType = this.alignType;
- return settings;
- }
-
- public function set colorObjList(list:Array) : void
- {
- this._colorObjList = list;
- this._colorList = [];
- var i:int = 0;
- while(i < list.length)
- {
- if(list[i].enabled)
- {
- this._colorList.push(list[i].color);
- }
- i++;
- }
- }
-
- public function get colorList() : Array
- {
- return this._colorList;
- }
-
- public function get colorType() : String
- {
- return this._colorType;
- }
-
- public function get colorStringObjList() : Array
- {
- for(var stringObjList:Array = [],var i:int = 0; i < this.colorObjList.length; stringObjList.push({
- "value":this.colorObjList[i].colorString,
- "enabled":this.colorObjList[i].enabled
- }),i++)
- {
- }
- return stringObjList;
- }
-
- public function set settings(settings:Settings) : void
- {
- this.decoSet.decos = settings.decos;
- this.selectedDecoIndex = settings.selectedDecoIndex;
- this.decoSet.selectedDecoIndex = this.selectedDecoIndex;
- this.orderType = settings.orderType;
- this.posType = settings.posType;
- this.minPos = settings.minPos;
- this.maxPos = settings.maxPos;
- this.posSpeed = settings.posSpeed;
- this.angleType = settings.angleType;
- this.autoFlip = settings.autoFlip;
- this.minAngle = settings.minAngle;
- this.maxAngle = settings.maxAngle;
- this.angleSpeed = settings.angleSpeed;
- this.sizeType = settings.sizeType;
- this.minSize = settings.minSize;
- this.maxSize = settings.maxSize;
- this.sizeSpeed = settings.sizeSpeed;
- this.colorType = settings.colorType;
- this.colorObjList = settings.colorObjList.slice();
- this.colorSteps = settings.colorSteps;
- this.colorHold = settings.colorHold;
- this.tintType = settings.tintType;
- this.minTint = settings.minTint;
- this.maxTint = settings.maxTint;
- this.tintSpeed = settings.tintSpeed;
- this.alphaType = settings.alphaType;
- this.minAlpha = settings.minAlpha;
- this.maxAlpha = settings.maxAlpha;
- this.alphaSpeed = settings.alphaSpeed;
- this.decoNum = settings.decoNum;
- this.decoHold = settings.decoHold;
- this.persist = settings.persist;
- this.alignType = settings.alignType;
- }
-
- public function get colorObjList() : Array
- {
- return this._colorObjList;
- }
-
- public function clone(style:Style) : DecoStyle
- {
- var decoStyle:DecoStyle = new DecoStyle(style);
- decoStyle.settings = this.settings;
- decoStyle.decoSet = this.decoSet.clone();
- return decoStyle;
- }
-
- public function setXML(xml:String) : void
- {
- var i:int;
- var element:XML = null;
- var decoList:Array = null;
- var decoXML:XML = new XML(xml);
- for each(element in decoXML.*)
- {
- try
- {
- if(element.name() != "colorList" && element.name() != "decoList")
- {
- if(element == "true" || element == "false")
- {
- this[element.name()] = element == "true" ? true : false;
- }
- else
- {
- this[element.name()] = element;
- }
- }
- else if(element.name() == "colorList")
- {
- this.colorObjList = Style.objListToColorObjList(Style.propEnabledXMLToList(decoXML.colorList.color));
- }
- }
- catch(e:Error)
- {
- }
- }
- if(this.colorObjList == null || this.colorObjList.length == 0)
- {
- this.colorObjList = [new ColorObj(16711680,true)];
- }
- this.decoSet.die();
- this.decoSet = new DecoSet();
- this.decoSet.selectedDecoIndex = this.selectedDecoIndex;
- try
- {
- decoList = Style.propEnabledXMLToList(decoXML.decoList.deco);
- }
- catch(e:Error)
- {
- }
- for(i = 0; i < decoList.length; i++)
- {
- try
- {
- this.addDeco(decoList[i].value,decoList[i].enabled);
- }
- catch(e:Error)
- {
- }
- }
- try
- {
- this.decoSet.decos = this.decoSet.decos;
- }
- catch(e:Error)
- {
- }
- }
-
- public function addDeco(assetPath:String, enabled:Boolean = true) : void
- {
- this.decoSet.addDeco(assetPath,enabled,false,this.selectedDecoIndex);
- }
-
- public function get selectedDecoAsset() : DecoAsset
- {
- return this.decoSet.getDecoByIndex(this.selectedDecoIndex);
- }
-
- public function getXML() : XML
- {
- var decoXML:XML = new XML(<deco/>);
- decoXML.appendChild(Style.propEnabledListToXML(this.decoSet.decos,"value","enabled","deco"));
- decoXML.appendChild(Settings.varStringToXML("orderType",this));
- decoXML.appendChild(Settings.varStringToXML("selectedDecoIndex",this));
- decoXML.appendChild(Settings.varStringToXML("decoNum",this));
- decoXML.appendChild(Settings.varStringToXML("decoHold",this));
- decoXML.appendChild(Settings.varStringToXML("alignType",this));
- decoXML.appendChild(Settings.varStringToXML("persist",this));
- decoXML.appendChild(Settings.varStringToXML("posType",this));
- decoXML.appendChild(Settings.varStringToXML("minPos",this));
- decoXML.appendChild(Settings.varStringToXML("maxPos",this));
- decoXML.appendChild(Settings.varStringToXML("posSpeed",this));
- decoXML.appendChild(Settings.varStringToXML("angleType",this));
- decoXML.appendChild(Settings.varStringToXML("autoFlip",this));
- decoXML.appendChild(Settings.varStringToXML("minAngle",this));
- decoXML.appendChild(Settings.varStringToXML("maxAngle",this));
- decoXML.appendChild(Settings.varStringToXML("angleSpeed",this));
- decoXML.appendChild(Settings.varStringToXML("sizeType",this));
- decoXML.appendChild(Settings.varStringToXML("minSize",this));
- decoXML.appendChild(Settings.varStringToXML("maxSize",this));
- decoXML.appendChild(Settings.varStringToXML("sizeSpeed",this));
- decoXML.appendChild(Settings.varStringToXML("sizeType",this));
- decoXML.appendChild(Settings.varStringToXML("minSize",this));
- decoXML.appendChild(Settings.varStringToXML("maxSize",this));
- decoXML.appendChild(Settings.varStringToXML("sizeSpeed",this));
- decoXML.appendChild(Settings.varStringToXML("colorType",this));
- decoXML.appendChild(Settings.varStringToXML("colorSteps",this));
- decoXML.appendChild(Style.propEnabledListToXML(this.colorStringObjList,"value","enabled","color"));
- decoXML.appendChild(Settings.varStringToXML("colorHold",this));
- decoXML.appendChild(Settings.varStringToXML("tintType",this));
- decoXML.appendChild(Settings.varStringToXML("minTint",this));
- decoXML.appendChild(Settings.varStringToXML("maxTint",this));
- decoXML.appendChild(Settings.varStringToXML("tintSpeed",this));
- decoXML.appendChild(Settings.varStringToXML("alphaType",this));
- decoXML.appendChild(Settings.varStringToXML("minAlpha",this));
- decoXML.appendChild(Settings.varStringToXML("maxAlpha",this));
- decoXML.appendChild(Settings.varStringToXML("alphaSpeed",this));
- return decoXML;
- }
-
- public function set colorType(s:String) : void
- {
- this._colorType = s;
- }
- }
- }
-
-