Posts Tagged ‘ Class ’

New Flex 4, Spark Classes to be known

Flex4 Framework
spark.effects.AddAction
spark.effects.Animate
spark.effects.AnimateColor
spark.effects.AnimateFilter
spark.effects.AnimateTransitionShader
spark.effects.AnimateTransform
spark.effects.AnimateTransform3D
spark.effects.animation.Animation

mx.collections.ArrayList
spark.filters.BevelFilter
spark.primitives.BitmapImage
spark.layouts.supportclasses.Block
spark.filters.BlurFilter
spark.components.BorderContainer
spark.effects.easing.Bounce

spark.components.supportclasses.ButtonBarHorizontalLayout
spark.components.supportclasses.ButtonBase
spark.effects.CallAction
spark.components.CheckBox
spark.filters.ColorMatrixFilter
flash.geom.ColorTransform
spark.layouts.ColumnAlign
spark.components.ComboBox
spark.filters.ConvolutionFilter
spark.effects.CrossFade

spark.components.DataRenderer
spark.filters.DisplacementMapFilter

spark.layouts.supportclasses.DropLocation
spark.filters.DropShadowFilter
spark.components.mediaclasses.DynamicStreamingVideoSource
spark.components.mediaclasses.DynamicStreamingVideoItem
spark.effects.easing.Elastic
spark.primitives.Ellipse
spark.effects.Fade
spark.primitives.supportclasses.FilledElement
spark.filters.GlowFilter
spark.filters.GradientBevelFilter
spark.filters.GradientFilter
spark.filters.GradientGlowFilter
spark.primitives.Graphic
spark.primitives.supportclasses.GraphicElement

spark.components.supportclasses.GroupBase

spark.effects.interpolation.HSBInterpolator
spark.components.HScrollBar

spark.components.supportclasses.ItemRenderer
spark.effects.animation.Keyframe

spark.layouts.supportclasses.LayoutBase
spark.primitives.Line
spark.effects.easing.Linear

spark.components.supportclasses.ListBase
spark.core.MaskType
flash.geom.Matrix
flash.geom.Matrix3D
spark.effects.animation.MotionPath
spark.effects.Move
spark.effects.Move3D
spark.effects.interpolation.MultiValueInterpolator
spark.components.mediaclasses.MuteButton
spark.components.NavigatorContent
spark.effects.interpolation.NumberInterpolator

spark.primitives.Path
spark.components.PopUpAnchor
spark.components.PopUpPosition
spark.effects.easing.Power

spark.components.supportclasses.Range
spark.primitives.Rect
spark.primitives.RectangularDropShadow
mx.collections.AsyncListView
spark.effects.RemoveAction
spark.effects.Resize
spark.effects.interpolation.RGBInterpolator
spark.components.RichEditableText
spark.components.RichText
spark.effects.Rotate
spark.effects.Rotate3D
spark.layouts.RowAlign
spark.effects.Scale
spark.effects.Scale3D
spark.components.supportclasses.ScrollBarBase
spark.components.Scroller
spark.components.supportclasses.ScrollerLayout
spark.components.mediaclasses.ScrubBar
spark.effects.SetAction
spark.filters.ShaderFilter
spark.effects.animation.SimpleMotionPath
spark.effects.easing.Sine
spark.components.supportclasses.Skin
spark.components.supportclasses.SkinnableComponent
spark.components.SkinnableContainer
spark.components.supportclasses.SkinnableContainerBase
spark.components.SkinnableDataContainer
spark.components.supportclasses.SkinnableTextBase
spark.components.supportclasses.SliderBase
spark.skins.SparkSkin
spark.components.Spinner
spark.core.SpriteVisualElement
spark.primitives.supportclasses.StrokedElement
spark.components.TabBar

spark.components.supportclasses.TextBase

spark.components.TextSelectionHighlighting
spark.utils.TextUtil
spark.components.TileGroup
spark.layouts.TileLayout
spark.layouts.TileOrientation
spark.effects.animation.Timeline
spark.components.TitleWindow
spark.components.ToggleButton
spark.components.supportclasses.ToggleButtonBase
spark.components.supportclasses.TrackBase
mx.geom.Transform
mx.geom.TransformOffsets
spark.components.VideoDisplay
spark.components.VideoPlayer
spark.components.mediaclasses.VolumeBar
spark.effects.Wipe
mx.collections.XMLListCollection

Special Components
mx.states.AddItems

airframework
spark.components.windowclasses.TitleBar

