import com.mosesSupposes.fuse.ZigoEngine; /** * * The Fuse Kit [beta1.1z3] * Copyright (c) 2006 Moses Gunesch, MosesSupposes.com * * Distributed under MIT Open Source License, see Fuse-Kit-License.html (in fuse package directory) * Easing Equations (c) 2003 Robert Penner used by permission, see PennerEasing * Visit http://www.mosessupposes.com/Fuse * * @ignore * * Pass this class to {@link com.mosesSupposes.fuse.ZigoEngine#register} or {@link com.mosesSupposes.fuse.ZigoEngine#simpleSetup} * to enable tween-shortcut functionality and 'easyfunc' callback parsing. * @usage *
import com.mosesSupposes.fuse.*;
* import mx.transitions.easing.Elastic;
* ZigoEngine.register(actionscript_video_com_mosesSupposes_fuse_Shortcuts);
* ZigoEngine.doShortcut(my_mc, 'brightOffsetTo', 100, 1, Elastic.easeOut);
*
*
import com.mosesSupposes.fuse.*;
* ZigoEngine.simpleSetup(actionscript_video_com_mosesSupposes_fuse_Shortcuts, PennerEasing);
* my_mc.brightOffsetTo(200, 1, 'easeOutElastic');
*
Shortcut methods are variations on {@link com.mosesSupposes.fuse.ZigoEngine#doTween} syntax and return a formatted string indicating properties successfully tweened. * In each method listed below target refers to whatever MovieClip or TextField you wish to tween. *


*

Property Shortcut Methods:

*
target.alphaTo (alpha:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens _alpha. Supports relative (string) end-value. *
target.bezierTo (x:Object, y:Object, controlX:Object, controlY:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Generates a simple curved path. Supports relative (string) values; use "0" for x or y to affect no change, use null for controlX or controlY to auto-center the control point. * In this way a curve can be generated with only two values, like this arc that hops up-then-down while sliding right: my_mc.bezierTo("200","0",null,"-50"); *
target.fadeIn (seconds:Number, ease:Object, delay:Number, callback:Object):String
* Automatically sets the target's _visible property to true, then tweens _alpha to 100. *
target.fadeOut (seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens _alpha to 0 then automatically sets the target's _visible property to false. *
target.frameTo (frame:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* MovieClip only: tweens the clip's timeline to the desired frame. *
target.rotateTo (rotation:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens _rotation. Supports relative (string) end-value, such as this counter-clockwise rotation: my_mc.rotateTo("-90"); *
target.scaleTo (scale:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens _xscale and _yscale to the same value. Supports relative (string) end-value. *
target.sizeTo (size:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens _width and _height to the same value. Supports relative (string) end-value. *
target.slideTo (x:Object, y:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens _x and _y. Supports relative (string) values; use "0" or null to affect no change for either coordinate. *

*

Color Shortcut Methods:

*
target.brightnessTo (brightness:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens brightness between -100 (black), 0 (normal) and 100 (white) *
target.brightOffsetTo (brightOffset:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens a burn effect between -100 (black), 0 (normal) and 100 (white) *
target.colorTo (rgb:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens a clip's color. Accepts 0x000000 or "#000000" formats. *
target.colorResetTo (percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Resets a color-transformed clip in a range between 0 (no change from current transform) and 100 (full reset) *
target.colorTransformTo (ra:Object, rb:Object, ga:Object, gb:Object, ba:Object, bb:Object, aa:Object, ab:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens specific properties of a color-transform. Supports relative (string) values or pass null to affect no change on that property. The "a" values are percentages while "b" values are -255 to 255 offsets. *
target.contrastTo (level:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens photo contrast between 0 (gray), 100 (normal), or higher (200 for extreme contrast, higher to posterize image). Supports relative (string) end-value. *
target.invertColorTo (percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Photo-negative effect from 0-100. Supports relative (string) end-value. *
target.tintTo (rgb:Object, percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Similar to colorTo, with a tint-percentage value in the second parameter. Supports relative (string) end-value for percentage. *
target.tintPercentTo (percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
* Tweens the tint percentage of a target that has had its color altered previously. Supports relative (string) end-value. *

*

Tween Methods:

(see similar methods in {@link com.mosesSupposes.fuse.ZigoEngine} for additional info.) *
target.tween (props:Object, endVals:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String
*
target.removeTween (props:Object):Void
*
target.removeAllTweens ():Void
*
target.isTweening (prop:String):Boolean
*
target.getTweens():Number
*
target.lockTween():Void
*
target.unlockTween():Void
*
target.isTweenLocked():Boolean
*
target.isTweenPaused(prop:String):Boolean
*
target.pauseTween (props:Object):Void
*
target.resumeTween (props:Object):Void
*
target.pauseAllTweens ():Void
*
target.resumeAllTweens ():Void
*
target.ffTween (props:Object):Void
*
target.rewTween (props:Object,suppressStartEvents:Boolean):Void
*
target.rewAndPauseTween (props:Object,suppressStartEvents:Boolean):Void
*

*

Legacy Methods:

(retained for compatibility with earlier versions) *
target.stopTween (props:Object):Void
*
target.stopAllTweens ():Void
*
target.unpauseTween (props:Object):Void
*
target.unpauseAllTweens ():Void
*

*

FuseFMP tweening shortcuts


* For use with FuseFMP and {@link com.mosesSupposes.fuse.ZigoEngine#simpleSetup} (prototype extension) only. * The format follows the convention short-filtername+"_"+filter property+"To". *
* // example:
* import com.mosesSupposes.fuse.*;
* ZigoEngine.simpleSetup(actionscript_video_com_mosesSupposes_fuse_Shortcuts, PennerEasing, FuseFMP);
* my_mc.DropShadow_angleTo("45", 2, "easeOutElastic");
* 
* Bevel_angleTo
* Bevel_blurTo
* Bevel_blurXTo
* Bevel_blurYTo
* Bevel_distanceTo
* Bevel_highlightAlphaTo
* Bevel_shadowAlphaTo
* Bevel_strengthTo
* Blur_blurTo
* Blur_blurXTo
* Blur_blurYTo
* Convolution_alphaTo
* Convolution_colorTo
* DisplacementMap_alphaTo
* DisplacementMap_colorTo
* DropShadow_alphaTo
* DropShadow_angleTo
* DropShadow_blurTo
* DropShadow_blurXTo
* DropShadow_blurYTo
* DropShadow_colorTo
* DropShadow_distanceTo
* DropShadow_strengthTo
* Glow_alphaTo
* Glow_blurTo
* Glow_blurXTo
* Glow_blurYTo
* Glow_colorTo
* Glow_strengthTo
* GradientBevel_angleTo
* GradientBevel_blurTo
* GradientBevel_blurXTo
* GradientBevel_blurYTo
* GradientBevel_distanceTo
* GradientBevel_strengthTo
* GradientGlow_angleTo
* GradientGlow_blurTo
* GradientGlow_blurXTo
* GradientGlow_blurYTo
* GradientGlow_distanceTo
* GradientGlow_strengthTo
*

*

Shortcut Properties:


* If you've extended prototypes with {@link com.mosesSupposes.fuse.ZigoEngine#simpleSetup}, you may use these the same as normal properties like _x: *
my_mc._brightness = 50;
*
* *

*

FuseFMP Shortcut Properties


* {@link com.mosesSupposes.fuse.FuseFMP} property formatting follows the convention: short-filtername+"_"+filter property. *
Example with {@link com.mosesSupposes.fuse.ZigoEngine#register} (see {@link com.mosesSupposes.fuse.FuseFMP} for more info): *
import com.mosesSupposes.fuse.*;
* import mx.transitions.easing.Elastic;
* ZigoEngine.register(actionscript_video_com_mosesSupposes_fuse_Shortcuts, FuseFMP);
* ZigoEngine.doTween(my_mc, "DropShadow_angle", "45", 2, Elastic.easeOut);
* 
* If {@link com.mosesSupposes.fuse.ZigoEngine#simpleSetup} is used you may also get/set properties directly on a target: *
my_mc.DropShadow_angle = 105;
* (Note that this is an optional feature of {@link com.mosesSupposes.fuse.FuseFMP} that may be used without ZigoEngine.) * *

* Methods and properties of this class are excluded here - see class file for further documentation. * @author Moses Gunesch / MosesSupposes.com (shortcut syntax created by Zeh Fernando, Ladislav Zigo, others) * @version 2.0 */ class com.mosesSupposes.fuse.actionscript_video_com_mosesSupposes_fuse_Shortcuts { /** * @exclude * Unique identifier used by ZigoEngine.register */ public static var registryKey:String = 'shortcuts'; /** * @exclude * An internal memory object that stores all shortcut methods & properties for quick access. */ public static var shortcuts:Object = null; /** * @exclude * An internal memory object that stores all MovieClip-specific shortcut methods & properties for quick access. */ public static var mcshortcuts:Object = null; /** * @exclude * A relay that ensures initactionscript_video_com_mosesSupposes_fuse_Shortcuts has been called, also called by ZigoEngine.register() to ensure class is imported and retained. */ public static function initialize():Void { if (shortcuts==null) initactionscript_video_com_mosesSupposes_fuse_Shortcuts(); } /** * @exclude * Enables shortcut syntax with doTween. (This idea thanks to Yotam Laufer) * @param obj target of tween * @param methodName method type to tween */ public static function doShortcut(obj:Object, methodName:String):String { initialize(); var s:Function = shortcuts[methodName]; if (s==undefined) { if (typeof obj=='movieclip') s = mcshortcuts[methodName]; } if (s==undefined) return null; obj = arguments.shift(); methodName = String(arguments.shift()); if (!(obj instanceof Array)) obj = [obj]; var propsAdded:String = ''; for (var i:String in obj) { var pa:String = String((s.apply(obj[i], arguments))); if (pa!=null && pa.length>0) { if (propsAdded.length>0) propsAdded=(pa+'|'+propsAdded); else propsAdded = pa; } } return ((propsAdded=='') ? null : propsAdded); } /** * @exclude * ZigoEngine uses this method to graft shortcut methods and properties into one or more target objects. * @params accepts any number of target objects */ public static function addactionscript_video_com_mosesSupposes_fuse_ShortcutsTo():Void { initialize(); var doadd:Function = function(o:Object,so:Object) { for (var j:String in so) { var item:Object = so[j]; if (item.getter || item.setter) { o.addProperty(j, item.getter, item.setter); _global.ASSetPropFlags(o, j, 3, 1); // must remain overwritable for direct initialization of individual targets. } else { o[j] = item; _global.ASSetPropFlags(o, j, 7, 1); } } }; for (var i:String in arguments) { var obj:Object = arguments[i]; // add MovieClip-only shortcuts if (obj==MovieClip.prototype || typeof obj=='movieclip') { doadd(obj,mcshortcuts); } doadd(obj,shortcuts); } } /** * @exclude * ZigoEngine uses this method to strip shortcut methods and properties from one or more target objects. * @params accepts any number of target objects */ public static function removeactionscript_video_com_mosesSupposes_fuse_ShortcutsFrom():Void { initialize(); var doremove:Function = function(o:Object,so:Object):Void { for (var j:String in so) { _global.ASSetPropFlags(o, j, 0, 2); // 0,2 is NOT a mistake, do not change var item:Object = so[j]; if (item.getter || item.setter) { o.addProperty(j,null,null); } delete o[j]; } }; for (var i:String in arguments) { var obj:Object = arguments[i]; // remove MovieClip-only shortcuts if (obj==MovieClip.prototype || typeof obj=='movieclip') { doremove(obj,mcshortcuts); } doremove(obj,shortcuts); } } /** * @exclude * The "easyfunc" syntax feature of the Kit, in which a string version of a complete callback like "_root.gotoAndStop('home');" is parsed, is stored in the actionscript_video_com_mosesSupposes_fuse_Shortcuts class. If an easyfunc string is passed when actionscript_video_com_mosesSupposes_fuse_Shortcuts has not been registered, a warning message is thrown. * @param callbackStr complete version of the callback * @return object */ public static function parseStringTypeCallback(callbackStr:String):Object { var evaluate:Function = function(val:String):Object { var first:String = val.charAt(0); if (first==val.slice(-1) && (first=='"' || first=="'")) return val.slice(1,-1); // retain quoted values as strings if (val=='true') return Object(true); if (val=='false') return Object(false); if (val=='null') return Object(null); if (_global.isNaN(Number(val))==false) return Object(Number(val)); return Object(eval(val)); // otherwise assume it's an expression, use eval to convert. }; var trimWhite:Function = function(str:String):String { while(str.charAt(0)==' ') str = str.slice(1); while(str.slice(-1)==' ') str = str.slice(0,-1); return str; }; var evaluateList:Function = function(list:Array):Array { var newlist:Array = []; for (var i:Number=0; i-1 || item.indexOf(':')>-1)); var isArray:Boolean = (item.charAt(0)=='['); if ((isObj || isArray)==true) { var o:Object = (isObj==true) ? {} : []; for (var k:Number=i; k-1) { var oParts:Array = item2.split(':'); o[trimWhite(oParts[0])] = evaluate(trimWhite(oParts[1])); } else if (isArray==true) { o.push(evaluate(trimWhite(item2))); } if (isEnd==true) { newlist.push(o); i = k; // fake out loop break; } } } else { newlist.push(evaluate(trimWhite(item))); } } return newlist; }; var parts:Array = callbackStr.split( "(" ); var p0:String = parts[0]; var p1:String = parts[1]; return { func:(p0.slice(p0.lastIndexOf(".")+1)), scope:eval(p0.slice(0,p0.lastIndexOf("."))), args:(evaluateList((p1.slice(0, p1.lastIndexOf(")"))).split(","))) }; /* @ignore */ } /** * @exclude * Internal method that writes all shortcuts into a memory object, creating fast access for copying the set or locating a specific method for a ZigoEngine.doactionscript_video_com_mosesSupposes_fuse_Shortcuts call. */ private static function initactionscript_video_com_mosesSupposes_fuse_Shortcuts():Void { shortcuts = (new Object()); var methods:Object = { alphaTo:'_alpha',scaleTo:'_scale',sizeTo:'_size',rotateTo:'_rotation',brightnessTo:'_brightness', brightOffsetTo:'_brightOffset',contrastTo:'_contrast',colorTo:'_tint',tintPercentTo:'_tintPercent', colorResetTo:'_colorReset',invertColorTo:'_invertColor' }; var fmethods:Array = _global.com.mosesSupposes.fuse.FuseFMP.getAllactionscript_video_com_mosesSupposes_fuse_Shortcuts(); // if FMP exists, graft a bunch more shortcuts. var okFmethods:Object = {blur:1,blurX:1,blurY:1,strength:1,shadowAlpha:1,highlightAlpha:1,angle:1,distance:1,alpha:1,color:1}; for (var i:String in fmethods) if (okFmethods[(fmethods[i]).split('_')[1]]===1) methods[fmethods[i]+'To'] = fmethods[i]; var ro:Object = { __resolve:function(name:String):Function { var propName:String = methods[name]; return (function():String { var rs:String = (_global.com.mosesSupposes.fuse.ZigoEngine.doTween.apply(ZigoEngine, ((new Array(this, propName)).concat(arguments)))); return rs; }); } }; var ro2:Object = { __resolve:function(name:String):Object { var prop:String = name.slice(1); var returnObj:Object = { getter:function():Object { return (_global.com.mosesSupposes.fuse.ZigoEngine.getColorKeysObj(this))[prop]; }}; if (prop=='tintString' || prop=='tint') returnObj.setter = function(v:Object){ _global.com.mosesSupposes.fuse.ZigoEngine.setColorByKey(this,'tint',(_global.com.mosesSupposes.fuse.ZigoEngine.getColorKeysObj(this).tintPercent || 100),v); }; else if (prop=='tintPercent') returnObj.setter = function(v:Number){ _global.com.mosesSupposes.fuse.ZigoEngine.setColorByKey(this,'tint',v,_global.com.mosesSupposes.fuse.ZigoEngine.getColorKeysObj(this).tint); }; else if (prop=='colorReset') returnObj.setter = function(v:Number){ var co:Object = _global.com.mosesSupposes.fuse.ZigoEngine.getColorKeysObj(this); _global.com.mosesSupposes.fuse.ZigoEngine.setColorByKey(this,'tint',Math.min(100,Math.max(0,Math.min(co.tintPercent,100-v))),co.tint); }; else returnObj.setter = function(v:Number){ _global.com.mosesSupposes.fuse.ZigoEngine.setColorByKey(this,prop,v); }; return returnObj; } }; for (var i:String in methods) { shortcuts[i] = ro[i]; if (i=='colorTo') shortcuts._tintString = ro2['_tintString']; if (i.indexOf('bright')==0 || i=='contrastTo' || i=='colorTo' || i=='invertColor' || i=='tintPercentTo' || i=='colorResetTo') { shortcuts[methods[i]] = ro2[methods[i]]; } } shortcuts.tween = function(props:Object, endVals:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String { // references the method. if (arguments.length==1 && typeof props=='object') { return (ZigoEngine.doTween({ target:this, action:props })); } return (ZigoEngine.doTween(this, props, endVals, seconds, ease, delay, callback)); }; shortcuts.removeTween = shortcuts.stopTween = function(props:Object):Void { com.mosesSupposes.fuse.ZigoEngine.removeTween(this,props); }; shortcuts.removeAllTweens = shortcuts.stopAllTweens = function():Void { // globally remove all tweens from a clip com.mosesSupposes.fuse.ZigoEngine.removeTween('ALL'); }; shortcuts.isTweening = function(prop:String):Boolean { return ZigoEngine.isTweening(this, prop); }; shortcuts.getTweens = function():Number { return ZigoEngine.getTweens(this); }; shortcuts.lockTween = function():Void { com.mosesSupposes.fuse.ZigoEngine.lockTween(this, true); }; shortcuts.unlockTween = function():Void { com.mosesSupposes.fuse.ZigoEngine.lockTween(this, false); }; shortcuts.isTweenLocked = function():Boolean { return ZigoEngine.isTweenLocked(this); }; shortcuts.isTweenPaused = function(prop:String):Boolean { return ZigoEngine.isTweenPaused(this, prop); }; shortcuts.pauseTween = function(props:Object):Void { com.mosesSupposes.fuse.ZigoEngine.pauseTween(this,props); }; shortcuts.resumeTween = shortcuts.unpauseTween = function(props:Object):Void { com.mosesSupposes.fuse.ZigoEngine.unpauseTween(this,props); }; shortcuts.pauseAllTweens = function():Void { // globally pause all tweens from a clip com.mosesSupposes.fuse.ZigoEngine.pauseTween('ALL'); }; shortcuts.resumeAllTweens = shortcuts.unpauseAllTweens = function():Void { // globally unpause all tweens from a clip com.mosesSupposes.fuse.ZigoEngine.unpauseTween('ALL'); }; shortcuts.ffTween = function(props:Object):Void { com.mosesSupposes.fuse.ZigoEngine.ffTween(this,props); }; shortcuts.rewTween = function(props:Object,suppressStartEvents:Boolean):Void { com.mosesSupposes.fuse.ZigoEngine.rewTween(this,props,false,suppressStartEvents); }; shortcuts.rewAndPauseTween = function(props:Object,suppressStartEvents:Boolean):Void { com.mosesSupposes.fuse.ZigoEngine.rewTween(this,props,true,suppressStartEvents); }; // Special fadeIn & fadeOut shortcuts toggle the target's _visible property when alpha is at 0. shortcuts.fadeIn = function(seconds:Number, ease:Object, delay:Number, callback:Object):String { (this)._visible = true; return (ZigoEngine.doTween(this, '_alpha', 100, seconds, ease, delay)); }; shortcuts.fadeOut = function(seconds:Number, ease:Object, delay:Number, callback:Object):String { // create a hidden listener object instead of blocking out the callback. if ((this).__fadeOutEnd==undefined) { (this).__fadeOutEnd = { __owner:this, onTweenEnd : function(o:Object):Void { (this).onTweenInterrupt(o); if (String((o.props).join(',')).indexOf('_alpha')>-1 && (this).__owner._alpha<1) { ((o.target)._visible = false); } }, onTweenInterrupt : function(o:Object):Void { if (o.target==(this).__owner && String((o.props).join(',')).indexOf('_alpha')>-1) { (this).__owner.removeListener(this); com.mosesSupposes.fuse.ZigoEngine.removeListener(this); } } }; _global.ASSetPropFlags((this), '__fadeOutEnd', 7, 1); } (this).addListener((this).__fadeOutEnd); var propsAdded:String = (ZigoEngine.doTween(this, '_alpha', 0, seconds, ease, delay, callback)); ZigoEngine.addListener((this).__fadeOutEnd); // do not listen for interrupt until tween is added, in case another fade on this target was running. return propsAdded; }; shortcuts.bezierTo = function(destX:Object, destY:Object, controlX:Object, controlY:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String { return (ZigoEngine.doTween(this, '_bezier_', {x:destX,y:destY,controlX:controlX,controlY:controlY}, seconds, ease, delay, callback)); }; shortcuts.colorTransformTo = function(ra:Object, rb:Object, ga:Object, gb:Object, ba:Object, bb:Object, aa:Object, ab:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String { return (ZigoEngine.doTween(this, '_colorTransform',{ra:ra, rb:rb, ga:ga, gb:gb, ba:ba, bb:bb, aa:aa, ab:ab}, seconds, ease, delay, callback)); }; shortcuts.tintTo = function(rgb:Object, percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String { var o:Object = {}; o.rgb = arguments.shift(); o.percent = arguments.shift(); return (ZigoEngine.doTween(this, '_tint', {tint:rgb,percent:percent}, seconds, ease, delay, callback)); }; shortcuts.slideTo = function(destX:Object, destY:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String { return (ZigoEngine.doTween(this, '_x,_y', [destX,destY], seconds, ease, delay, callback)); }; shortcuts._size = { getter:function():Number { return (((this)._width==(this)._height) ? (this)._width : null); }, setter:function(v:Number):Void { com.mosesSupposes.fuse.ZigoEngine.doTween((this),'_size',v,0); } }; shortcuts._scale = { getter:function():Number { return (((this)._xscale==(this)._yscale) ? (this)._xscale : null); }, setter:function(v:Number):Void { com.mosesSupposes.fuse.ZigoEngine.doTween((this),'_scale',v,0); } }; mcshortcuts = (new Object()); mcshortcuts._frame = { getter:function():Number { return (this)._currentframe; }, setter:function(v:Number) { (this).gotoAndStop(Math.round(v)); } }; mcshortcuts.frameTo = function(endframe:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String { return (ZigoEngine.doTween((this), "_frame", ((endframe!=undefined) ? endframe : (this)._totalframes), seconds, ease, delay, callback)); }; } }