├── deploy ├── js │ ├── .DS_Store │ └── swfobject.js ├── swf │ ├── slider.swf │ ├── collection.swf │ ├── flashvars.swf │ ├── bitmaputils.swf │ ├── pulloutmenu.swf │ ├── soundmanager.swf │ ├── textmanager.swf │ ├── expressInstall.swf │ └── mousepositionpanel.swf ├── sounds │ ├── birds.mp3 │ ├── frogs.mp3 │ └── elephant.mp3 ├── css │ ├── styles.css │ └── english-styles.css └── index.html ├── source ├── fla │ ├── slider │ │ └── slider.fla │ ├── flashvars │ │ └── flashvars.fla │ ├── collection │ │ └── collection.fla │ ├── bitmaputils │ │ └── bitmaputils.fla │ ├── pulloutmenu │ │ └── pulloutmenu.fla │ ├── soundmanager │ │ └── soundmanager.fla │ ├── textmanager │ │ └── textmanager.fla │ └── mousepositionpanel │ │ └── mousepositionpanel.fla ├── libs │ └── com │ │ └── reintroducing │ │ ├── data │ │ ├── base │ │ │ ├── IValueObject.as │ │ │ ├── ICollection.as │ │ │ ├── ValueObject.as │ │ │ ├── Iterator.as │ │ │ └── Collection.as │ │ ├── text │ │ │ ├── config │ │ │ │ ├── ITextConfig.as │ │ │ │ ├── StaticTextConfig.as │ │ │ │ ├── InputTextConfig.as │ │ │ │ └── HTMLTextConfig.as │ │ │ ├── TextManagerConstants.as │ │ │ └── lang │ │ │ │ ├── Language.as │ │ │ │ └── Languages.as │ │ ├── flashvars │ │ │ ├── FlashVar.as │ │ │ └── FlashVars.as │ │ ├── utils │ │ │ └── ExternalInterfaceMethod.as │ │ ├── slider │ │ │ └── SliderData.as │ │ ├── mousepositionpanel │ │ │ └── MousePositionPanelData.as │ │ ├── pulloutmenu │ │ │ └── PullOutMenuData.as │ │ └── link │ │ │ └── LinkData.as │ │ ├── utils │ │ ├── GarbageCollection.as │ │ ├── FontUtils.as │ │ ├── CacheUtils.as │ │ ├── SoundUtils.as │ │ ├── LibraryUtils.as │ │ ├── ObjectUtils.as │ │ ├── BitmapUtils.as │ │ ├── LayoutUtils.as │ │ ├── SharedObjectManager.as │ │ ├── DateUtils.as │ │ ├── ArrayUtils.as │ │ ├── DisplayObjectUtils.as │ │ ├── LinkUtils.as │ │ ├── ExternalInterfaceManager.as │ │ ├── ColorUtils.as │ │ ├── StringUtils.as │ │ ├── FlashVarsManager.as │ │ ├── Validator.as │ │ └── MathUtils.as │ │ ├── events │ │ ├── MouseIdleMonitorEvent.as │ │ ├── SliderEvent.as │ │ └── SoundManagerEvent.as │ │ ├── text │ │ ├── types │ │ │ ├── HTMLTextField.as │ │ │ ├── StaticTextField.as │ │ │ └── InputTextField.as │ │ └── TextManager.as │ │ ├── debug │ │ └── Environment.as │ │ ├── ui │ │ ├── mousepositionpanel │ │ │ └── MousePositionPanel.as │ │ ├── pulloutmenu │ │ │ └── PullOutMenu.as │ │ └── slider │ │ │ └── Slider.as │ │ ├── mouse │ │ └── MouseIdleMonitor.as │ │ └── sound │ │ └── SoundItem.as └── src │ ├── collection │ ├── TestVO.as │ └── MainCollection.as │ ├── flashvars │ └── MainFlashVarsManager.as │ ├── bitmaputils │ └── MainBitmapUtils.as │ ├── slider │ └── MainSlider.as │ ├── mousepositionpanel │ └── MainMousePositionPanel.as │ ├── pulloutmenu │ └── MainPullOutMenu.as │ ├── textmanager │ └── MainTextManager.as │ └── soundmanager │ └── MainSoundManager.as └── README.txt /deploy/js/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/js/.DS_Store -------------------------------------------------------------------------------- /deploy/swf/slider.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/slider.swf -------------------------------------------------------------------------------- /deploy/sounds/birds.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/sounds/birds.mp3 -------------------------------------------------------------------------------- /deploy/sounds/frogs.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/sounds/frogs.mp3 -------------------------------------------------------------------------------- /deploy/swf/collection.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/collection.swf -------------------------------------------------------------------------------- /deploy/swf/flashvars.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/flashvars.swf -------------------------------------------------------------------------------- /deploy/sounds/elephant.mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/sounds/elephant.mp3 -------------------------------------------------------------------------------- /deploy/swf/bitmaputils.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/bitmaputils.swf -------------------------------------------------------------------------------- /deploy/swf/pulloutmenu.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/pulloutmenu.swf -------------------------------------------------------------------------------- /deploy/swf/soundmanager.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/soundmanager.swf -------------------------------------------------------------------------------- /deploy/swf/textmanager.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/textmanager.swf -------------------------------------------------------------------------------- /deploy/swf/expressInstall.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/expressInstall.swf -------------------------------------------------------------------------------- /source/fla/slider/slider.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/slider/slider.fla -------------------------------------------------------------------------------- /deploy/swf/mousepositionpanel.swf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/deploy/swf/mousepositionpanel.swf -------------------------------------------------------------------------------- /source/fla/flashvars/flashvars.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/flashvars/flashvars.fla -------------------------------------------------------------------------------- /source/fla/collection/collection.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/collection/collection.fla -------------------------------------------------------------------------------- /source/fla/bitmaputils/bitmaputils.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/bitmaputils/bitmaputils.fla -------------------------------------------------------------------------------- /source/fla/pulloutmenu/pulloutmenu.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/pulloutmenu/pulloutmenu.fla -------------------------------------------------------------------------------- /source/fla/soundmanager/soundmanager.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/soundmanager/soundmanager.fla -------------------------------------------------------------------------------- /source/fla/textmanager/textmanager.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/textmanager/textmanager.fla -------------------------------------------------------------------------------- /source/fla/mousepositionpanel/mousepositionpanel.fla: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/reintroducing/as3/HEAD/source/fla/mousepositionpanel/mousepositionpanel.fla -------------------------------------------------------------------------------- /deploy/css/styles.css: -------------------------------------------------------------------------------- 1 | html, body, #containerA, #containerB 2 | { 3 | height: 100%; 4 | } 5 | 6 | body 7 | { 8 | margin: 0; 9 | padding: 0; 10 | overflow: hidden; 11 | backgroundcolor: #FCF1DC; 12 | } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/data/base/IValueObject.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.data.base { /** * Interface for ValueObject. * * @author Matt Przybylski [http://www.reintroducing.com] * @version 1.0 */ public interface IValueObject { function output():void; //- END INTERFACE ----------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/data/text/config/ITextConfig.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.data.text.config { /** * Interface for TextConfig value objects. * * @author Matt Przybylski [http://www.reintroducing.com] * @version 1.0 */ public interface ITextConfig { function output():void; //- END INTERFACE ----------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/data/text/TextManagerConstants.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.data.text { /** * Constants used in the TextManager. * * @author Matt Przybylski [http://www.reintroducing.com] * @version 1.0 */ public class TextManagerConstants { public static const TYPE_STATIC:String = "text.type.static"; public static const TYPE_HTML:String = "text.type.html"; public static const TYPE_INPUT:String = "text.type.input"; } } -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | This library contains a portion of my AS3 classes that I use almost every day. 2 | 3 | Feel free to do whatever you want with them. If you find any bugs, please let me know. 4 | 5 | Dependent on: 6 | - Greensock Tweening Platform [http://www.greensock.com] 7 | - Greensock LoaderMax [http://www.loadermax.com] 8 | 9 | source/fla - contains the FLAs to go with the examples 10 | source/libs - contains the core class files 11 | source/src - contains the example code for the FLAs -------------------------------------------------------------------------------- /source/libs/com/reintroducing/data/base/ICollection.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.data.base { /** * Interface for Collection. * * @author Matt Przybylski [http://www.reintroducing.com] * @version 1.0 */ public interface ICollection { function getName():String; function addItem($item:*):Boolean; function addItems(...$items):void; function addItemAt($index:int, $item:*):void; function removeItem($item:*):Boolean; function clear():void; function contains($item:*):Boolean; function getItemAt($index:int):*; function getIterator():Iterator; function getLength():int; function isEmpty():Boolean; function output():void; //- END INTERFACE ----------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /deploy/css/english-styles.css: -------------------------------------------------------------------------------- 1 | /* ----------------------------------- 2 | COMMON 3 | ----------------------------------- */ 4 | 5 | .header { 6 | font-family: Trade Gothic Bold Condensed No. 20; 7 | font-size: 20pt; 8 | color: #000000; 9 | } 10 | 11 | .bodyCopy { 12 | font-family: Trade Gothic; 13 | font-size: 12pt; 14 | color: #666666; 15 | } 16 | 17 | .footer { 18 | font-family: Trade Gothic Light; 19 | font-size: 10pt; 20 | color: #000000; 21 | } 22 | 23 | .htmlTest1 { 24 | font-family: Trade Gothic; 25 | font-size: 14pt; 26 | color: #FF0000; 27 | } 28 | 29 | .htmlTest2 { 30 | font-family: Trade Gothic; 31 | font-size: 14pt; 32 | color: #00FF00; 33 | } 34 | 35 | .inputTest { 36 | font-family: Trade Gothic; 37 | font-size: 12pt; 38 | color: #888888; 39 | } -------------------------------------------------------------------------------- /deploy/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
* // an image exists in the FLA's library with a linkage class name of "Roses"
* var roses:BitmapData = LibraryUtils.createClassFromObject("Roses") as BitmapData;
*
*
* @return * The new (castable) class
*/
public static function createClassFromObject($libraryLinkage:String):*
{
var ref:Class = getDefinitionByName($libraryLinkage) as Class;
var obj:* = new ref();
return obj;
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/data/pulloutmenu/PullOutMenuData.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.data.pulloutmenu
{
import com.greensock.easing.Linear;
import com.reintroducing.data.base.ValueObject;
import flash.display.Sprite;
import flash.utils.getQualifiedClassName;
/**
* Strongly typed data object for use with the PullOutMenu.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class PullOutMenuData extends ValueObject
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public static const AXIS_X:String = "x";
public static const AXIS_Y:String = "y";
public static const TYPE_ROLL_OVER:String = "rollover";
public static const TYPE_PRESS:String = "press";
public static const TYPE_RELEASE:String = "release";
public var hitButton:Sprite;
public var itemHolder:Sprite;
public var startPosition:Number;
public var endPosition:Number;
public var openSpeed:Number = .25;
public var closeSpeed:Number = .25;
public var axis:String = AXIS_Y;
public var tweenEase:Function = Linear.easeOut;
public var eventType:String = TYPE_ROLL_OVER;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function PullOutMenuData()
{
super();
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
override public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/src/bitmaputils/MainBitmapUtils.as:
--------------------------------------------------------------------------------
1 | package bitmaputils
{
import com.reintroducing.utils.BitmapUtils;
import com.reintroducing.utils.LibraryUtils;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.utils.getQualifiedClassName;
/**
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class MainBitmapUtils extends MovieClip
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public var bmp:Bitmap;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function MainBitmapUtils():void
{
super();
init();
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
/**
*
*/
private function init():void
{
// var rosesRef:Class = getDefinitionByName("Roses") as Class;
// var roses:BitmapData = new rosesRef();
var roses:BitmapData = LibraryUtils.createClassFromObject("Roses") as BitmapData;
bmp = new Bitmap(roses);
var tiles:Array = BitmapUtils.createTiles(bmp, 3, 3);
var tile:Bitmap;
for (var i:int = 0; i < tiles.length; i++)
{
for (var j:int = 0; j < tiles[i].length; j++)
{
tile = tiles[i][j];
tile.x = ((j * tile.width) + (j * 10));
tile.y = ((i * tile.height) + (i * 10));
addChild(tile);
}
}
}
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
override public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/data/base/Iterator.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.data.base
{
import flash.utils.getQualifiedClassName;
/**
* Works in conjunction with a Collection to iterate through its contents.
*
* @author Adobe [http://www.adobe.com]
* @author Ported to AS3 by Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class Iterator
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
protected var _collection:Collection;
protected var _cursor:int;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
/**
* Initializes the Iterator and maintain a link to its Collection.
*
* @param $coll Collection to which this Iterator belongs.
*/
public function Iterator($coll:Collection)
{
_collection = $coll;
_cursor = 0;
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Returns true if the iteration has more items.
*
* @return Boolean true if iteration has more items.
*/
public function hasNext():Boolean
{
return (_cursor < _collection.getLength());
}
/**
* Return the next item in the iteration and increment the cursor. Returns null if the
* iteration has no more items.
*
* @return * the next item in the Iteration.
*/
public function next():*
{
return (_collection.getItemAt(_cursor++));
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/data/text/config/HTMLTextConfig.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.data.text.config
2 | {
3 | import com.reintroducing.data.base.ValueObject;
4 |
5 | import flash.text.AntiAliasType;
6 | import flash.text.TextFieldAutoSize;
7 | import flash.utils.getQualifiedClassName;
8 |
9 | /**
10 | * Strongly typed value object for HTMLTextField usage in the TextManager.
11 | *
12 | * @author Matt Przybylski [http://www.reintroducing.com]
13 | * @version 1.0
14 | */
15 | public class HTMLTextConfig extends ValueObject implements ITextConfig
16 | {
17 | //- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
18 |
19 |
20 |
21 | //- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
22 |
23 | public var antiAliasType:String = AntiAliasType.ADVANCED;
24 | public var autoSize:String = TextFieldAutoSize.LEFT;
25 | public var selectable:Boolean = false;
26 | public var wordWrap:Boolean = true;
27 | public var multiline:Boolean = true;
28 | public var width:Number = 100;
29 | public var height:Number = 100;
30 |
31 | //- CONSTRUCTOR -------------------------------------------------------------------------------------------
32 |
33 | public function HTMLTextConfig()
34 | {
35 | super();
36 | }
37 |
38 | //- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
39 |
40 |
41 |
42 | //- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
43 |
44 |
45 |
46 | //- EVENT HANDLERS ----------------------------------------------------------------------------------------
47 |
48 |
49 |
50 | //- GETTERS & SETTERS -------------------------------------------------------------------------------------
51 |
52 |
53 |
54 | //- HELPERS -----------------------------------------------------------------------------------------------
55 |
56 | /**
57 | * @private
58 | */
59 | override public function toString():String
60 | {
61 | return getQualifiedClassName(this);
62 | }
63 |
64 | //- END CLASS ---------------------------------------------------------------------------------------------
65 | }
66 | }
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/data/link/LinkData.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.data.link
{
import com.reintroducing.data.base.ValueObject;
import flash.utils.getQualifiedClassName;
/**
* Strongly typed data object for use with the LinkUtils.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class LinkData extends ValueObject
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public static const WINDOW_POPUP:String = "window.popup";
public static const WINDOW_NEW:String = "_blank";
public static const WINDOW_SELF:String = "_self";
public static const WINDOW_PARENT:String = "_parent";
public var sourceURL:String = "";
public var targetWindow:String = WINDOW_SELF;
public var windowName:String = "new.popup.window";
public var windowWidth:Number = 600;
public var windowHeight:Number = 500;
public var windowX:Number = 100;
public var windowY:Number = 100;
public var copyHistory:Boolean = false;
public var statusBar:Boolean = true;
public var toolBar:Boolean = true;
public var location:Boolean = true;
public var menuBar:Boolean = true;
public var directories:Boolean = true;
public var resizable:Boolean = true;
public var scrollBars:Boolean = true;
public var fullScreen:Boolean = false;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function LinkData()
{
super();
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
override public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/utils/ObjectUtils.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.utils
{
import flash.utils.describeType;
import flash.utils.getQualifiedClassName;
/**
* Static utility methods for working with Objects.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class ObjectUtils
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function ObjectUtils()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Traces out all properties in a given object.
*
* @param $o The object to inspect
*
* @return void
*/
public static function trace($o:Object):void
{
trace("\n");
trace("OBJECT TRACE:");
for (var val:* in $o)
{
trace(" [" + typeof($o[val]) + "] " + val + " => " + $o[val]);
}
trace("\n");
}
/**
2 | * Traces out all the properties as provided by describeType.
*
* @param $o The object to trace
* @param $type The type of properties the object has. "variable" traces out public, "accessor" traces out bindable/getter & setters.
*
* @return void
3 | */
4 | public static function describe($o:*, $type:String = "variable"):void
5 | {
6 | var props:XMLList = ($type == "variable") ? describeType($o)..variable : describeType($o)..accessor;
for (var i:int = 0; i < props.length(); i++)
{
trace(props[i].@name + ': ' + $o[props[i].@name]);
}
7 | }
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/events/SliderEvent.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.events
{
import flash.display.DisplayObject;
import flash.events.Event;
/**
* Event dispatched by the Slider.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class SliderEvent extends Event
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
// event constants
public static const ON_UPDATE:String = "onUpdate";
public static const ON_PRESS:String = "onPress";
public static const ON_RELEASE:String = "onRelease";
public static const ON_ENABLED:String = "onEnabled";
public static const ON_DISABLED:String = "onDisabled";
// parameters
public var percent:Number;
public var currentValue:Number;
public var slider:DisplayObject;
public var track:DisplayObject;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function SliderEvent($type:String, $percent:Number, $currentValue:Number, $slider:DisplayObject, $track:DisplayObject, $bubbles:Boolean = false, $cancelable:Boolean = false)
{
super($type, $bubbles, $cancelable);
percent = $percent;
currentValue = $currentValue;
slider = $slider;
track = $track;
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public override function clone():Event
{
return new SliderEvent(type, percent, currentValue, slider, track, bubbles, cancelable);
}
/**
* @private
*/
public override function toString():String
{
return formatToString("SliderUIEvent", "percent", "currentValue", "slider", "track", "type", "bubbles", "cancelable");
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/text/types/HTMLTextField.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.text.types
{
import com.reintroducing.data.text.config.ITextConfig;
2 | import com.reintroducing.data.text.config.HTMLTextConfig;
import com.reintroducing.data.text.lang.Language;
import flash.text.TextField;
import flash.utils.getQualifiedClassName;
/**
* Utility class used to create an HTML TextField in the TextManager.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class HTMLTextField
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function HTMLTextField()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Creates the TextField.
*
* @param $language The Language to use from the TextManager
* @param $config The text configuration to use
* @param $content The text which will populate the TextField
*
* @return TextField
*/
public static function create($language:Language, $config:ITextConfig, $content:String):TextField
{
var config:HTMLTextConfig = ($config as HTMLTextConfig);
var tf:TextField = new TextField();
tf.styleSheet = $language.styleSheet;
tf.antiAliasType = config.antiAliasType;
tf.embedFonts = $language.embed;
tf.autoSize = config.autoSize;
tf.selectable = config.selectable;
tf.wordWrap = config.wordWrap;
tf.multiline = config.multiline;
tf.width = config.width;
tf.height = config.height;
tf.htmlText = $content;
return tf;
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/src/slider/MainSlider.as:
--------------------------------------------------------------------------------
1 | package slider
{
import com.reintroducing.data.slider.SliderData;
2 | import com.reintroducing.events.SliderEvent;
import com.reintroducing.ui.slider.Slider;
import flash.display.MovieClip;
import flash.utils.getQualifiedClassName;
/**
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class MainSlider extends MovieClip
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
private var _slider:Slider;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public var sliderBtn:MovieClip;
public var track:MovieClip;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function MainSlider():void
{
super();
init();
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
/**
*
*/
private function init():void
{
var sd:SliderData = new SliderData();
sd.stage = stage;
sd.axis = SliderData.AXIS_X;
sd.track = track;
sd.slider = sliderBtn;
sd.lowValue = 100;
sd.highValue = 0;
sd.startValue = 10;
sd.precision = 0;
_slider = new Slider(sd);
_slider.addEventListener(SliderEvent.ON_PRESS, onSliderPress, false, 0, true);
_slider.addEventListener(SliderEvent.ON_RELEASE, onSliderRelease, false, 0, true);
_slider.addEventListener(SliderEvent.ON_UPDATE, onSliderUpdate, false, 0, true);
}
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
/**
*
*/
private function onSliderPress($evt:SliderEvent):void
{
trace("slider pressed");
}
/**
*
*/
private function onSliderRelease($evt:SliderEvent):void
{
trace("slider released");
}
/**
*
*/
private function onSliderUpdate($evt:SliderEvent):void
{
trace("CURRENT VALUE: " + $evt.currentValue);
trace("CURRENT PERCENT: " + $evt.percent);
}
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
override public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/src/mousepositionpanel/MainMousePositionPanel.as:
--------------------------------------------------------------------------------
1 | package mousepositionpanel
{
import flash.events.MouseEvent;
2 | import com.reintroducing.ui.mousepositionpanel.MousePositionPanel;
3 | import com.reintroducing.data.mousepositionpanel.MousePositionPanelData;
import flash.display.MovieClip;
import flash.utils.getQualifiedClassName;
/**
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class MainMousePositionPanel extends MovieClip
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
private var _mpp:MousePositionPanel;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public var holder:MovieClip;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function MainMousePositionPanel()
{
super();
init();
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
/**
*
*/
private function init():void
{
var mppData:MousePositionPanelData = new MousePositionPanelData();
mppData.itemHolder = holder;
mppData.content = holder.content;
mppData.masker = holder.masker;
mppData.axis = MousePositionPanelData.AXIS_X;
mppData.moveType = MousePositionPanelData.TYPE_AGAINST_MOUSE;
mppData.speed = 10;
_mpp = new MousePositionPanel(mppData);
holder.addEventListener(MouseEvent.ROLL_OVER, handleStartPanel, false, 0, true);
holder.addEventListener(MouseEvent.ROLL_OUT, handleStopPanel, false, 0, true);
}
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
/**
*
*/
private function handleStartPanel($evt:MouseEvent):void
{
trace("MainMousePositionPanel.handleStartPanel(",[$evt],")");
_mpp.startPanel();
}
/**
*
*/
private function handleStopPanel($evt:MouseEvent):void
{
trace("MainMousePositionPanel.handleStopPanel(",[$evt],")");
_mpp.stopPanel();
}
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
override public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/text/types/StaticTextField.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.text.types
{
import com.reintroducing.data.text.config.ITextConfig;
2 | import com.reintroducing.data.text.config.StaticTextConfig;
import com.reintroducing.data.text.lang.Language;
import flash.text.TextField;
import flash.utils.getQualifiedClassName;
/**
* Utility class used to create a Static TextField in the TextManager.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class StaticTextField
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function StaticTextField()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Creates the TextField.
*
* @param $language The Language to use from the TextManager
* @param $config The text configuration to use
* @param $style The name of the CSS style to use to style the TextField
* @param $content The text which will populate the TextField
*
* @return TextField
*/
public static function create($language:Language, $config:ITextConfig, $style:String, $content:String):TextField
{
var config:StaticTextConfig = ($config as StaticTextConfig);
var styleObj:Object = $language.styleSheet.getStyle(String("." + $style));
var tf:TextField = new TextField();
tf.defaultTextFormat = $language.styleSheet.transform(styleObj);
tf.antiAliasType = config.antiAliasType;
tf.embedFonts = $language.embed;
tf.autoSize = config.autoSize;
tf.selectable = config.selectable;
tf.wordWrap = config.wordWrap;
tf.multiline = config.multiline;
tf.width = config.width;
tf.height = config.height;
tf.text = $content;
return tf;
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/text/types/InputTextField.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.text.types
{
import com.reintroducing.data.text.config.ITextConfig;
2 | import com.reintroducing.data.text.config.InputTextConfig;
import com.reintroducing.data.text.lang.Language;
import flash.text.TextField;
import flash.utils.getQualifiedClassName;
/**
* Utility class used to create an Input TextField in the TextManager.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class InputTextField
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function InputTextField()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Creates the TextField.
*
* @param $language The Language to use from the TextManager
* @param $config The text configuration to use
* @param $style The name of the CSS style to use to style the TextField
* @param $content The text which will populate the TextField
*
* @return TextField
*/
public static function create($language:Language, $config:ITextConfig, $style:String, $content:String):TextField
{
var config:InputTextConfig = ($config as InputTextConfig);
var styleObj:Object = $language.styleSheet.getStyle(String("." + $style));
var tf:TextField = new TextField();
tf.type = config.type;
tf.defaultTextFormat = $language.styleSheet.transform(styleObj);
tf.antiAliasType = config.antiAliasType;
tf.embedFonts = $language.embed;
tf.autoSize = config.autoSize;
tf.wordWrap = config.wordWrap;
tf.multiline = config.multiline;
tf.width = config.width;
tf.height = config.height;
tf.mouseEnabled = config.mouseEnabled;
tf.background = config.background;
tf.backgroundColor = config.backgroundColor;
tf.text = $content;
return tf;
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/utils/BitmapUtils.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.utils
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.geom.Point;
import flash.geom.Rectangle;
import flash.utils.getQualifiedClassName;
/**
* Static utility methods used to manipulate bitmaps.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class BitmapUtils
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function BitmapUtils()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Creates a new bitmap which is a clone of the original.
*
* @param $bmp The bitmap to be cloned
*
* @return Bitmap
*/
public static function getClone($bmp:Bitmap):Bitmap
{
return new Bitmap($bmp.bitmapData.clone());
}
/**
* Clears the BitmapData's contents.
*
* @param $bmd The bitmap data to be cleared
*
* @return void
*/
public static function clearBitmapData($bmd:BitmapData):void
{
$bmd.fillRect($bmd.rect, 0);
}
/**
* Slices a bitmap into a grid of tiles specified by row and column count.
*
* @param $bmp The bitmap to be tiled
* @param $numRows Number of rows
* @param $numCols Number of columns
*
* @return Array 2-Dimensional array of bitmaps
*/
public static function createTiles($bmp:Bitmap, $numRows:int = 3, $numCols:int = 3):Array
{
var w:Number = ($bmp.width / $numCols);
var h:Number = ($bmp.height / $numRows);
var tiles:Array = [];
var rect:Rectangle;
var bmpTile:Bitmap;
var bmd:BitmapData;
for (var i:int = 0; i < $numRows; i++)
{
tiles[i] = new Array();
for (var j:int = 0; j < $numCols; j++)
{
bmd = new BitmapData(w, h, true, 0x00000000);
rect = new Rectangle((j * w), (i * h), w, h);
bmd.copyPixels($bmp.bitmapData, rect, new Point(0, 0));
bmpTile = new Bitmap(bmd);
tiles[i][j] = bmpTile;
}
}
return tiles;
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/utils/LayoutUtils.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.utils
{
import flash.geom.Point;
import flash.utils.getQualifiedClassName;
/**
* Static utility methods used to aid in laying out objects on the stage.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class LayoutUtils
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function LayoutUtils()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Creates a grid and returns a vector of points with x and y values based on passed parameters.
* The $leftToRight addition was contributed by Skye Giordano.
*
* @param $columns An integer representing the number of columns to be created in the grid
* @param $rows An integer representing the number of rows to be created in the grid
* @param $xSpacing An integer representing the spacing between columns
* @param $ySpacing An integer representing the spacing between rows
* @param $xPadding An integer representing the padding between each column
* @param $yPadding An integer representing the padding between each row
* @param $leftToRight An optional boolean that creates the grid from left-to-right or top-to-bottom (default: true)
*
* @return Vector.* var val:* = ArrayUtils.getRandomItem(10, "Hello", "0xFF0000", 1000); ** * @return An unspecified value that is selected at random */ public static function getRandomItem(...args:Array):* { return args[int(Math.random() * args.length)]; } /** * Returns the number of instances of an item within a given array. * * @param $array The array to check in * @param $item The item to check for * * @return uint */ public static function contains($array:Array, $item:*):uint { var i:int = $array.indexOf($item, 0); var t:uint = 0; while (i != -1) { i = $array.indexOf($item, (i + 1)); t++; } return t; } /** * Removes all instances of the specified value from an array. * * @param $array The array to check in * @param $value The value to check for * * @return void */ public static function removeValue($array:Array, $value:Object):void { var len:uint = $array.length; for (var i:Number = len; i > -1; i--) { if ($array[i] === $value) { $array.splice(i, 1); } } } //- EVENT HANDLERS ---------------------------------------------------------------------------------------- //- GETTERS & SETTERS ------------------------------------------------------------------------------------- //- HELPERS ----------------------------------------------------------------------------------------------- /** * @private */ public function toString():String { return getQualifiedClassName(this); } //- END CLASS --------------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/debug/Environment.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.debug { import flash.display.Stage; import flash.system.Capabilities; import flash.utils.getQualifiedClassName; /** * A small Singleton utility class that allows you to set debug and live path variables for local and remote testing without having to toggle anything. * * @author Joshua Perez [http://www.joshua-studios.com] * @author Matt Przybylski [http://www.reintroducing.com] * @version 2.0 */ public class Environment { //- PRIVATE & PROTECTED VARIABLES ------------------------------------------------------------------------- // singleton instance private static var _instance:Environment; private static var _allowInstance:Boolean; private var _debugPath:String; private var _livePath:String; private var _basePath:String; private var _isLive:Boolean; //- PUBLIC & INTERNAL VARIABLES --------------------------------------------------------------------------- //- CONSTRUCTOR ------------------------------------------------------------------------------------------- // singleton instance of Environment public static function getInstance():Environment { if (_instance == null) { _allowInstance = true; _instance = new Environment(); _allowInstance = false; } return _instance; } public function Environment() { if (!_allowInstance) { throw new Error("Error: Use Environment.getInstance() instead of the new keyword."); } } //- PRIVATE & PROTECTED METHODS --------------------------------------------------------------------------- private function setProperPath($useServerCheck:Boolean, $stage:Stage):void { if ($useServerCheck) { if ($stage.loaderInfo.url.indexOf("file:") != -1) { _basePath = _debugPath; _isLive = false; } else { _basePath = _livePath; _isLive = true; } } else { if (Capabilities.playerType == "PlugIn" || Capabilities.playerType == "ActiveX") { _basePath = _livePath; _isLive = true; } else { _basePath = _debugPath; _isLive = false; } } } //- PUBLIC & INTERNAL METHODS ----------------------------------------------------------------------------- /** * Sets the proper debug/live paths. * * @param $debugPath A string representing the local (debug) path * @param $livePath A string representing the remote (live) path * @param $useServerCheck Check against path of file as it pertains to the server rather than player type * @param $stage If using $useServerCheck, pass the stage reference * * @return void */ public function setPaths($debugPath:String, $livePath:String, $useServerCheck:Boolean = false, $stage:Stage = null):void { _debugPath = $debugPath; _livePath = $livePath; setProperPath($useServerCheck, $stage); } /** * Returns a player and environment info string. * * @return String */ public function getPlayerInfo():String { var debugger:String = (Capabilities.isDebugger) ? " / Debugger" : ""; var info:String = String("Flash Platform: " + Capabilities.version + " / " + Capabilities.playerType + debugger + " / " + Capabilities.os + " / " + Capabilities.screenResolutionX + "x" + Capabilities.screenResolutionY); return info; } //- EVENT HANDLERS ---------------------------------------------------------------------------------------- //- GETTERS & SETTERS ------------------------------------------------------------------------------------- /** * Returns the basePath for use in loading assets. * * @return String */ public function get basePath():String { return _basePath; } /** * Returns a Boolean value if the site is on a live server or being tested locally. * * @return Boolean */ public function get isLive():Boolean { return _isLive; } //- HELPERS ----------------------------------------------------------------------------------------------- /** * @private */ public function toString():String { return getQualifiedClassName(this); } //- END CLASS --------------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/utils/DisplayObjectUtils.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.utils { import flash.display.DisplayObject; import flash.display.DisplayObjectContainer; import flash.display.MovieClip; import flash.utils.getQualifiedClassName; /** * Static utility methods used to manipulate DisplayObjects. * * @author Matt Przybylski [http://www.reintroducing.com] * @version 1.0 */ public class DisplayObjectUtils { //- PRIVATE & PROTECTED VARIABLES ------------------------------------------------------------------------- //- PUBLIC & INTERNAL VARIABLES --------------------------------------------------------------------------- //- CONSTRUCTOR ------------------------------------------------------------------------------------------- public function DisplayObjectUtils() { } //- PRIVATE & PROTECTED METHODS --------------------------------------------------------------------------- //- PUBLIC & INTERNAL METHODS ----------------------------------------------------------------------------- /** * Removes all the children from the specified DisplayObjectContainer. * * @param $do The DisplayObjectContainer to remove children from * * @return void */ public static function removeAllChildren($do:DisplayObjectContainer):void { while ($do.numChildren) { $do.removeChildAt(0); } } /** * Resizes a DisplayObject to the specified width/height and allows to control aspect ratio. * Originally written by Evan Mullins [http://blog.circlecube.com/] * * @param $do The DisplayObject to resize * @param $maxW The maximum desired width * @param $maxH The maximum desired height (default: 0, matches $maxW and resizes into a square) * @param $constrainProportions A boolean that identifies if you should maintain the aspect ratio * * @return void */ public static function resizeTo($do:DisplayObject, $maxW:Number, $maxH:Number = 0, $constrainProportions:Boolean = true):void { $maxH = ($maxH == 0) ? $maxW : $maxH; $do.width = $maxW; $do.height = $maxH; if ($constrainProportions) { ($do.scaleX < $do.scaleY) ? $do.scaleY = $do.scaleX : $do.scaleX = $do.scaleY; } } /** * Plays all MovieClips (and any of their children) on the specified object's timeline. * If any of the clips have reached their last frame, they will not replay. * * @param $obj The timeline (and all of its children) to play the MovieClips of * * @return void */ protected function playMovieClips($obj:DisplayObject):void { var mc:MovieClip = $obj as MovieClip; if (mc == null) { return; } if (mc.currentFrame != mc.totalFrames) mc.play(); var i:int = mc.numChildren; while (--i > -1) { playMovieClips(mc.getChildAt(i)); } } /** * Stops all MovieClips (and any of their children) on the specified object's timeline. * * @param $obj The timeline (and all of its children) to stop the MovieClips of * * @return void */ protected function stopMovieClips($obj:DisplayObject):void { var mc:MovieClip = $obj as MovieClip; if (mc == null) { return; } mc.stop(); var i:int = mc.numChildren; while (--i > -1) { stopMovieClips(mc.getChildAt(i)); } } /** * Determines the frame number for the specified label. * * @param $target The MovieClip to search for the frame label in * @param $label The name of the frame label * * @return int The frame number of the label or -1 if the frame label was not found */ public function getFrameNumberForLabel($target:MovieClip, $label:String):int { var labels:Array = $target.currentLabels; var l:int = labels.length; while (l--) { if (labels[l].name == $label) return labels[l].frame; } return -1; } //- EVENT HANDLERS ---------------------------------------------------------------------------------------- //- GETTERS & SETTERS ------------------------------------------------------------------------------------- //- HELPERS ----------------------------------------------------------------------------------------------- /** * @private */ public function toString():String { return getQualifiedClassName(this); } //- END CLASS --------------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/utils/LinkUtils.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.utils { import com.reintroducing.data.link.LinkData; import flash.external.ExternalInterface; import flash.net.URLRequest; import flash.net.navigateToURL; import flash.utils.getQualifiedClassName; /** * Static utility methods to easily create external links. * * @author Matt Przybylski [http://www.reintroducing.com] * @version 1.0 */ public class LinkUtils { //- PRIVATE & PROTECTED VARIABLES ------------------------------------------------------------------------- //- PUBLIC & INTERNAL VARIABLES --------------------------------------------------------------------------- //- CONSTRUCTOR ------------------------------------------------------------------------------------------- public function LinkUtils() { } //- PRIVATE & PROTECTED METHODS --------------------------------------------------------------------------- //- PUBLIC & INTERNAL METHODS ----------------------------------------------------------------------------- /** * Launches a link with the specified data. * * @param $linkData The LinkData to pass in to the request * * @return void */ public static function launch($linkData:LinkData):void { var url:URLRequest = new URLRequest($linkData.sourceURL); navigateToURL(url, $linkData.targetWindow); } /** * Opens a popup window with the specified data. * * @param $linkData The LinkData to pass in to the popup * * @return void */ public static function openPopup($linkData:LinkData):void { if (ExternalInterface.available) { var params:String = ""; params += "width=" + $linkData.windowWidth; params += ",height=" + $linkData.windowHeight; params += ",left=" + $linkData.windowX; params += ",top=" + $linkData.windowY; params += ",status=" + String(($linkData.statusBar) ? "1" : "0"); params += ",toolbar=" + String(($linkData.toolBar) ? "1" : "0"); params += ",location=" + String(($linkData.location) ? "1" : "0"); params += ",menubar=" + String(($linkData.menuBar) ? "1" : "0"); params += ",directories=" + String(($linkData.directories) ? "1" : "0"); params += ",resizable=" + String(($linkData.resizable) ? "1" : "0"); params += ",scrollbars=" + String(($linkData.scrollBars) ? "1" : "0"); params += ",copyhistory=" + String(($linkData.scrollBars) ? "1" : "0"); params += ",fullscreen=" + String(($linkData.fullScreen) ? "1" : "0"); ExternalInterface.call("window.open", $linkData.sourceURL, $linkData.windowName, params); } else { var javaScriptStr:String = "javascript:NewWindow=window.open('"; javaScriptStr += $linkData.sourceURL; javaScriptStr += "','" + $linkData.windowName + "','"; javaScriptStr += "height=" + $linkData.windowHeight; javaScriptStr += ",width=" + $linkData.windowWidth; javaScriptStr += ",left=" + $linkData.windowX; javaScriptStr += ",top=" + $linkData.windowY; javaScriptStr += ",status=" + String(($linkData.statusBar) ? "yes" : "no"); javaScriptStr += ",toolbar=" + String(($linkData.toolBar) ? "yes" : "no"); javaScriptStr += ",location=" + String(($linkData.location) ? "yes" : "no"); javaScriptStr += ",menubar=" + String(($linkData.menuBar) ? "yes" : "no"); javaScriptStr += ",directories=" + String(($linkData.directories) ? "yes" : "no"); javaScriptStr += ",resizable=" + String(($linkData.resizable) ? "yes" : "no"); javaScriptStr += ",scrollbars=" + String(($linkData.scrollBars) ? "yes" : "no"); javaScriptStr += ",copyhistory=" + String(($linkData.copyHistory) ? "yes" : "no"); javaScriptStr += ",fullscreen=" + String(($linkData.fullScreen) ? "yes" : "no"); javaScriptStr += "'); NewWindow.focus(); void(0);"; var url:URLRequest = new URLRequest(javaScriptStr); navigateToURL(url); } } //- EVENT HANDLERS ---------------------------------------------------------------------------------------- //- GETTERS & SETTERS ------------------------------------------------------------------------------------- //- HELPERS ----------------------------------------------------------------------------------------------- /** * @private */ public function toString():String { return getQualifiedClassName(this); } //- END CLASS --------------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /source/libs/com/reintroducing/utils/ExternalInterfaceManager.as: -------------------------------------------------------------------------------- 1 | package com.reintroducing.utils 2 | { 3 | import com.reintroducing.data.utils.ExternalInterfaceMethod; 4 | import flash.external.ExternalInterface; 5 | import flash.utils.clearInterval; 6 | import flash.utils.getQualifiedClassName; 7 | import flash.utils.setInterval; 8 | 9 | /** 10 | * Utility to buffer outgoing ExternalInterface calls. Simultaneous calls get dropped if they aren't buffered. It seems both Firefox and IE's script engine gets overloaded and either drops calls or 11 | * throws a JavaScript error. This buffer ensures the script engines only get one call at a time. 12 | * 13 | *
14 | * var eiMethod:ExternalInterfaceMethod = new ExternalInterfaceMethod();
15 | * eiMethod.methodName = "jsMethodName";
16 | * eiMethod.methodParameters = {argA: "blah", argB: "merp", argC: "DOH"};
17 | *
* ExternalInterfaceManager.getInstance().call(eiMethod);
18 | *
19 | *
20 | * @author Scott Morgan for Yahoo! Maps AS3 Communication Kit (2007)
21 | * @author Matt Przybylski [http://www.reintroducing.com] - Modified to use strongly typed ExternalInterfaceMethod value object
22 | * @version 1.0
23 | */
24 | public class ExternalInterfaceManager
25 | {
26 | //- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
27 |
28 | // singleton instance
29 | private static var _instance:ExternalInterfaceManager;
30 | private static var _allowInstance:Boolean;
31 |
32 | private var methodQueue:Array = [];
33 | private var methodCallInterval:Number;
34 |
35 | //- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
36 |
37 |
38 |
39 | //- CONSTRUCTOR -------------------------------------------------------------------------------------------
40 |
41 | // singleton instance of ExternalInterfaceManager
42 | public static function getInstance():ExternalInterfaceManager
43 | {
44 | if (_instance == null)
45 | {
46 | _allowInstance = true;
47 | _instance = new ExternalInterfaceManager();
48 | _allowInstance = false;
49 | }
50 |
51 | return _instance;
52 | }
53 |
54 | public function ExternalInterfaceManager()
55 | {
56 | if (!_allowInstance)
57 | {
58 | throw new Error("Error: Use ExternalInterfaceManager.getInstance() instead of the new keyword.");
59 | }
60 | }
61 |
62 | //- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
63 |
64 | /**
65 | * Called every 50 milliseconds until the methodQueue array is empty. This method sends the first method listed in the methodQueue array to the
66 | * ExternalInterface.call method.
67 | *
68 | * @return void
69 | */
70 | private function methodChurn():void
71 | {
72 | var eiMethod:ExternalInterfaceMethod = (methodQueue[0] as ExternalInterfaceMethod);
73 |
74 | if (eiMethod.methodName) ExternalInterface.call(eiMethod.methodName, eiMethod.methodParameters);
75 |
76 | methodQueue.shift();
77 |
78 | if (methodQueue.length == 0)
79 | {
80 | clearInterval(methodCallInterval);
81 |
82 | methodCallInterval = undefined;
83 | }
84 | }
85 |
86 | //- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
87 |
88 | /**
89 | * Adds calls to the methodQueue array. If the length of the methodQueue array is greater than 0 the methodChurn interval is kicked off and runs every 50
90 | * milliseconds until the methodQueue's length is 0 at which point the interval is cleared.
91 | *
92 | * @param $eiMethod The ExternalInterfaceMethod object to send to the queue.
93 | *
94 | * @return void
95 | */
96 | public function call($eiMethod:ExternalInterfaceMethod):void
97 | {
98 | methodQueue.push($eiMethod);
99 |
100 | if (isNaN(methodCallInterval) || methodCallInterval == 0) methodCallInterval = setInterval(methodChurn, 50);
101 | }
102 |
103 | //- EVENT HANDLERS ----------------------------------------------------------------------------------------
104 |
105 |
106 |
107 | //- GETTERS & SETTERS -------------------------------------------------------------------------------------
108 |
109 |
110 |
111 | //- HELPERS -----------------------------------------------------------------------------------------------
112 |
113 | /**
114 | * @private
115 | */
116 | public function toString():String
117 | {
118 | return getQualifiedClassName(this);
119 | }
120 |
121 | //- END CLASS ---------------------------------------------------------------------------------------------
122 | }
123 | }
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/utils/ColorUtils.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.utils
{
import flash.utils.getQualifiedClassName;
/**
* Static utility methods used to manipulate colors.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class ColorUtils
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function ColorUtils()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Returns the value of red in the specified color (0 - 255).
*
* @param $color The color, in hexadecimal format, to extract the red value from
*
* @return uint
*/
public static function extractRed($color:uint):uint
{
return (($color >> 16) & 0xFF);
}
/**
* Returns the value of green in the specified color (0 - 255).
*
* @param $color The color, in hexadecimal format, to extract the green value from
*
* @return uint
*/
public static function extractGreen($color:uint):uint
{
return (($color >> 8) & 0xFF);
}
/**
* Returns the value of blue in the specified color (0 - 255).
*
* @param $color The color, in hexadecimal format, to extract the blue value from
*
* @return uint
*/
public static function extractBlue($color:uint):uint
{
return ($color & 0xFF);
}
/**
* Returns the value of alpha in the specified color (0 - 255).
*
* @param $color The color, in hexadecimal format, to extract the blue value from
*
* @return uint
*/
public static function extractAlpha($color:uint):uint
{
return (($color >> 24 ) & 0xFF);
}
/**
* Combines red, blue, and green components into a color value.
*
* @param $r The red value
* @param $g The green value
* @param $b The blue value
*
* @return uint The numerical representation of the combined colors
*/
public static function combineRGB($r:uint, $g:uint, $b:uint):uint
{
return (($r << 16) | ($g << 8) | $b);
}
/**
* Combines alpha, red, blue, and green components into a color value.
*
* @param $a The alpha value
* @param $r The red value
* @param $g The green value
* @param $b The blue value
*
* @return uint The numerical representation of the combined colors
*/
public static function combineARGB($a:uint, $r:uint, $g:uint, $b:uint):uint
{
return (($a << 24) | ($r << 16) | ($g << 8) | $b);
}
/**
* Displays the specified numerical representation of a color (RGB) as a hexadecimal string.
*
* @param $color The numerical value of a color
*
* @return String The color represented in hexadecimal RGB
*/
public static function displayRGBasHex($color:uint):String
{
var r:String = extractRed($color).toString(16).toUpperCase();
var g:String = extractGreen($color).toString(16).toUpperCase();
var b:String = extractBlue($color).toString(16).toUpperCase();
var zero:String = "0";
if (r.length == 1) r = zero.concat(r);
if (g.length == 1) g = zero.concat(g);
if (b.length == 1) b = zero.concat(b);
return String(r + g + b);
}
/**
* Displays the specified numerical representation of a color (ARGB) as a hexadecimal string.
*
* @param $color The numerical value of a color
*
* @return String The color represented in hexadecimal ARGB
*/
public static function displayARGBasHex($color:uint):String
{
var a:String = extractAlpha($color).toString(16).toUpperCase();
var r:String = extractRed($color).toString(16).toUpperCase();
var g:String = extractGreen($color).toString(16).toUpperCase();
var b:String = extractBlue($color).toString(16).toUpperCase();
var zero:String = "0";
if (a.length == 1) a = zero.concat(a);
if (r.length == 1) r = zero.concat(r);
if (g.length == 1) g = zero.concat(g);
if (b.length == 1) b = zero.concat(b);
return String(a + r + g + b);
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/utils/StringUtils.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.utils
{
import flash.utils.getQualifiedClassName;
import flash.xml.XMLDocument;
import flash.xml.XMLNode;
import flash.xml.XMLNodeType;
/**
* Static utility methods for working with strings.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class StringUtils
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
public function StringUtils()
{
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Converts the given string into a boolean.
*
* @param $string The string value to convert
*
* @return Boolean
*/
public static function stringToBoolean($string:String):Boolean
{
return ($string.toLowerCase() == "true" || $string.toLowerCase() == "1");
}
/**
* Counts the number of words in the given string.
*
* @param $string The string value to count the number of words in
*
* @return int
*/
public static function countWords($string:String):int
{
if ($string == null) { return 0; }
return $string.match(/\b\w+\b/g).length;
}
/**
* Checks if a string is empty or not.
*
* @param $string The string to check against
*
* @return Boolean
*/
public static function isEmpty($string:String):Boolean
{
if ($string == null || $string == " " || $string == "") { return true; }
return !$string.length;
}
/**
* Uses Regular Expressions to escape backslashes in the provided string.
* Without using this method, a backslash will be removed from the string
* because it is used to escape other characters.
*
* @param $string The string to escape slashes in
*
*
* trace(StringUtils.escapeBackslashes("this is \ the way to do it")); // traces "this is \ the way to do it"
*
*
* @return String
*/
public static function escapeBackslashes($string:String):String
{
return $string.replace(/\\/g, "\\\\");
}
/**
* Uses Regular Expressions to trim beginning and trailing white space.
*
* @param $string The string to trim white space in
*
* @return String
*/
public static function trimWhitespace($string:String):String
{
if ($string == null) { return ""; }
return $string.replace(/^\s+|\s+$/g, "");
}
/**
* Unescapes html entities.
*
*
* trace(htmlUnescape("ham & eggs")); // traces ham & eggs
*
*
* @param $str The string to unescape
*
* @return String
*/
public static function htmlUnescape($str:String):String
{
return new XMLDocument($str).firstChild.nodeValue;
}
/**
* Escapes html entities.
*
*
* trace(htmlEscape("ham & eggs")); // traces ham & eggs
*
*
* @param $str The string to escape
*
* @return String
*/
public static function htmlEscape($str:String):String
{
return XML(new XMLNode(XMLNodeType.TEXT_NODE, $str)).toXMLString();
}
/**
* Converts all XML tags to lowercase
*
*
* var x:XML = xmlTagsToLowerCase(new XML("test"));
* trace(x); // Output: test
*
*
* @param $xml The XML to convert
*
* @return XML
*/
public static function xmlTagsToLowerCase($xml:XML):XML
{
// convert the root tag to lowercase
$xml.setName($xml.name().toString().toLowerCase());
for each (var attribute:XML in $xml.@*)
{
attribute.setName(attribute.name().toString().toLowerCase());
}
// convert all descendant tags to lowercase
for each (var child:XML in $xml..*)
{
// if the node is an element...
if (child.nodeKind() == "element")
{
// ...change its name to lowercase.
child.setName(child.name().toString().toLowerCase());
// if the node has any attributes, change their names to lowercase.
for each (attribute in child.@*)
{
attribute.setName(attribute.name().toString().toLowerCase());
}
}
}
return $xml;
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/ui/mousepositionpanel/MousePositionPanel.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.ui.mousepositionpanel
{
import flash.display.Sprite;
2 | import com.reintroducing.data.mousepositionpanel.MousePositionPanelData;
3 | import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.getQualifiedClassName;
/**
* Creates a scrolling panel that allows for scrolling on the x or y axis depending on where the
* mouse pointer is within the panel as well as going with or against the mouse.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.2
*/
public class MousePositionPanel
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
protected var _holder:Sprite;
protected var _mc:Sprite;
protected var _mask:Sprite;
protected var _axis:String;
protected var _moveType:String;
protected var _moveDir:Number;
protected var _mouseAxis:String;
protected var _changeProp:String;
protected var _speed:Number;
protected var _end:Number;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
/**
* Creates a new instance of the MousePositionPanel class.
*
* @param $mousePositionPanelData The MousePositionPanelData to use with the MousePositionPanel
*
* * The $mousePositionPanelData object takes the following values: *
39 | * The class will dispatch two events: 40 | *
* var fvm:FlashVarsManager = FlashVarsManager.getInstance(loaderInfo);
* fvm.addDefault("testPath", "../test/folder/here");
* fvm.addDefault("servicePath", "../service/here");
* fvm.addDefault("imagePath", "../img/folder/here");
* fvm.initialize();
*
* fvm.flashVars.output();
*
* trace(fvm.getByName("servicePath").value);
* trace(fvm.getValueByName("imagePath"));
*
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.0
*/
public class FlashVarsManager
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
// singleton instance
private static var _instance:FlashVarsManager;
private static var _allowInstance:Boolean;
private var _loaderInfo:LoaderInfo;
private var _flashVars:FlashVars;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
// singleton instance of FlashVarsManager
public static function getInstance($loaderInfo:LoaderInfo = null):FlashVarsManager
{
if (_instance == null)
{
_allowInstance = true;
_instance = new FlashVarsManager($loaderInfo);
_allowInstance = false;
}
return _instance;
}
public function FlashVarsManager($loaderInfo:LoaderInfo)
{
if (!_allowInstance)
{
throw new Error("Error: Use FlashVarsManager.getInstance() instead of the new keyword.");
}
else
{
_loaderInfo = $loaderInfo;
_flashVars = new FlashVars("FlashVars");
}
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
// creates a new FlashVar
private function createFlashVar($name:String, $value:String):FlashVar
{
var flashVar:FlashVar = new FlashVar();
flashVar.name = $name;
flashVar.value = $value;
return flashVar;
}
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Initializes the FlashVars and parses any QueryString params that were passed into the SWF for usage within the FlashVarsManager.
*
* @return void
*/
public function initialize():void
{
var params:Object = _loaderInfo.parameters;
if (ExternalInterface.available)
{
// get query string
var queryString:String = ExternalInterface.call("document.location.search.toString");
if (queryString != null && queryString != "")
{
var querySplit:Array = String(queryString.split("?")[1]).split("&");
var queryVarName:String;
var queryVarValue:String;
// add query string params
for (var i:int = 0; i < querySplit.length; i++)
{
queryVarName = String(querySplit[i]).split("=")[0];
queryVarValue = String(querySplit[i]).split("=")[1];
if (_flashVars.getItemByName(queryVarName) != null)
{
_flashVars.getItemByName(queryVarName).value = queryVarValue;
}
else
{
_flashVars.addItem(this.createFlashVar(queryVarName, queryVarValue));
}
}
}
// add flashvars
for (var varName:String in params)
{
if (_flashVars.getItemByName(varName) != null)
{
_flashVars.getItemByName(varName).value = params[varName];
}
else
{
_flashVars.addItem(this.createFlashVar(varName, params[varName]));
}
}
}
else
{
trace("WARNING: FlashVars could not be retrieved!");
}
}
/**
* Returns a FlashVar by its specified name.
*
* @param $name The name of the FlashVar to retrieve
*
* @return FlashVar
*/
public function getByName($name:String):FlashVar
{
return (_flashVars.getItemByName($name) as FlashVar);
}
/**
* Returns a FlashVar's value by its specified name.
*
* @param $name The name of the FlashVar to retrieve
*
* @return String
*/
public function getValueByName($name:String):String
{
return (_flashVars.getItemByName($name) as FlashVar).value;
}
/**
* Adds a default value to a FlashVar.
*
* @param $name The name of the FlashVar to set the value on
* @param $value The value to set it to
*
* @return void
*/
public function addDefault($name:String, $value:String):void
{
if (_flashVars.getItemByName($name) != null)
{
_flashVars.getItemByName($name).value = $value;
}
else
{
_flashVars.addItem(createFlashVar($name, $value));
}
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
/**
* Returns a collection of strongly typed FlashVars.
*
* @return FlashVars
*/
public function get flashVars():FlashVars
{
return _flashVars;
}
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/data/base/Collection.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.data.base
{
import flash.utils.getQualifiedClassName;
/**
* Helper class used to manage a collection of objects. This class is similar to the Java
* Collection interface. Developers can extend this class to create new Collection types
* that provide additional functionality such as ordering and sorting.
*
* @author Adobe [http://www.adobe.com]
* @author Ported to AS3 by Matt Przybylski [http://www.reintroducing.com]
* @version 1.1
*/
public class Collection implements ICollection
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
protected var _name:String;
protected var _items:Array;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
/**
* Constructor
*
* @param $name the name of the Collection.
*/
public function Collection($name:String)
{
super();
_name = $name;
_items = new Array();
}
//- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
// Finds an item within the Collection and returns it's index.
private function internalGetItem($item:Object):int
{
var result:int = -1;
for (var i:int = 0; i < _items.length; i++)
{
if (_items[i] == $item)
{
result = i;
break;
}
}
return result;
}
//- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
/**
* Gets the name of the Collection.
*
* @return String the name of the Collection.
*/
public function getName():String
{
return _name;
}
/**
* Adds a new item to the end of the Collection.
*
* @param $item * to be added to the Collection. If item is null it will not be added to the Collection.
*
* @return Boolean true if the Collection was changed as a result of the operation.
*/
public function addItem($item:*):Boolean
{
var result:Boolean = false;
if ($item != null)
{
_items.push($item);
result = true;
}
return result;
}
/**
* Adds an array of items to the Collection.
*
* @param items An array of items to be added
*
* @return void
*/
public function addItems(...$items):void
{
for each (var item:* in $items)
{
addItem(item);
}
}
/**
* Adds a new item at the specified index in the Collection.
*
* @param $index position to add the specified item in
* @param $item * to be added to the Collection.
*
* @return void
*/
public function addItemAt($index:int, $item:*):void
{
_items.splice($index, 0, $item);
}
/**
* Removes a single item from the Collection. Returns false if item is not found.
*
* @param $item reference to Collection item to be removed from Collection.
*
* @return Boolean true if item is found and successfully removed. False if item is not found.
*/
public function removeItem($item:*):Boolean
{
var result:Boolean = false;
var itemIndex:int = internalGetItem($item);
if (itemIndex > -1)
{
_items.splice(itemIndex, 1);
result = true;
}
return result;
}
/**
* Removes all items from the Collection.
*
* @return void
*/
public function clear():void
{
_items.length = 0;
}
/**
* Reverses the Collection.
*
* @return void
*/
public function reverse():void
{
_items.reverse();
}
/**
* Returns true if this Collection contains the specified item.
*
* @param $item * whose presence in this collection is to be tested.
*
* @return Boolean true if this collection contains the specified item.
*/
public function contains($item:*):Boolean
{
return (internalGetItem($item) > -1);
}
/**
* Returns an item within the Collection using it's index.
*
* @param $index location of item within the Collection.
*
* @return * reference to item.
*/
public function getItemAt($index:int):*
{
return _items[$index];
}
/**
* Returns an iterator over the elements in this collection. There are no guarantees concerning
* the order in which the elements are returned (unless this collection is an instance of some
* class that provides a guarantee).
*
* @return Iterator object that is used to iterate through the collection.
*/
public function getIterator():Iterator
{
return (new Iterator(this));
}
/**
* Returns the current length
*
* @return int value reflecting the number of items in this Collection.
*/
public function getLength():int
{
return _items.length;
}
/**
* Returns true if the Collection is empty.
*
* @return Boolean true if Collection is empty.
*/
public function isEmpty():Boolean
{
return (_items.length == 0);
}
/**
* Traces the Value Objects of the Collection to the Output panel.
*
* @return void
*/
public function output():void
{
trace("Start " + getName() + " Contents:");
trace("---------------------------------------------\n");
for (var i:int = 0; i < getLength(); i++)
{
var vo:IValueObject = getItemAt(i);
vo.output();
}
trace("End " + getName() + " Contents");
trace("---------------------------------------------\n");
}
//- EVENT HANDLERS ----------------------------------------------------------------------------------------
//- GETTERS & SETTERS -------------------------------------------------------------------------------------
//- HELPERS -----------------------------------------------------------------------------------------------
/**
* @private
*/
public function toString():String
{
return getQualifiedClassName(this);
}
//- END CLASS ---------------------------------------------------------------------------------------------
}
}
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/sound/SoundItem.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.sound
2 | {
3 | import com.greensock.TweenLite;
4 | import com.greensock.plugins.TweenPlugin;
5 | import com.greensock.plugins.VolumePlugin;
6 | import com.reintroducing.events.SoundManagerEvent;
7 |
8 | import flash.events.Event;
9 | import flash.events.EventDispatcher;
10 | import flash.media.Sound;
11 | import flash.media.SoundChannel;
12 | import flash.media.SoundTransform;
13 | import flash.utils.getQualifiedClassName;
14 |
15 | /**
16 | * A class that acts as a holder for a sound to be used in the SoundManager.
17 | *
18 | * @author Matt Przybylski [http://www.reintroducing.com]
19 | * @version 1.4.2
20 | */
21 | public class SoundItem extends EventDispatcher
22 | {
23 | //- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
24 |
25 | private var _fadeTween:TweenLite;
26 | private var _volume:Number;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public var name:String;
27 | public var sound:Sound;
public var channel:SoundChannel;
public var position:int;
public var paused:Boolean;
public var savedVolume:Number;
public var startTime:Number;
public var loops:int;
public var pausedByAll:Boolean;
public var muted:Boolean;
28 |
29 | //- CONSTRUCTOR -------------------------------------------------------------------------------------------
30 |
31 | public function SoundItem():void
{
super();
32 |
33 | TweenPlugin.activate([VolumePlugin]);
34 |
35 | init();
}
36 |
37 | //- PRIVATE & PROTECTED METHODS ---------------------------------------------------------------------------
38 |
39 | /**
40 | *
41 | */
42 | private function init():void
43 | {
44 | channel = new SoundChannel();
45 | }
46 |
47 | /**
48 | *
49 | */
50 | private function fadeComplete($stopOnComplete:Boolean):void
51 | {
52 | if ($stopOnComplete) stop();
53 |
54 | dispatchEvent(new SoundManagerEvent(SoundManagerEvent.SOUND_ITEM_FADE_COMPLETE, this));
55 | }
56 |
57 | //- PUBLIC & INTERNAL METHODS -----------------------------------------------------------------------------
58 |
59 | /**
60 | * Plays the SoundItem.
61 | *
62 | * @param $startTime The time, in milliseconds, to start the sound at (default: 0)
63 | * @param $loops The number of times to loop (default: 0)
64 | * @param $volume The volume to play the sound at (default: 1)
65 | * @param $resumeTween If the fade tween should be resumed if it's currently running (default: true)
66 | *
67 | * @return void
68 | */
69 | public function play($startTime:Number = 0, $loops:int = 0, $volume:Number = 1, $resumeTween:Boolean = true):void
{
if (!paused) return;
70 |
71 | volume = $volume;
72 | startTime = $startTime;
73 | loops = $loops;
74 | paused = ($startTime == 0) ? true : false;
75 |
76 | if (!paused) position = startTime;
77 |
78 | channel = sound.play(position, loops, new SoundTransform(volume));
79 | channel.addEventListener(Event.SOUND_COMPLETE, handleSoundComplete);
80 | paused = false;
81 |
82 | if ($resumeTween && (fadeTween != null)) fadeTween.resume();
}
83 |
84 | /**
85 | * Pauses the SoundItem.
86 | *
87 | * @param $pauseTween If the fade tween should be paused if it's currently running (default: true)
88 | *
89 | * @return void
90 | */
91 | public function pause($pauseTween:Boolean = true):void
92 | {
93 | paused = true;
94 | position = channel.position;
95 | channel.stop();
96 | channel.removeEventListener(Event.SOUND_COMPLETE, handleSoundComplete);
97 |
98 | if ($pauseTween && (fadeTween != null)) fadeTween.pause();
99 | }
100 |
101 | /**
102 | * Stops the SoundItem.
103 | *
104 | * @return void
105 | */
106 | public function stop():void
107 | {
108 | paused = true;
109 | channel.stop();
110 | channel.removeEventListener(Event.SOUND_COMPLETE, handleSoundComplete);
111 | position = channel.position;
112 | fadeTween = null;
113 | }
114 |
115 | /**
116 | * Fades the SoundItem.
117 | *
118 | * @param $volume The volume to fade to (default: 0)
119 | * @param $fadeLength The time, in seconds, to fade over (default: 1)
120 | * @param $stopOnComplete If the sound should be stopped after fading is complete (default: false)
121 | */
122 | public function fade($volume:Number = 0, $fadeLength:Number = 1, $stopOnComplete:Boolean = false):void
123 | {
124 | fadeTween = TweenLite.to(channel, $fadeLength, {volume: $volume, onComplete: fadeComplete, onCompleteParams: [$stopOnComplete]});
125 | }
126 |
127 | /**
128 | * Sets the volume of the SoundItem.
129 | *
130 | * @param $volume The volume to set on the sound
131 | *
132 | * @return void
133 | */
134 | public function setVolume($volume:Number):void
135 | {
136 | var curTransform:SoundTransform = channel.soundTransform;
137 | curTransform.volume = $volume;
138 | channel.soundTransform = curTransform;
139 |
140 | _volume = $volume;
141 | }
142 |
143 | /**
144 | * Clears and makes the SoundItem available for garbage collection.
145 | *
146 | * @return void
147 | */
148 | public function destroy():void
149 | {
150 | channel.removeEventListener(Event.SOUND_COMPLETE, handleSoundComplete);
151 | channel = null;
152 | fadeTween = null;
153 | }
154 |
155 | //- EVENT HANDLERS ----------------------------------------------------------------------------------------
156 |
157 | /**
158 | *
159 | */
160 | private function handleSoundComplete($evt:Event):void
161 | {
162 | stop();
163 |
164 | dispatchEvent(new SoundManagerEvent(SoundManagerEvent.SOUND_ITEM_PLAY_COMPLETE, this));
165 | }
166 |
167 | //- GETTERS & SETTERS -------------------------------------------------------------------------------------
168 |
169 | /**
170 | * Returns the volume of the Sounditem.
171 | *
172 | * @return Number
173 | */
174 | public function get volume():Number
175 | {
176 | return channel.soundTransform.volume;
177 | }
178 |
179 | /**
180 | * Sets the volume of the SoundItem.
181 | *
182 | * @param $val The volume to set
183 | *
184 | * @return void
185 | */
186 | public function set volume($val:Number):void
187 | {
188 | setVolume($val);
189 | }
190 |
191 | /**
* Returns the instance of the fading tween.
192 | *
193 | * @return TweenLite
*/
public function get fadeTween():TweenLite
{
return _fadeTween;
}
/**
* Sets the instance of the fading tween.
194 | *
195 | * @param $val The TweenLite instance to create
196 | *
197 | * @return void
*/
public function set fadeTween($val:TweenLite):void
{
if ($val == null) TweenLite.killTweensOf(this);
_fadeTween = $val;
}
198 |
199 | //- HELPERS -----------------------------------------------------------------------------------------------
200 |
201 | /**
202 | * @private
203 | */
204 | override public function toString():String
205 | {
206 | return getQualifiedClassName(this);
207 | }
208 |
209 | //- END CLASS ---------------------------------------------------------------------------------------------
210 | }
211 | }
--------------------------------------------------------------------------------
/source/libs/com/reintroducing/ui/pulloutmenu/PullOutMenu.as:
--------------------------------------------------------------------------------
1 | package com.reintroducing.ui.pulloutmenu
{
import com.greensock.TweenMax;
import com.reintroducing.data.pulloutmenu.PullOutMenuData;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.getQualifiedClassName;
/**
* Creates a menu like the classic dropdown menu with the options to direct it up, down, left, or right depending on values set.
*
* CHANGE LOG:
* v 1.3 - Made the class extend Sprite so it can be added to the stage.
*
* Changed the constructor to accept PullOutMenuData object.
*
* Changed interval check into an enter frame check.
*
* Changed TweenLite to TweenMax.
*
* v 1.2 - Added events OPEN/CLOSE that dispatch correspondingly.
*
* Changed out Adobe's Tween class in favor of TweenLite.
*
* @author Matt Przybylski [http://www.reintroducing.com]
* @version 1.3
*/
public class PullOutMenu extends Sprite
{
//- PRIVATE & PROTECTED VARIABLES -------------------------------------------------------------------------
private var _startHeight:Number;
private var _endHeight:Number;
private var _openSpeed:Number;
private var _closeSpeed:Number;
private var _axis:String;
private var _easeFunc:Function;
private var _eventType:String;
//- PUBLIC & INTERNAL VARIABLES ---------------------------------------------------------------------------
public var container:Sprite;
public var masker:Sprite;
public var hitButton:Sprite;
public var itemHolder:Sprite;
//- CONSTRUCTOR -------------------------------------------------------------------------------------------
/**
* Creates a new instance of the PullOutMenu class.
*
* @param $pullOutMenuData The PullOutMenuData to use with the PullOutMenu.
*
* * The $pullOutMenuData object takes the following values: *
* trace(MathUtils.isPrime(13)); // traces true * trace(MathUtils.isPrime(4)); // traces false ** * @return Boolean */ public static function isPrime($value:Number):Boolean { if ($value == 1 || $value == 2) return true; if (isEven($value)) return false; var s:Number = Math.sqrt($value); for (var i:Number = 3; i <= s; i++) { if ($value % i == 0) return false; } return true; } /** * Determines if the number is an integer (containts no decimal values). * * @param $value The number to test * *
* trace(MathUtils.isInteger(13)); // traces true * trace(MathUtils.isInteger(1.2345)); // traces false ** * @return Boolean */ public static function isInteger($value:Number):Boolean { return ($value % 1) == 0; } /** * Determines if the number is even. * * @param $num The number to test * * @return Boolean */ public static function isEven($num:Number):Boolean { return ($num & 1) == 0; } /** * Determines if the number is positive. * * @param $num The number to test * * @return Boolean */ public static function isPositive($num:Number):Boolean { return ($num >= 0) == true; } /** * Returns the absolute value of an integer. * * @param $num The integer to use in the calculation * * @return int */ public static function absInteger($num:int):int { return ($num ^ ($num >> 31)) - ($num >> 31); } /** * Determines if the specified value is included within a range. * The range values do no need to be specified in order. * * @param $value The number to check * @param $firstValue Starting value of the range * @param $secondValue Ending value of the range * *
* trace(MathUtils.isBetween(3, 0, 5)); // traces true * trace(MathUtils.isBetween(7, 0, 5)); // traces false ** * @return Boolean */ public static function isBetween($value:Number, $firstValue:Number, $secondValue:Number):Boolean { return !($value < Math.min($firstValue, $secondValue) || $value > Math.max($firstValue, $secondValue)); } /** * Inserts commas every three digits in the integer of value. * * @param value The number to insert commas into * * @return String The value formatted with commas */ public static function insertCommas($value:Number):String { var valueString:String = String($value); var commaIndex:int = valueString.indexOf("."); if (commaIndex == -1) commaIndex = valueString.length; do { commaIndex -= 3; if (commaIndex <= 0) break; valueString = valueString.substring(0, commaIndex) + "," + valueString.substr(commaIndex); } while (true); if (valueString.substr(0, 2) == "0.") valueString = valueString.substr(1); return valueString; } /** * Rounds to a decimal specified by the number of points. * * @param $value The number to round * @param $points The number of points to round to * * @return Number */ public static function roundToDecimal($value:Number, $points:int):Number { if ($points < 1) { return $value >> 0; } var delta:Number = Math.pow(10, $points); return ($value * delta >> 0) / delta; } /** * Converts the number of degrees to radians. * * @param $degrees The degrees to convert * * @return Number */ public static function degreesToRadians($degrees:Number):Number { return ($degrees * (Math.PI / 180)); } /** * Converts the number of radians into degrees. * * @param $radians The radians to convert * * @return Number */ public static function radiansToDegrees($radians:Number):Number { return ($radians * (180 / Math.PI)); } /** * Gets the difference between two angles. * * @param $angle1 The first angle * @param $angle2 the second angle * * @return Number */ public static function getAngleDifference($angle1:Number, $angle2:Number):Number { return Math.abs(($angle1 + 180 - $angle2) % 360 - 180); } /** * Rounds a number to the nearest value. * * @param $roundTo The number to round to * @param $value The value to round * * @return Number */ public static function roundToNearest($roundTo:Number, $value:Number):Number { return (Math.round($value / $roundTo) * $roundTo); } /** * Returns the angle between two points. * * @param $x1 The X value of the first point * @param $y1 The Y value of the first point * @param $x2 The X value of the second point * @param $y2 The Y value of the second point * * @return Number */ public static function getAngle($x1:Number, $y1:Number, $x2:Number, $y2:Number):Number { var newX:Number = ($x2 - $x1); var newY:Number = ($y2 - $y1); return Math.round((-180 * Math.atan2(newX, newY)) / Math.PI); } /** * Returns the distance between two points. * * @param $x1 The X value of the first point * @param $y1 The Y value of the first point * @param $x2 The X value of the second point * @param $y2 The Y value of the second point * * @return Number */ public static function getDistance($x1:Number, $y1:Number, $x2:Number, $y2:Number):Number { var dx:Number = ($x2 - $x1); var dy:Number = ($y2 - $y1); return Math.sqrt((dx * dx) + (dy * dy)); } /** * Generates and returns a truly unique (not random) integer. * Casting the return value as an int will result in an incorrect value because its such a large number. * *
* var _n:Number = MathUtils.generateUniqueInt(); // correct value, 1230707045775 * var _i:int = _n; // incorrect value, -1948568177 ** * @return Number */ public static function generateUniqueNumber():Number { return new Date().time; } /** * Simplifies the supplied angle to its simplest representation. * * @param $angle The angle to simplify * *
* var _simpAngle:Number = MathUtils.simplifyAngle(725); // returns 5 * var _simpAngle2:Number = MathUtils.simplifyAngle(-725); // returns -5 ** * @return int */ public static function simplifyAngle($angle:Number):int { var rotations:int = int($angle / 360); return ($angle >= 0) ? ($angle - (360 * rotations)) : ($angle + (360 * rotations)); } /** * Rotates a Point around another Point by the specified angle. * * @param $point The Point to rotate * @param $centerPoint The Point to rotate this Point around * @param $angle The angle (in degrees) to rotate this point * * @return void */ public function rotatePoint($point:Point, $centerPoint:Point, $angle:Number):void { var radians:Number = degreesToRadians($angle); var baseX:Number = ($point.x - $centerPoint.x); var baseY:Number = ($point.y - $centerPoint.y); $point.x = ((Math.cos(radians) * baseX) - (Math.sin(radians) * baseY) + $centerPoint.x); $point.y = ((Math.sin(radians) * baseX) + (Math.cos(radians) * baseY) + $centerPoint.y); } //- EVENT HANDLERS ---------------------------------------------------------------------------------------- //- GETTERS & SETTERS ------------------------------------------------------------------------------------- //- HELPERS ----------------------------------------------------------------------------------------------- /** * @private */ public function toString():String { return getQualifiedClassName(this); } //- END CLASS --------------------------------------------------------------------------------------------- } } -------------------------------------------------------------------------------- /deploy/js/swfobject.js: -------------------------------------------------------------------------------- 1 | /* SWFObject v2.2
* The $sliderData object takes the following values: *