FTE text for MX components
mx.controls.dataGridclasses.FTEDataGridItemRenderer
mx.controls.MXFTETextInput
mx.controls.advancedDataGridclasses.FTEAdvancedDataGridItemRenderer

Text Layout Framework (TLF)
flashx.textLayout.elements.LinkElement
flashx.textLayout.elements.BreakElement
flashx.textLayout.elements.DivElement
flashx.textLayout.elements.InlineGraphicElement
flashx.textLayout.elements.ParagraphElement
flashx.textLayout.elements.SpanElement
flashx.textLayout.elements.TabElement
flashx.textLayout.elements.TCYElement
flashx.textLayout.elements.TextFlow
flashx.textLayout.formats.TextLayoutFormat


mx.rpc.CallResponder
mx.messaging.channels.HTTPChannel
mx.rpc.remoting.mxml.Operation
mx.messaging.channels.SecureHTTPChannel
mx.messaging.channels.SecureStreamingHTTPChannel
mx.messaging.channels.SecureRTMPChannel
mx.messaging.channels.StreamingHTTPChannel

Flex 3 Graphics
mx.geom.CompoundTransform
mx.graphics.GradientEntry
mx.graphics.LinearGradient
mx.graphics.LinearGradientStroke
mx.graphics.RadialGradient
mx.graphics.RadialGradientStroke
mx.graphics.SolidColor
mx.graphics.SolidColorStroke
mx.graphics.Stroke
mx.geom.Transform

Flex 3 Miscellaneous
mx.logging.targets.MiniDebugTarget
mx.logging.targets.TraceTarget

MXItemRenderer
mx.controls.listclasses.MXItemRenderer
mx.controls.treeclasses.MXTreeItemRenderer
mx.controls.dataGridclasses.MXDataGridItemRenderer
mx.controls.advancedDataGridclasses.MXAdvancedDataGridItemRenderer

Advertisements

Dotted Line Util

Dotted Line, Utility Class for AS3 

package {
import flash.display.Graphics;
import flash.geom.Point;
public class DotLine{
public function DotLine( target:Graphics, seg:Number=20, xx:Number=0, yy:Number=0 ):void{
this.target = target;
this.now = new Point( xx, yy );
this.seg = seg;
this.rest = 0;
this.flag = false;
}
public var target : Graphics;
public var seg : Number;
public var now :  Point;
public var rest : Number;
public var flag : Boolean;
public function dotLineTo( xx:Number, yy:Number ):void{
var s: Point = new Point( now.x, now.y );
var e: Point = new Point( xx, yy );
var d:Number = Point.distance( s, e );
now.x = e.x;
now.y = e.y;
rest = (seg * 1 < rest) ? rest – seg * Math.floor( rest / seg ) : rest;
if(d <= rest){
rest -= d;
if(flag){
target.lineTo( e.x, e.y );
flag = (rest == 0) ? false : true;
}
else{
target.moveTo( e.x, e.y );
flag = (rest == 0) ? true : false;
}
return void;
}

var m:Number = 1 / ( d / seg );
var n:Number = 1 / ( d / rest );

for( var i:Number=1-n; 0<i; i-=m ){
var a: Point = Point.interpolate( s, e, i );
if(flag){
target.lineTo( a.x, a.y );
flag = false;
}
else{
target.moveTo( a.x, a.y );
flag = true;
}
if( i – m < 0 ){
var b: Point = Point.interpolate( s, e, i – m );
var c: Point = Point.interpolate( s, e, 0 );
rest = Point.distance( e, b );
if(flag){
target.lineTo( c.x, c.y );
}
else{
target.moveTo( c.x, c.y );
}
}
}
}

}
}

Collision Detection AS3 Util

Collision Detection Utility class for AS3,

Usage: var collide:Rectangle = checkForCollision(obj1, obj2);

