Initial commit
This commit is contained in:
commit
0572ac72c7
132
src/com/degrafa/GeometryGroup.as
Normal file
132
src/com/degrafa/GeometryGroup.as
Normal file
@ -0,0 +1,132 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
import com.degrafa.core.collections.GeometryCollection;
|
||||
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Graphics;
|
||||
import flash.geom.Rectangle;
|
||||
import mx.events.PropertyChangeEvent;
|
||||
|
||||
[DefaultProperty("geometry")]
|
||||
[Bindable(event="propertyChange")]
|
||||
/**
|
||||
* GeometryGroup is where composition is achieved for
|
||||
* all Degrafa objects that render to a graphics context. Nested GeometryGroups
|
||||
* can be added each of which may contain IGraphic or IGeometry type objects.
|
||||
* GeometryGroup is the principle building block for compositing.
|
||||
**/
|
||||
public class GeometryGroup extends Graphic implements IGraphic, IGeometry{
|
||||
|
||||
public function GeometryGroup(){
|
||||
super();
|
||||
}
|
||||
|
||||
private var _geometry:GeometryCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.IGeometry")]
|
||||
[ArrayElementType("com.degrafa.IGeometry")]
|
||||
/**
|
||||
* A array of IGeometry objects. Objects of type GraphicText, GraphicImage
|
||||
* and GeometryGroup are added to the target display list.
|
||||
**/
|
||||
public function get geometry():Array{
|
||||
if(!_geometry){_geometry = new GeometryCollection();}
|
||||
return _geometry.items;
|
||||
}
|
||||
public function set geometry(value:Array):void
|
||||
{
|
||||
if(!_geometry){_geometry = new GeometryCollection();}
|
||||
_geometry.items = value;
|
||||
|
||||
|
||||
//add the children is required
|
||||
for each (var item:IGeometry in _geometry.items){
|
||||
if(item is IGraphic){
|
||||
addChild(DisplayObject(item));
|
||||
}
|
||||
}
|
||||
|
||||
//add a listener to the collection
|
||||
if(_geometry && enableEvents){
|
||||
_geometry.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa geometry collection object for this graphic object.
|
||||
**/
|
||||
public function get geometryCollection():GeometryCollection{
|
||||
if(!_geometry){_geometry = new GeometryCollection();}
|
||||
return _geometry;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Principle event handler for any property changes to a
|
||||
* graphic object or it's child objects.
|
||||
**/
|
||||
private function propertyChangeHandler(event:PropertyChangeEvent):void{
|
||||
draw(null,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Begins the draw phase for graphic objects. All graphic objects
|
||||
* override this to do their specific rendering.
|
||||
*
|
||||
* @param graphics The current context to draw to.
|
||||
* @param rc A Rectangle object used for fill bounds.
|
||||
**/
|
||||
override public function draw(graphics:Graphics,rc:Rectangle):void{
|
||||
if(!parent){return;}
|
||||
|
||||
super.draw(null,null);
|
||||
|
||||
if (_geometry){
|
||||
for each (var geometryItem:IGeometry in _geometry.items){
|
||||
|
||||
if(geometryItem is IGraphic){
|
||||
//a IGraphic is a sprite and does not draw to
|
||||
//this graphics object
|
||||
geometryItem.draw(null,null);
|
||||
}
|
||||
else{
|
||||
geometryItem.draw(this.graphics,null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.endDraw(null);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Data is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
public function get data():String{return "";}
|
||||
public function set data(value:String):void{}
|
||||
|
||||
|
||||
}
|
||||
}
|
474
src/com/degrafa/Graphic.as
Normal file
474
src/com/degrafa/Graphic.as
Normal file
@ -0,0 +1,474 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.degrafa{
|
||||
|
||||
import com.degrafa.core.IGraphicsFill;
|
||||
import com.degrafa.core.IGraphicsStroke;
|
||||
import com.degrafa.core.collections.FillCollection;
|
||||
import com.degrafa.core.collections.GraphicsCollection;
|
||||
import com.degrafa.core.collections.StrokeCollection;
|
||||
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Sprite;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
import mx.events.FlexEvent;
|
||||
import mx.utils.NameUtil;
|
||||
|
||||
|
||||
import mx.core.IMXMLObject;
|
||||
import mx.events.PropertyChangeEvent;
|
||||
import mx.events.PropertyChangeEventKind;
|
||||
|
||||
[Event(name="initialize", type="mx.events.FlexEvent")]
|
||||
[Event(name="propertyChange", type="mx.events.PropertyChangeEvent")]
|
||||
[Bindable(event="propertyChange",type="mx.events.PropertyChangeEvent")]
|
||||
|
||||
/**
|
||||
* Graphic is the base class for Degrafa objects that allow complete composition
|
||||
* GeometryGroup for example.
|
||||
*
|
||||
* @see flash.display.Sprite
|
||||
**/
|
||||
public class Graphic extends Sprite implements IMXMLObject{
|
||||
|
||||
/**
|
||||
* Number that specifies the vertical position, in pixels, within the target.
|
||||
**/
|
||||
override public function get y():Number{
|
||||
return super.y;
|
||||
}
|
||||
override public function set y(value:Number):void{
|
||||
super.y = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Number that specifies the horizontal position, in pixels, within the target.
|
||||
**/
|
||||
override public function get x():Number{
|
||||
return super.x;
|
||||
}
|
||||
override public function set x(value:Number):void{
|
||||
super.x = value;
|
||||
}
|
||||
|
||||
private var _width:Number=0;
|
||||
[PercentProxy("percentWidth")]
|
||||
/**
|
||||
* Number that specifies the width, in pixels, in the target's coordinates.
|
||||
**/
|
||||
override public function get width():Number{
|
||||
return _width;
|
||||
}
|
||||
override public function set width(value:Number):void{
|
||||
_width = value;
|
||||
draw(null,null);
|
||||
dispatchEvent(new Event("change"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
private var _height:Number=0;
|
||||
[PercentProxy("percentHeight")]
|
||||
/**
|
||||
* Number that specifies the height, in pixels, in the target's coordinates.
|
||||
**/
|
||||
override public function get height():Number{
|
||||
return _height;
|
||||
}
|
||||
override public function set height(value:Number):void{
|
||||
_height = value;
|
||||
draw(null,null);
|
||||
dispatchEvent(new Event("change"));
|
||||
}
|
||||
|
||||
/**
|
||||
* The default height, in pixels.
|
||||
**/
|
||||
public function get measuredHeight():Number{
|
||||
return _height;
|
||||
}
|
||||
|
||||
/**
|
||||
* The default width, in pixels.
|
||||
**/
|
||||
public function get measuredWidth():Number{
|
||||
return _width;
|
||||
}
|
||||
|
||||
private var _percentWidth:Number;
|
||||
[Inspectable(environment="none")]
|
||||
/**
|
||||
* Number that specifies the width as a percentage of the target.
|
||||
**/
|
||||
public function get percentWidth():Number{
|
||||
return _percentWidth;
|
||||
}
|
||||
public function set percentWidth(value:Number):void{
|
||||
if (_percentWidth == value){return};
|
||||
_percentWidth = value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private var _percentHeight:Number;
|
||||
[Inspectable(environment="none")]
|
||||
/**
|
||||
* Number that specifies the height as a percentage of the target.
|
||||
**/
|
||||
public function get percentHeight():Number{
|
||||
return _percentHeight;
|
||||
}
|
||||
public function set percentHeight(value:Number):void{
|
||||
if (_percentHeight == value){return;}
|
||||
_percentHeight = value;
|
||||
|
||||
}
|
||||
|
||||
|
||||
private var _target:DisplayObjectContainer;
|
||||
/**
|
||||
* A target DisplayObjectContainer that this graphic object should be added or drawn to.
|
||||
**/
|
||||
public function get target():DisplayObjectContainer{
|
||||
return _target;
|
||||
}
|
||||
public function set target(value:DisplayObjectContainer):void{
|
||||
|
||||
if (!value){return;}
|
||||
|
||||
//reparent if nessesary
|
||||
if (_target != value && _target!=null)
|
||||
{
|
||||
//remove this obejct from previous parent
|
||||
_target.removeChild(this);
|
||||
}
|
||||
|
||||
_target = value;
|
||||
_target.addChild(this);
|
||||
|
||||
//draw the obejct
|
||||
draw(null,null);
|
||||
endDraw(null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private var _stroke:IGraphicsStroke;
|
||||
/**
|
||||
* Defines the stroke object that will be used for
|
||||
* rendering this graphic object.
|
||||
**/
|
||||
public function get stroke():IGraphicsStroke{
|
||||
return _stroke;
|
||||
}
|
||||
public function set stroke(value:IGraphicsStroke):void{
|
||||
_stroke = value;
|
||||
}
|
||||
|
||||
|
||||
private var _fill:IGraphicsFill;
|
||||
/**
|
||||
* Defines the fill object that will be used for
|
||||
* rendering this graphic object.
|
||||
**/
|
||||
public function get fill():IGraphicsFill{
|
||||
return _fill;
|
||||
}
|
||||
public function set fill(value:IGraphicsFill):void{
|
||||
_fill=value;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private var _fills:FillCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.core.IGraphicsFill")]
|
||||
[ArrayElementType("com.degrafa.core.IGraphicsFill")]
|
||||
/**
|
||||
* A array of IGraphicsFill objects.
|
||||
**/
|
||||
public function get fills():Array{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
return _fills.items;
|
||||
}
|
||||
public function set fills(value:Array):void{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
_fills.items = value;
|
||||
|
||||
//add a listener to the collection
|
||||
if(_fills && enableEvents){
|
||||
_fills.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa fill collection object for this graphic object.
|
||||
**/
|
||||
public function get fillCollection():FillCollection{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
return _fills;
|
||||
}
|
||||
|
||||
|
||||
private var _strokes:StrokeCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.core.IGraphicsStroke")]
|
||||
[ArrayElementType("com.degrafa.core.IGraphicsStroke")]
|
||||
/**
|
||||
* A array of IStroke objects.
|
||||
**/
|
||||
public function get strokes():Array{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
return _strokes.items;
|
||||
}
|
||||
public function set strokes(value:Array):void{
|
||||
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
_strokes.items = value;
|
||||
|
||||
|
||||
//add a listener to the collection
|
||||
if(_strokes && enableEvents){
|
||||
_strokes.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa stroke collection object for this graphic object.
|
||||
**/
|
||||
public function get strokeCollection():StrokeCollection{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
return _strokes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Principle event handler for any property changes to a
|
||||
* graphic object or it's child objects.
|
||||
**/
|
||||
private function propertyChangeHandler(event:PropertyChangeEvent):void{
|
||||
draw(null,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ends the draw phase for geometry objects.
|
||||
*
|
||||
* @param graphics The current Graphics context being drawn to.
|
||||
**/
|
||||
public function endDraw(graphics:Graphics):void{
|
||||
|
||||
if (fill){
|
||||
fill.end(this.graphics);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Begins the draw phase for geometry objects. All geometry objects
|
||||
* override this to do their specific rendering.
|
||||
*
|
||||
* @param graphics The current context to draw to.
|
||||
* @param rc A Rectangle object used for fill bounds.
|
||||
**/
|
||||
public function draw(graphics:Graphics,rc:Rectangle):void{
|
||||
|
||||
if (!parent){return;}
|
||||
|
||||
if(percentWidth || percentHeight)
|
||||
{
|
||||
//calculate based on the parent
|
||||
_width = (parent.width/100)*_percentHeight;
|
||||
_height = (parent.height/100)*_percentHeight;
|
||||
}
|
||||
|
||||
|
||||
this.graphics.clear();
|
||||
|
||||
if (stroke)
|
||||
{
|
||||
if(!rc){
|
||||
stroke.apply(this.graphics,null);
|
||||
}
|
||||
else{
|
||||
stroke.apply(this.graphics,rc);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.graphics.lineStyle(0, 0xFFFFFF, 0);
|
||||
}
|
||||
|
||||
|
||||
if (fill){
|
||||
|
||||
if(!rc){
|
||||
var rect:Rectangle = new Rectangle(0,0,width,height);
|
||||
fill.begin(this.graphics, rect);
|
||||
}
|
||||
else{
|
||||
fill.begin(this.graphics, rc);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private var _enableEvents:Boolean=true;
|
||||
/**
|
||||
* Enable events for this object.
|
||||
**/
|
||||
public function get enableEvents():Boolean{
|
||||
return _enableEvents;
|
||||
}
|
||||
public function set enableEvents(value:Boolean):void{
|
||||
_enableEvents=value;
|
||||
}
|
||||
|
||||
private var _surpressEventProcessing:Boolean=false;
|
||||
/**
|
||||
* Temporarily suppress event processing for this object.
|
||||
**/
|
||||
public function get surpressEventProcessing():Boolean{
|
||||
return _surpressEventProcessing;
|
||||
}
|
||||
public function set surpressEventProcessing(value:Boolean):void{
|
||||
|
||||
if(_surpressEventProcessing==true && value==false){
|
||||
_surpressEventProcessing=value;
|
||||
initChange("surpressEventProcessing",false,true,this);
|
||||
}
|
||||
else{
|
||||
_surpressEventProcessing=value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event into the event flow.
|
||||
*
|
||||
* @see EventDispatcher
|
||||
**/
|
||||
override public function dispatchEvent(event:Event):Boolean{
|
||||
if(_surpressEventProcessing){return false;}
|
||||
|
||||
return(super.dispatchEvent(event));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an property change event into the event flow.
|
||||
**/
|
||||
public function dispatchPropertyChange(bubbles:Boolean = false,
|
||||
property:Object = null, oldValue:Object = null,
|
||||
newValue:Object = null, source:Object = null):Boolean{
|
||||
return dispatchEvent(new PropertyChangeEvent("propertyChange",bubbles,false,PropertyChangeEventKind.UPDATE,property,oldValue,newValue,source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for dispatching property changes
|
||||
**/
|
||||
public function initChange(property:String,oldValue:Object,newValue:Object,source:Object):void{
|
||||
if(hasEventManager){
|
||||
dispatchPropertyChange(false,property,oldValue,newValue,source);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to see if a EventDispatcher instance has been created for this object.
|
||||
**/
|
||||
public function get hasEventManager():Boolean{
|
||||
return true;
|
||||
}
|
||||
|
||||
//specific identity code
|
||||
|
||||
private var _id:String;
|
||||
/**
|
||||
* The identifier used by document to refer to this object.
|
||||
**/
|
||||
public function get id():String{
|
||||
|
||||
if(_id){
|
||||
return _id;
|
||||
}
|
||||
else{
|
||||
_id =NameUtil.createUniqueName(this);
|
||||
name=_id;
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
public function set id(value:String):void{
|
||||
_id = value;
|
||||
name=_id;
|
||||
}
|
||||
|
||||
|
||||
private var _document:Object;
|
||||
/**
|
||||
* The MXML document that created this object.
|
||||
**/
|
||||
public function get document():Object{
|
||||
return _document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the implementing object has been created and all component properties specified on the MXML tag have been initialized.
|
||||
*
|
||||
* @param document The MXML document that created this object.
|
||||
* @param id The identifier used by document to refer to this object.
|
||||
**/
|
||||
public function initialized(document:Object, id:String):void {
|
||||
|
||||
//if the id has not been set (through as perhaps)
|
||||
if(!_id){
|
||||
if(id){
|
||||
_id = id;
|
||||
}
|
||||
else{
|
||||
//if no id specified create one
|
||||
_id = NameUtil.createUniqueName(this);
|
||||
}
|
||||
}
|
||||
|
||||
//sprit has a name property and it is set
|
||||
//to the instance value. Make sure it is the
|
||||
//same as the id
|
||||
name=_id;
|
||||
|
||||
_document=document;
|
||||
|
||||
if(enableEvents && !surpressEventProcessing){
|
||||
dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
106
src/com/degrafa/GraphicImage.as
Normal file
106
src/com/degrafa/GraphicImage.as
Normal file
@ -0,0 +1,106 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.degrafa{
|
||||
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Graphics;
|
||||
import flash.display.Loader;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.net.URLRequest;
|
||||
|
||||
[Bindable(event="propertyChange")]
|
||||
/**
|
||||
* GraphicImage Enables support for images to be added to compositions.
|
||||
**/
|
||||
public class GraphicImage extends Graphic implements IGraphic, IGeometry{
|
||||
|
||||
public function GraphicImage(){
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Data is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
public function get data():String{return "";}
|
||||
public function set data(value:String):void{}
|
||||
|
||||
private var loader:Loader;
|
||||
private var _source:Object;
|
||||
|
||||
/**
|
||||
* The URL, class or string name of a class to load as the content
|
||||
**/
|
||||
public function get source():Object{
|
||||
return _source;
|
||||
}
|
||||
public function set source(value:Object):void{
|
||||
_source = value;
|
||||
|
||||
var newClass:Class;
|
||||
|
||||
if (_source is Class)
|
||||
{
|
||||
newClass = Class(_source);
|
||||
}
|
||||
else if (_source is String)
|
||||
{
|
||||
//treat as a url so need a loader
|
||||
loader = new Loader();
|
||||
var urlRequest:URLRequest = new URLRequest(String(_source));
|
||||
loader.load(urlRequest);
|
||||
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoaded);
|
||||
}
|
||||
|
||||
if(newClass){
|
||||
var child:DisplayObject;
|
||||
child = new newClass();
|
||||
addChild(child);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the image has been successfully loaded.
|
||||
**/
|
||||
private function onLoaded(event:Event):void{
|
||||
addChild(event.target.content);
|
||||
loader.contentLoaderInfo.removeEventListener(Event.COMPLETE, onLoaded);
|
||||
}
|
||||
|
||||
/**
|
||||
* draw is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
override public function draw(graphics:Graphics,rc:Rectangle):void{}
|
||||
|
||||
/**
|
||||
* endDraw is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
override public function endDraw(graphics:Graphics):void{}
|
||||
|
||||
|
||||
}
|
||||
}
|
39
src/com/degrafa/GraphicPoint.as
Normal file
39
src/com/degrafa/GraphicPoint.as
Normal file
@ -0,0 +1,39 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
import flash.geom.Point;
|
||||
|
||||
[Bindable]
|
||||
/**
|
||||
* Simple point definition.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public class GraphicPoint extends Point implements IGraphicPoint{
|
||||
|
||||
public function GraphicPoint(x:Number=0, y:Number=0){
|
||||
super(x, y);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
260
src/com/degrafa/GraphicPointEX.as
Normal file
260
src/com/degrafa/GraphicPointEX.as
Normal file
@ -0,0 +1,260 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
|
||||
/**
|
||||
* servers as a proxy wrapper so we can get the event manager in here.
|
||||
* This should/can not be used in a matrix where flex/flash expect a
|
||||
* point. But rather use/pass/set the point property when required. It should
|
||||
* never evenr be used on a complex graphic. It is intended to be wrapped for
|
||||
* a current object if manipulation is required.
|
||||
**/
|
||||
|
||||
import com.degrafa.core.DegrafaObject;
|
||||
import flash.geom.Point;
|
||||
import mx.events.PropertyChangeEvent;
|
||||
|
||||
|
||||
[Bindable(event="propertyChange")]
|
||||
/**
|
||||
* Extended Degrafa event enabled point definition.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public class GraphicPointEX extends DegrafaObject implements IGraphicPoint{
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* <p>The graphic extended point constructor accepts 2 optional arguments that define it's
|
||||
* x, and y coordinate values.</p>
|
||||
*
|
||||
* @param x A number indicating the x-axis coordinate.
|
||||
* @param y A number indicating the y-axis coordinate.
|
||||
*
|
||||
*/
|
||||
public function GraphicPointEX(x:Number=0, y:Number=0){
|
||||
this.x=x
|
||||
this.y=y
|
||||
this.point.x=x
|
||||
this.point.y=y
|
||||
}
|
||||
|
||||
private var _data:String;
|
||||
/**
|
||||
* GraphicPointEX short hand data value.
|
||||
*
|
||||
* <p>The extended graphic point data property expects exactly 2 values x and
|
||||
* y separated by spaces.</p>
|
||||
**/
|
||||
public function get data():String{
|
||||
return _data;
|
||||
}
|
||||
public function set data(value:String):void
|
||||
{
|
||||
if(_data != value){
|
||||
var oldValue:String=_data;
|
||||
|
||||
_data = value;
|
||||
|
||||
var tempArray:Array = value.split(" ");
|
||||
|
||||
if (tempArray.length == 2)
|
||||
{
|
||||
_x=tempArray[0];
|
||||
_y=tempArray[1];
|
||||
}
|
||||
|
||||
_point.x=_x
|
||||
_point.y=_y
|
||||
|
||||
//call local helper to dispatch event
|
||||
if(enableEvents){
|
||||
initChange("data",oldValue,value,this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private var _point:Point=new Point();
|
||||
/**
|
||||
* The internal point object.
|
||||
**/
|
||||
public function get point():Point{
|
||||
return _point;
|
||||
}
|
||||
public function set point(value:Point):void{
|
||||
if(!_point.equals(value)){
|
||||
|
||||
var oldValue:Point=_point;
|
||||
_point = value;
|
||||
|
||||
_x=_point.x;
|
||||
_y=_point.y;
|
||||
|
||||
//call local helper to dispatch event
|
||||
if(enableEvents){
|
||||
initChange("data",oldValue,value,this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private var _x:Number=0;
|
||||
/**
|
||||
* The x-coordinate of the point. If not specified
|
||||
* a default value of 0 is used.
|
||||
**/
|
||||
public function get x():Number{
|
||||
return _x;
|
||||
}
|
||||
public function set x(value:Number):void{
|
||||
if(_x != value){
|
||||
var oldValue:Number=_x;
|
||||
|
||||
_x = value;
|
||||
_point.y=_x;
|
||||
|
||||
//call local helper to dispatch event
|
||||
if(enableEvents){
|
||||
initChange("x",oldValue,_x,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private var _y:Number=0;
|
||||
/**
|
||||
* The y-coordinate of the point. If not specified
|
||||
* a default value of 0 is used.
|
||||
**/
|
||||
public function get y():Number{
|
||||
return _y;
|
||||
}
|
||||
public function set y(value:Number):void{
|
||||
if(_y != value){
|
||||
var oldValue:Number=_y;
|
||||
|
||||
_y = value;
|
||||
_point.y=_y;
|
||||
|
||||
//call local helper to dispatch event
|
||||
if(enableEvents){
|
||||
initChange("y",oldValue,_y,this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the coordinates of another point to the coordinates of this point to create a new point.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function add(v:Point):Point{
|
||||
return _point.add(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of this Point object.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function clone():Point {
|
||||
return _point.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the distance between pt1 and pt2.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public static function distance(pt1:Point, pt2:Point):Number{
|
||||
return Point.distance(pt1,pt2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether two points are equal.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function equals(toCompare:Point):Boolean {
|
||||
return _point.equals(toCompare);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines a point between two specified points.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public static function interpolate(pt1:Point, pt2:Point, f:Number):Point{
|
||||
return Point.interpolate(pt1,pt2,f);
|
||||
}
|
||||
|
||||
/**
|
||||
* Scales the line segment between (0,0) and the current point to a set length.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function normalize(thickness:Number):void {
|
||||
_point.normalize(thickness);
|
||||
}
|
||||
|
||||
/**
|
||||
* Offsets the Point object by the specified amount.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function offset(dx:Number, dy:Number):void {
|
||||
_point.offset(dx,dy);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a pair of polar coordinates to a Cartesian point coordinate.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public static function polar(len:Number, angle:Number):Point{
|
||||
return Point.polar(len,angle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtracts the coordinates of another point from the coordinates of this point to create a new point.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function subtract(v:Point):Point{
|
||||
return _point.subtract(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* The length from (0,0) to this point.
|
||||
*
|
||||
* @see flash.geom.Point
|
||||
**/
|
||||
public function get length():Number{
|
||||
return _point.length;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
532
src/com/degrafa/GraphicText.as
Normal file
532
src/com/degrafa/GraphicText.as
Normal file
@ -0,0 +1,532 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
package com.degrafa
|
||||
{
|
||||
import com.degrafa.core.IGraphicsFill;
|
||||
import com.degrafa.core.IGraphicsStroke;
|
||||
import com.degrafa.core.collections.FillCollection;
|
||||
import com.degrafa.core.collections.StrokeCollection;
|
||||
import com.degrafa.paint.SolidFill;
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Graphics;
|
||||
import flash.events.Event;
|
||||
import flash.geom.Rectangle;
|
||||
import flash.text.TextField;
|
||||
import flash.text.TextFormat;
|
||||
import mx.events.FlexEvent;
|
||||
import mx.utils.NameUtil;
|
||||
import mx.core.IMXMLObject;
|
||||
import mx.events.PropertyChangeEvent;
|
||||
import mx.events.PropertyChangeEventKind;
|
||||
|
||||
/**
|
||||
* some of these will be added back at a later date
|
||||
**/
|
||||
|
||||
[Exclude(name="percentHeight", kind="property")]
|
||||
[Exclude(name="percentWidth", kind="property")]
|
||||
[Exclude(name="measuredWidth", kind="property")]
|
||||
[Exclude(name="measuredHeight", kind="property")]
|
||||
[Exclude(name="target", kind="property")]
|
||||
[Exclude(name="stroke", kind="property")]
|
||||
[Exclude(name="fills", kind="property")]
|
||||
[Exclude(name="strokes", kind="property")]
|
||||
|
||||
[Bindable(event="propertyChange")]
|
||||
|
||||
/**
|
||||
* GraphicText extends TextField and enables support for text fields
|
||||
* to be added to compositions.
|
||||
*
|
||||
* @see flash.text.TextField
|
||||
**/
|
||||
public class GraphicText extends TextField implements IGraphic, IGeometry, IMXMLObject
|
||||
{
|
||||
public function GraphicText()
|
||||
{
|
||||
super();
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
|
||||
/**
|
||||
* Data is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
public function get data():String{return "";}
|
||||
public function set data(value:String):void{}
|
||||
|
||||
|
||||
/**
|
||||
* Text format.
|
||||
*
|
||||
* @see flash.text.TextFormat
|
||||
**/
|
||||
private var _textFormat:TextFormat=new TextFormat();
|
||||
public function get textFormat():TextFormat{
|
||||
return _textFormat;
|
||||
}
|
||||
public function set textFormat(value:TextFormat):void{
|
||||
_textFormat = value;
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Controls automatic sizing and alignment of text fields.
|
||||
*
|
||||
* @see flash.text.TextField
|
||||
**/
|
||||
private var _autoSize:String="none";
|
||||
[Inspectable(category="General", enumeration="none,left,center", defaultValue="none")]
|
||||
override public function get autoSize():String{
|
||||
return _autoSize;
|
||||
}
|
||||
override public function set autoSize(value:String):void{
|
||||
_autoSize = value;
|
||||
autoSize =_autoSize;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Autosize the text field to text size. When set to true the
|
||||
* GraphicText object will size to fit the height and width of
|
||||
* the text.
|
||||
**/
|
||||
private var _autoSizeField:Boolean=true;
|
||||
public function get autoSizeField():Boolean{
|
||||
return _autoSizeField;
|
||||
}
|
||||
public function set autoSizeField(value:Boolean):void{
|
||||
_autoSizeField = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* A string that is the current text in the text field.
|
||||
**/
|
||||
override public function set text(value:String):void{
|
||||
|
||||
super.text = value;
|
||||
|
||||
//NOTE: added the 5px offset as the left and bottom was
|
||||
//being cut off requires investigation
|
||||
|
||||
if(_autoSizeField){
|
||||
width = textWidth +5;
|
||||
height = textHeight +5;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Indicates the color of the text.
|
||||
*
|
||||
* @see flash.text.TextFormat
|
||||
**/
|
||||
private var _color:uint;
|
||||
public function set color(value:uint):void{
|
||||
_color = value;
|
||||
_textFormat.color = _color;
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
public function get color():uint{
|
||||
return _color;
|
||||
}
|
||||
|
||||
/**
|
||||
* The name of the font for text in this text format, as a string.
|
||||
*
|
||||
* @see flash.text.TextFormat
|
||||
**/
|
||||
private var _fontFamilly:String;
|
||||
public function set fontFamilly(value:String):void{
|
||||
_fontFamilly = value;
|
||||
_textFormat.font = _fontFamilly;
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
public function get fontFamilly():String{
|
||||
return _fontFamilly;
|
||||
}
|
||||
|
||||
/**
|
||||
* The point size of text in this text format.
|
||||
*
|
||||
* @see flash.text.TextFormat
|
||||
**/
|
||||
private var _fontSize:Number;
|
||||
public function set fontSize(value:Number):void{
|
||||
_fontSize = value;
|
||||
_textFormat.size = _fontSize;
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
public function get fontSize():Number{
|
||||
return _fontSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies whether the text is normal or boldface.
|
||||
*
|
||||
* @see flash.text.TextFormat
|
||||
**/
|
||||
private var _fontWeight:String="normal";
|
||||
[Inspectable(category="General", enumeration="normal,bold", defaultValue="normal")]
|
||||
public function set fontWeight(value:String):void{
|
||||
_fontWeight = value;
|
||||
_textFormat.bold = (_fontWeight == "bold") ? true: false;
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
public function get fontWeight():String{
|
||||
return _fontWeight;
|
||||
}
|
||||
|
||||
/**
|
||||
* A number representing the amount of space that is uniformly distributed between all characters.
|
||||
*
|
||||
* @see flash.text.TextFormat
|
||||
**/
|
||||
private var _letterSpacing:int;
|
||||
public function set letterSpacing(value:int):void{
|
||||
_letterSpacing = value;
|
||||
_textFormat.letterSpacing = _letterSpacing;
|
||||
defaultTextFormat = _textFormat;
|
||||
}
|
||||
public function get letterSpacing():int{
|
||||
return _letterSpacing;
|
||||
}
|
||||
|
||||
private var _stroke:IGraphicsStroke;
|
||||
/**
|
||||
* Defines the stroke object that will be used for
|
||||
* rendering this geometry object. Coming soon has no effect here.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
public function get stroke():IGraphicsStroke{
|
||||
return _stroke;
|
||||
}
|
||||
public function set stroke(value:IGraphicsStroke):void{
|
||||
if(_stroke != value){
|
||||
|
||||
if(_stroke){
|
||||
if(_stroke.hasEventManager){
|
||||
_stroke.removeEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
_stroke = value;
|
||||
|
||||
if(enableEvents){
|
||||
_stroke.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler,false,0,true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the fill object that will be used for
|
||||
* rendering this geometry object. Coming soon has no effect here.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
private var _fill:IGraphicsFill;
|
||||
public function get fill():IGraphicsFill{
|
||||
return _fill;
|
||||
}
|
||||
public function set fill(value:IGraphicsFill):void{
|
||||
_fill=value;
|
||||
|
||||
if (_fill is SolidFill){
|
||||
color = uint(SolidFill(_fill).color);
|
||||
}
|
||||
else{
|
||||
//gradient fill need to do runtime mask
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private var _fills:FillCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.IGraphicsFill")]
|
||||
[ArrayElementType("com.degrafa.IGraphicsFill")]
|
||||
/**
|
||||
* A array of IGraphicsFill objects.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
public function get fills():Array{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
return _fills.items;
|
||||
|
||||
}
|
||||
public function set fills(value:Array):void{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
_fills.items = value;
|
||||
|
||||
|
||||
//add a listener to the collection
|
||||
if(_fills && enableEvents){
|
||||
_fills.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Access to the Degrafa fill collection object for this graphic object.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
public function get fillCollection():FillCollection{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
return _fills;
|
||||
}
|
||||
|
||||
|
||||
private var _strokes:StrokeCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.IGraphicsStroke")]
|
||||
[ArrayElementType("com.degrafa.IGraphicsStroke")]
|
||||
/**
|
||||
* A array of IStroke objects.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
public function get strokes():Array{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
return _strokes.items;
|
||||
}
|
||||
public function set strokes(value:Array):void{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
_strokes.items = value;
|
||||
|
||||
//add a listener to the collection
|
||||
if(_strokes && enableEvents){
|
||||
_strokes.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa stroke collection object for this graphic object.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
public function get strokeCollection():StrokeCollection{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
return _strokes;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Principle event handler for any property changes to a
|
||||
* graphic object or it's child objects.
|
||||
*
|
||||
* @private
|
||||
**/
|
||||
private function propertyChangeHandler(event:PropertyChangeEvent):void{
|
||||
draw(null,null);
|
||||
}
|
||||
|
||||
/**
|
||||
* draw is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
|
||||
public function draw(graphics:Graphics,rc:Rectangle):void{}
|
||||
/**
|
||||
* endDraw is required for the IGeometry interface and has no effect here.
|
||||
* @private
|
||||
**/
|
||||
public function endDraw(graphics:Graphics):void{}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* the below are all excluded for now
|
||||
**/
|
||||
|
||||
/**
|
||||
* @private
|
||||
**/
|
||||
public function get percentHeight():Number{return 0;}
|
||||
public function set percentHeight(value:Number):void{}
|
||||
|
||||
/**
|
||||
* @private
|
||||
**/
|
||||
public function get percentWidth():Number{return 0;}
|
||||
public function set percentWidth(value:Number):void{}
|
||||
|
||||
/**
|
||||
* @private
|
||||
**/
|
||||
public function get measuredWidth():Number{return 0;}
|
||||
|
||||
/**
|
||||
* @private
|
||||
**/
|
||||
public function get measuredHeight():Number{return 0;}
|
||||
|
||||
/**
|
||||
* @private
|
||||
**/
|
||||
public function get target():DisplayObjectContainer{return null;}
|
||||
public function set target(value:DisplayObjectContainer):void{}
|
||||
|
||||
|
||||
|
||||
//event related stuff
|
||||
|
||||
private var _enableEvents:Boolean=true;
|
||||
/**
|
||||
* Enable events for this object.
|
||||
**/
|
||||
public function get enableEvents():Boolean{
|
||||
return _enableEvents;
|
||||
}
|
||||
public function set enableEvents(value:Boolean):void{
|
||||
_enableEvents=value;
|
||||
}
|
||||
|
||||
private var _surpressEventProcessing:Boolean=false;
|
||||
/**
|
||||
* Temporarily suppress event processing for this object.
|
||||
**/
|
||||
public function get surpressEventProcessing():Boolean{
|
||||
return _surpressEventProcessing;
|
||||
}
|
||||
public function set surpressEventProcessing(value:Boolean):void{
|
||||
|
||||
if(_surpressEventProcessing==true && value==false){
|
||||
_surpressEventProcessing=value;
|
||||
initChange("surpressEventProcessing",false,true,this);
|
||||
}
|
||||
else{
|
||||
_surpressEventProcessing=value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event into the event flow.
|
||||
*
|
||||
* @see EventDispatcher
|
||||
**/
|
||||
override public function dispatchEvent(event:Event):Boolean{
|
||||
if(_surpressEventProcessing){return false;}
|
||||
|
||||
return(super.dispatchEvent(event));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an property change event into the event flow.
|
||||
**/
|
||||
public function dispatchPropertyChange(bubbles:Boolean = false,
|
||||
property:Object = null, oldValue:Object = null,
|
||||
newValue:Object = null, source:Object = null):Boolean{
|
||||
return dispatchEvent(new PropertyChangeEvent("propertyChange",bubbles,false,PropertyChangeEventKind.UPDATE,property,oldValue,newValue,source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for dispatching property changes
|
||||
**/
|
||||
public function initChange(property:String,oldValue:Object,newValue:Object,source:Object):void{
|
||||
if(hasEventManager){
|
||||
dispatchPropertyChange(false,property,oldValue,newValue,source);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to see if a EventDispatcher instance has been created for this object.
|
||||
**/
|
||||
public function get hasEventManager():Boolean{
|
||||
return true;
|
||||
}
|
||||
|
||||
//specific identity code
|
||||
|
||||
private var _id:String;
|
||||
/**
|
||||
* The identifier used by document to refer to this object.
|
||||
**/
|
||||
public function get id():String{
|
||||
|
||||
if(_id){
|
||||
return _id;
|
||||
}
|
||||
else{
|
||||
_id =NameUtil.createUniqueName(this);
|
||||
name=_id;
|
||||
return _id;
|
||||
}
|
||||
}
|
||||
public function set id(value:String):void{
|
||||
_id = value;
|
||||
name=_id;
|
||||
}
|
||||
|
||||
private var _document:Object;
|
||||
/**
|
||||
* The MXML document that created this object.
|
||||
**/
|
||||
public function get document():Object{
|
||||
return _document;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after the implementing object has been created and all component properties specified on the MXML tag have been initialized.
|
||||
*
|
||||
* @param document The MXML document that created this object.
|
||||
* @param id The identifier used by document to refer to this object.
|
||||
**/
|
||||
public function initialized(document:Object, id:String):void {
|
||||
|
||||
//if the id has not been set (through as perhaps)
|
||||
if(!_id){
|
||||
if(id){
|
||||
_id = id;
|
||||
}
|
||||
else{
|
||||
//if no id specified create one
|
||||
_id = NameUtil.createUniqueName(this);
|
||||
}
|
||||
}
|
||||
|
||||
//sprit has a name property and it is set
|
||||
//to the instance value. Make sure it is the
|
||||
//same as the id
|
||||
name=_id;
|
||||
|
||||
_document=document;
|
||||
|
||||
if(enableEvents && !surpressEventProcessing){
|
||||
dispatchEvent(new FlexEvent(FlexEvent.INITIALIZE));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
44
src/com/degrafa/IGeometry.as
Normal file
44
src/com/degrafa/IGeometry.as
Normal file
@ -0,0 +1,44 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
|
||||
import com.degrafa.core.IGraphicsStroke;
|
||||
import com.degrafa.core.IGraphicsFill;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.Graphics;
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
/**
|
||||
* Base interface for all Degrafa geometry objects.
|
||||
**/
|
||||
public interface IGeometry{
|
||||
function draw(graphics:Graphics,rc:Rectangle):void
|
||||
function endDraw(graphics:Graphics):void
|
||||
function get stroke():IGraphicsStroke
|
||||
function set stroke(value:IGraphicsStroke):void
|
||||
function get fill():IGraphicsFill
|
||||
function set fill(value:IGraphicsFill):void
|
||||
function get data():String
|
||||
function set data(value:String):void
|
||||
}
|
||||
}
|
86
src/com/degrafa/IGraphic.as
Normal file
86
src/com/degrafa/IGraphic.as
Normal file
@ -0,0 +1,86 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
|
||||
import com.degrafa.core.IGraphicsFill;
|
||||
import com.degrafa.core.IGraphicsStroke;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.geom.Rectangle;
|
||||
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.display.Graphics;
|
||||
|
||||
/**
|
||||
* Base interface for Degrafa Graphic objects.
|
||||
**/
|
||||
public interface IGraphic{
|
||||
|
||||
function get width():Number
|
||||
function set width(value:Number):void
|
||||
|
||||
function get height():Number
|
||||
function set height(value:Number):void
|
||||
|
||||
function get x():Number
|
||||
function set x(value:Number):void
|
||||
|
||||
function get y():Number
|
||||
function set y(value:Number):void
|
||||
|
||||
function get name():String
|
||||
function set name(value:String):void
|
||||
|
||||
function addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
|
||||
function removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
|
||||
|
||||
function get fills():Array
|
||||
function set fills(value:Array):void
|
||||
|
||||
function get strokes():Array
|
||||
function set strokes(value:Array):void
|
||||
|
||||
function set percentHeight(value:Number):void
|
||||
function get percentHeight():Number
|
||||
|
||||
function set percentWidth(value:Number):void
|
||||
function get percentWidth():Number
|
||||
|
||||
function get measuredWidth():Number
|
||||
function get measuredHeight():Number
|
||||
|
||||
function get parent():DisplayObjectContainer
|
||||
|
||||
function draw(graphics:Graphics,rc:Rectangle):void
|
||||
function endDraw(graphics:Graphics):void
|
||||
|
||||
function set target(value:DisplayObjectContainer):void
|
||||
function get target():DisplayObjectContainer
|
||||
|
||||
function get stroke():IGraphicsStroke
|
||||
function set stroke(value:IGraphicsStroke):void
|
||||
|
||||
function get fill():IGraphicsFill
|
||||
function set fill(value:IGraphicsFill):void
|
||||
|
||||
}
|
||||
}
|
34
src/com/degrafa/IGraphicPoint.as
Normal file
34
src/com/degrafa/IGraphicPoint.as
Normal file
@ -0,0 +1,34 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
|
||||
//NOTE: though this has no details it is required to limit
|
||||
//the types of points.
|
||||
|
||||
/**
|
||||
* Base interface for Degrafa point objects.
|
||||
**/
|
||||
public interface IGraphicPoint{
|
||||
|
||||
}
|
||||
}
|
239
src/com/degrafa/Surface.as
Normal file
239
src/com/degrafa/Surface.as
Normal file
@ -0,0 +1,239 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (c) 2008 Jason Hawryluk, Juan Sanchez, Andy McIntosh, Ben Stucki
|
||||
// and Pavan Podila.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
// THE SOFTWARE.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
package com.degrafa{
|
||||
|
||||
import com.degrafa.core.collections.FillCollection;
|
||||
import com.degrafa.core.collections.GraphicsCollection;
|
||||
import com.degrafa.core.collections.StrokeCollection;
|
||||
|
||||
import flash.display.DisplayObject;
|
||||
import flash.events.Event;
|
||||
|
||||
import mx.core.UIComponent;
|
||||
import mx.events.PropertyChangeEvent;
|
||||
import mx.events.PropertyChangeEventKind;
|
||||
|
||||
[DefaultProperty("graphicsData")]
|
||||
[Bindable(event="propertyChange")]
|
||||
|
||||
/**
|
||||
* Surface is a simple UIComponent extension that allows Degrafa objects
|
||||
* to be added to it's display list. Fills and strokes set here have no
|
||||
* effect and only serve organizational purposes.
|
||||
**/
|
||||
public class Surface extends UIComponent{
|
||||
|
||||
public function Surface(){
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
private var _graphicsData:GraphicsCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.IGraphic")]
|
||||
[ArrayElementType("com.degrafa.IGraphic")]
|
||||
/**
|
||||
* A array of IGraphic objects. Objects of type GraphicText, GraphicImage
|
||||
* and GeometryGroup are accepted and to this objects display list.
|
||||
**/
|
||||
public function get graphicsData():Array{
|
||||
if(!_graphicsData){_graphicsData = new GraphicsCollection();}
|
||||
return _graphicsData.items;
|
||||
}
|
||||
public function set graphicsData(value:Array):void{
|
||||
|
||||
if(!_graphicsData){_graphicsData = new GraphicsCollection();}
|
||||
|
||||
_graphicsData.items = value;
|
||||
|
||||
|
||||
for each(var item:IGraphic in _graphicsData.items){
|
||||
|
||||
addChild(DisplayObject(item));
|
||||
|
||||
if (item.target==null){
|
||||
item.target=this;
|
||||
}
|
||||
}
|
||||
|
||||
if(_graphicsData && enableEvents){
|
||||
_graphicsData.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa graphics collection object for this graphic object.
|
||||
**/
|
||||
public function get graphicsCollection():GraphicsCollection{
|
||||
if(!_graphicsData){_graphicsData = new GraphicsCollection();}
|
||||
return _graphicsData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Principle event handler for any property changes to a
|
||||
* graphic object or it's child objects.
|
||||
**/
|
||||
private function propertyChangeHandler(event:PropertyChangeEvent):void{
|
||||
dispatchEvent(event);
|
||||
}
|
||||
|
||||
private var _fills:FillCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.core.IGraphicsFill")]
|
||||
[ArrayElementType("com.degrafa.core.IGraphicsFill")]
|
||||
/**
|
||||
* A array of IGraphicsFill objects.
|
||||
**/
|
||||
public function get fills():Array{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
return _fills.items;
|
||||
|
||||
}
|
||||
public function set fills(value:Array):void{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
_fills.items = value;
|
||||
|
||||
//add a listener to the collection
|
||||
if(_fills && enableEvents){
|
||||
_fills.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa fill collection object for this graphic object.
|
||||
**/
|
||||
public function get fillCollection():FillCollection{
|
||||
if(!_fills){_fills = new FillCollection();}
|
||||
return _fills;
|
||||
}
|
||||
|
||||
private var _strokes:StrokeCollection;
|
||||
[Inspectable(category="General", arrayType="com.degrafa.core.IGraphicsStroke")]
|
||||
[ArrayElementType("com.degrafa.core.IGraphicsStroke")]
|
||||
/**
|
||||
* A array of IStroke objects.
|
||||
**/
|
||||
public function get strokes():Array{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
return _strokes.items;
|
||||
|
||||
}
|
||||
public function set strokes(value:Array):void{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
_strokes.items = value;
|
||||
|
||||
//add a listener to the collection
|
||||
if(_strokes && enableEvents){
|
||||
_strokes.addEventListener(PropertyChangeEvent.PROPERTY_CHANGE,propertyChangeHandler);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access to the Degrafa stroke collection object for this graphic object.
|
||||
**/
|
||||
public function get strokeCollection():StrokeCollection{
|
||||
if(!_strokes){_strokes = new StrokeCollection();}
|
||||
|
||||
return _strokes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draws the object and/or sizes and positions its children.
|
||||
**/
|
||||
protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void{
|
||||
super.updateDisplayList(unscaledWidth, unscaledHeight);
|
||||
|
||||
setActualSize(getExplicitOrMeasuredWidth(), getExplicitOrMeasuredHeight());
|
||||
}
|
||||
|
||||
//event related stuff
|
||||
private var _enableEvents:Boolean=true;
|
||||
/**
|
||||
* Enable events for this object.
|
||||
**/
|
||||
public function get enableEvents():Boolean{
|
||||
return _enableEvents;
|
||||
}
|
||||
public function set enableEvents(value:Boolean):void{
|
||||
_enableEvents=value;
|
||||
}
|
||||
|
||||
private var _surpressEventProcessing:Boolean=false;
|
||||
/**
|
||||
* Temporarily suppress event processing for this object.
|
||||
**/
|
||||
public function get surpressEventProcessing():Boolean{
|
||||
return _surpressEventProcessing;
|
||||
}
|
||||
public function set surpressEventProcessing(value:Boolean):void{
|
||||
|
||||
if(_surpressEventProcessing==true && value==false){
|
||||
_surpressEventProcessing=value;
|
||||
initChange("surpressEventProcessing",false,true,this);
|
||||
}
|
||||
else{
|
||||
_surpressEventProcessing=value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an event into the event flow.
|
||||
*
|
||||
* @see EventDispatcher
|
||||
**/
|
||||
override public function dispatchEvent(event:Event):Boolean{
|
||||
if(_surpressEventProcessing){return false;}
|
||||
|
||||
return(super.dispatchEvent(event));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Dispatches an property change event into the event flow.
|
||||
**/
|
||||
public function dispatchPropertyChange(bubbles:Boolean = false,
|
||||
property:Object = null, oldValue:Object = null,
|
||||
newValue:Object = null, source:Object = null):Boolean{
|
||||
return dispatchEvent(new PropertyChangeEvent("propertyChange",bubbles,false,PropertyChangeEventKind.UPDATE,property,oldValue,newValue,source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for dispatching property changes
|
||||
**/
|
||||
public function initChange(property:String,oldValue:Object,newValue:Object,source:Object):void{
|
||||
if(hasEventManager){
|
||||
dispatchPropertyChange(false,property,oldValue,newValue,source);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests to see if a EventDispatcher instance has been created for this object.
|
||||
**/
|
||||
public function get hasEventManager():Boolean{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user