topical media & game development

talk show tell print

actionscript-video-com-mosesSupposes-fuse-Shortcuts.ax

actionscript-video-com-mosesSupposes-fuse-Shortcuts.ax [swf] flex


  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 {gray com.mosesSupposes.fuse.ZigoEngine#register} or {gray com.mosesSupposes.fuse.ZigoEngine#simpleSetup} to enable tween-shortcut functionality and 'easyfunc' callback parsing. @usage <pre>import com.mosesSupposes.fuse.*; import mx.transitions.easing.Elastic; ZigoEngine.register(@ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts); ZigoEngine.doShortcut(my_mc, 'brightOffsetTo', 100, 1, Elastic.easeOut);</pre> <br> <pre>import com.mosesSupposes.fuse.*; ZigoEngine.simpleSetup(@ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts, PennerEasing); my_mc.brightOffsetTo(200, 1, 'easeOutElastic');</pre> <br>Shortcut methods are variations on {gray com.mosesSupposes.fuse.ZigoEngine#doTween} syntax and return a formatted string indicating properties successfully tweened. In each method listed below <code>target</code> refers to whatever MovieClip or TextField you wish to tween. <br><br><br> <h3>Property Shortcut Methods:</h3> <pre>target.alphaTo (alpha:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens <code>_alpha</code>. Supports relative (string) end-value. <pre>target.bezierTo (x:Object, y:Object, controlX:Object, controlY:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Generates a simple curved path. Supports relative (string) values; use <code>"0"</code> for <code>x</code> or <code>y</code> to affect no change, use <code>null</code> for <code>controlX</code> or <code>controlY</code> 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: <code>my_mc.bezierTo("200","0",null,"-50");</code> <pre>target.fadeIn (seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Automatically sets the target's <code>_visible</code> property to true, then tweens <code>_alpha</code> to 100. <pre>target.fadeOut (seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens <code>_alpha</code> to 0 then automatically sets the target's <code>_visible</code> property to false. <pre>target.frameTo (frame:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> MovieClip only: tweens the clip's timeline to the desired frame. <pre>target.rotateTo (rotation:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens <code>_rotation</code>. Supports relative (string) end-value, such as this counter-clockwise rotation: <code>my_mc.rotateTo("-90");</code> <pre>target.scaleTo (scale:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens <code>_xscale</code> and <code>_yscale</code> to the same value. Supports relative (string) end-value. <pre>target.sizeTo (size:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens <code>_width</code> and <code>_height</code> to the same value. Supports relative (string) end-value. <pre>target.slideTo (x:Object, y:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens <code>_x</code> and <code>_y</code>. Supports relative (string) values; use <code>"0"</code> or <code>null</code> to affect no change for either coordinate. <br><br> <h3>Color Shortcut Methods:</h3> <pre>target.brightnessTo (brightness:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens brightness between -100 (black), 0 (normal) and 100 (white) <pre>target.brightOffsetTo (brightOffset:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens a burn effect between -100 (black), 0 (normal) and 100 (white) <pre>target.colorTo (rgb:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens a clip's color. Accepts 0x000000 or "#000000" formats. <pre>target.colorResetTo (percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Resets a color-transformed clip in a range between 0 (no change from current transform) and 100 (full reset) <pre>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</pre> Tweens specific properties of a color-transform. Supports relative (string) values or pass <code>null</code> to affect no change on that property. The "a" values are percentages while "b" values are -255 to 255 offsets. <pre>target.contrastTo (level:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens photo contrast between 0 (gray), 100 (normal), or higher (200 for extreme contrast, higher to posterize image). Supports relative (string) end-value. <pre>target.invertColorTo (percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Photo-negative effect from 0-100. Supports relative (string) end-value. <pre>target.tintTo (rgb:Object, percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Similar to <code>colorTo</code>, with a tint-percentage value in the second parameter. Supports relative (string) end-value for percentage. <pre>target.tintPercentTo (percent:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> Tweens the tint percentage of a target that has had its color altered previously. Supports relative (string) end-value. <br><br> <h3>Tween Methods:</h3> (see similar methods in {gray com.mosesSupposes.fuse.ZigoEngine} for additional info.) <pre>target.tween (props:Object, endVals:Object, seconds:Number, ease:Object, delay:Number, callback:Object):String</pre> <pre>target.removeTween (props:Object):Void</pre> <pre>target.removeAllTweens ():Void</pre> <pre>target.isTweening (prop:String):Boolean</pre> <pre>target.getTweens():Number</pre> <pre>target.lockTween():Void</pre> <pre>target.unlockTween():Void</pre> <pre>target.isTweenLocked():Boolean</pre> <pre>target.isTweenPaused(prop:String):Boolean</pre> <pre>target.pauseTween (props:Object):Void</pre> <pre>target.resumeTween (props:Object):Void</pre> <pre>target.pauseAllTweens ():Void</pre> <pre>target.resumeAllTweens ():Void</pre> <pre>target.ffTween (props:Object):Void</pre> <pre>target.rewTween (props:Object,suppressStartEvents:Boolean):Void</pre> <pre>target.rewAndPauseTween (props:Object,suppressStartEvents:Boolean):Void</pre> <br><br> <h3>Legacy Methods:</h3> (retained for compatibility with earlier versions) <pre>target.stopTween (props:Object):Void</pre> <pre>target.stopAllTweens ():Void</pre> <pre>target.unpauseTween (props:Object):Void</pre> <pre>target.unpauseAllTweens ():Void</pre> <br><br> <h3>FuseFMP tweening shortcuts</h3><br> For use with FuseFMP and {gray com.mosesSupposes.fuse.ZigoEngine#simpleSetup} (prototype extension) only. The format follows the convention short-filtername+"_"+filter property+"To". <pre> // example: import com.mosesSupposes.fuse.*; ZigoEngine.simpleSetup(@ax-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</pre> <br><br> <h3>Shortcut Properties:</h3><br> If you've extended prototypes with {gray com.mosesSupposes.fuse.ZigoEngine#simpleSetup}, you may use these the same as normal properties like <code>_x</code>: <pre>my_mc._brightness = 50;</pre> <br> <ul> <li><code>_scale</code> Sets _xscale and _yscale to the same value.</li> <li><code>_size</code> Sets _width and _height to the same value.</li> <li><code>_frame</code> Sets or retrieves the current frame of a MovieClip's timeline.</li> <li><code>_tint</code> Accepts 0x000000 or "#000000" formats.<br> Returns a human-readable hex-string like "0xFF33FF", easily converted to a usable color value using <code>Number()</code>.</li> <li><code>_tintPercent</code> Sets or retrieves the tint percentage of a target that has had its color altered previously.</li> <li><code>_brightness</code> (See brightnessTo)</li> <li><code>_brightOffset</code> (See brightOffsetTo)</li> <li><code>_invertColor</code> (See invertColorTo)</li> <li><code>_colorReset</code> (See colorResetTo)</li> <li><code>_contrast</code> (See contrastTo)</li> <li><code>_colorTransform</code> Accepts or returns a generic color-transform object with properties like ra, rb, etc. (See colorTransformTo)</li> </ul> <br><br> <h3>FuseFMP Shortcut Properties</h3><br> {gray com.mosesSupposes.fuse.FuseFMP} property formatting follows the convention: short-filtername+"_"+filter property. <br>Example with {gray com.mosesSupposes.fuse.ZigoEngine#register} (see {gray com.mosesSupposes.fuse.FuseFMP} for more info): <pre>import com.mosesSupposes.fuse.*; import mx.transitions.easing.Elastic; ZigoEngine.register(@ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts, FuseFMP); ZigoEngine.doTween(my_mc, "DropShadow_angle", "45", 2, Elastic.easeOut); </pre> If {gray com.mosesSupposes.fuse.ZigoEngine#simpleSetup} is used you may also get/set properties directly on a target: <pre>my_mc.DropShadow_angle = 105;</pre> (Note that this is an optional feature of {gray com.mosesSupposes.fuse.FuseFMP} that may be used without ZigoEngine.) <br><br> <i>Methods and properties of this class are excluded here - see class file for further documentation.</i> @author Moses Gunesch / MosesSupposes.com (shortcut syntax created by Zeh Fernando, Ladislav Zigo, others) @version 2.0

  
  class com.mosesSupposes.fuse.@ax-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 init@ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts has been called, also called by <code>ZigoEngine.register()</code> to ensure class is imported and retained.

  
          public static function initialize():Void
          {
                  if (shortcuts==null) init@ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts();
          }
          
          
@exclude Enables shortcut syntax with doTween. (This idea thanks to Yotam Laufer)
parameter: obj target of tween
parameter: 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 add@fileTo():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 remove@fileFrom():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 <code>"_root.gotoAndStop('home');"</code> is parsed, is stored in the @ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts class. If an easyfunc string is passed when @ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts has not been registered, a warning message is thrown.
parameter: callbackStr complete version of the callback
returns: 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<list.length; i++) {
                                  var item:String = list[i];
                                  item = trimWhite(item);
                                  var isObj:Boolean = (item.charAt(0)=='{' && (item.indexOf('}')>-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<list.length; k++) {
                                                  if (k==i) item = item.slice(1);
                                                  var item2:String;
                                                  var isEnd:Boolean = (item2.slice(-1)==((isObj==true) ? '}':']') || k==list.length-1);
                                                  if (isEnd==true) item2 = item2.slice(0,-1);
                                                  if (isObj==true && item2.indexOf(':')>-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 <code>ZigoEngine.do@ax-actionscript-video-com-mosesSupposes-fuse-Shortcuts</code> call.

  
          private static function init@ax-actionscript-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.getAll@ax-actionscript-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));
                  };
          }
  }


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.