package {
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.DisplayObject;
import flash.display.DisplayObjectContainer;
import flash.geom.Matrix;
import flash.geom.ColorTransform;
import flash.geom.Rectangle;

public class CollisionDetection{

public static function checkForCollision(firstObj: DisplayObject,secondObj: DisplayObject):Rectangle
{
var bounds1:Object = firstObj.getBounds(firstObj.root);
var bounds2:Object = secondObj.getBounds(secondObj.root);

if (((bounds1.right < bounds2.left) || (bounds2.right < bounds1.left)) || ((bounds1.bottom < bounds2.top) || (bounds2.bottom < bounds1.top)) ) {
return null;
}

var bounds:Object = {};
bounds.left = Math.max(bounds1.left,bounds2.left);
bounds.right= Math.min(bounds1.right,bounds2.right);
bounds.top = Math.max(bounds1.top,bounds2.top);
bounds.bottom = Math.min(bounds1.bottom,bounds2.bottom);

var w:Number = bounds.right-bounds.left;
var h:Number = bounds.bottom-bounds.top;

if(w < 1 || h < 1)
{
return null;
}

var bitmapData:BitmapData = new BitmapData(w,h,false);

var matrix:Matrix = firstObj.transform.concatenatedMatrix;
matrix.tx -= bounds.left;
matrix.ty -= bounds.top;
bitmapData.draw(firstObj,matrix,new ColorTransform(1,1,1,1,255,-255,-255,255));

matrix = secondObj.transform.concatenatedMatrix;
matrix.tx -= bounds.left;
matrix.ty -= bounds.top;
bitmapData.draw(secondObj,matrix,new ColorTransform(1,1,1,1,255,255,255,255),BlendMode.DIFFERENCE);

var intersection:Rectangle = bitmapData.getColorBoundsRect(0xFFFFFFFF,0xFF00FFFF);

/*try{
bitmapData.dispose();
}catch(e:Error){}*/

if (intersection.width == 0) { return null; }

intersection.x += bounds.left;
intersection.y += bounds.top;

return intersection;
}
}
}

Execute Commands on queue

The AS3 Utility Class to add commands in a queue, the usage and class is below:

/** 
* var commands : CommandsQueue = new CommandsQueue();
* commands.addCommand( this, myFunc );
* commands.addCommand( this, myFunc2, [0,2], this, Event.COMPLETE );
* commands.execute();
*/
package
{
import flash.events.Event;
import flash.events.EventDispatcher;

public class CommandsQueue extends EventDispatcher
{
protected var commands : Array;
protected var _index : Number = 0;
public var onComplete : Function;

public function CommandsQueue():void
{
commands = [];
}
public function addCommand( thisObj : Object, func : Function, params: Array = null , completeEventDispatcher : Object = null, completeEventName : String= null ) : void
{
commands.push({
thisObj : thisObj,
func : func,
completeEventDispatcher : completeEventDispatcher || thisObj,
completeEventName : completeEventName,
params : params
})
}
public function get progress():Number
{
return (commands.length>0)? _index / commands.length * 100 : 0;
}
public function cancel() : void
{
throw new Error(“commandQueue.cancel is not implemented yet”);
}
public function execute() : void
{
doNext();
}
public function get index():int
{
return _index;
}
public function get length():int
{
return commands.length;
}
protected function doNext() : void
{
var act : Object = commands[ _index ];

if( act.completeEventName ){
act.completeEventDispatcher.addEventListener(act.completeEventName, _commandComplete, false, 0, true);
act.func.apply( act.thisObj, act.params );
} else {
act.func.apply( act.thisObj, act.params );
doNextCommand();
}
}
protected function doNextCommand() : void
{
var act : Object = commands[ _index ];

if( act.completeEventName )
act.completeEventDispatcher.removeEventListener(act.completeEventName, _commandComplete);

_index ++;

if( _index == commands.length )
{
commands = []; //remove all registerd command for GC
if( onComplete != null )
onComplete();
dispatchEvent( new Event(Event.COMPLETE) );
}else{
doNext();
}
}
protected function _commandComplete( e : Event ) : void
{
doNextCommand();
}
}

Loading flash library asset in Flex

The below is the code to load flash library asset (using linkage name) on Flex.

<?xml version=”1.0″ encoding=”utf-8″?>
<mx:Application xmlns:mx=”http://www.adobe.com/2006/mxml&#8221; creationComplete=”onCreationComplete()” >
<mx:Script>
<![CDATA[
import mx.core.UIComponent;
private function onCreationComplete():void{
var swfLoader:Loader = new Loader();
swfLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onSWFLoadComplete);
swfLoader.load(new URLRequest(“flash.swf”));
}
private function onSWFLoadComplete(event:Event):void{
var tempClass:Class = event.target.applicationDomain.getDefinition(“libraryAsset”) as Class;
var movieClip:MovieClip = new tempClass() as MovieClip;
var uiComp:UIComponent = new UIComponent();
uiComp.addChild(movieClip);
addChild(uiComp);
}
]]>
</mx:Script>
</mx:Application>