actionscript-video-com-mosesSupposes-fuse-FuseFMP.ax [swf] flex
* 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 * * Provides easy Flash8 BitmapFilter handling. Can be used as a standalone utility or in conjunction with ZigoEngine & Fuse to animate filters.<br> * <br> * @usage * @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP uses a unique naming convention for addressing BitmapFilter properties:<br> * <i>short-filtername+"_"+filterprop</i><br> * <code>DropShadow_distance</code><br> * <code>Bevel_angle</code><br> * etc.<br> * <br> * Such pseudonyms are used in various management methods like {gray #setFilterProps}.<br> * <br>For a complete list of @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP properties call {gray com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP#getAllShortcuts} or {gray com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP#traceAllFilters}.<br> * <br> * @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP also supports its own optional Shortcuts functionality, which writes all of these pseudo-props into targets or prototypes. * This enables the getting and setting of BitmapFilter properties directly on targets, such as <code>my_mc.Blur_blurX = 10;</code> and, * if using ZigoEngine, tween shortcuts like <code>my_mc.Blur_blurXTo(10);</code>.<br> * For a complete list of @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP tweening methods see {gray com.mosesSupposes.fuse.Shortcuts} documentation.<br> * If you're using @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP without ZigoEngine and want to extend prototypes use {gray #simpleSetup}, or if you want to add & remove * shortcuts on specific targets use {gray #initialize} & {gray #deinitialize}.<br> * <br> * @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP pseudo-properties are also directly tweenable in ZigoEngine and Fuse once registered:<br> * <code>ZigoEngine.doTween(my_mc, "DropShadow_angle", "-25");<br> * Fuse.push({ DropShadow_angle:"-25" });</code> * * @author Moses Gunesch / MosesSupposes.com / Based on FMP 1.0 by Danilo Sandner & Björn Wibben * @version 2.0
* @exclude * Unique identifier used by ZigoEngine.register
* Enables kit version to be retrieved at runtime or when reviewing a decompiled swf.
* Extends MC, Button & TF prototypes with @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP shortcuts. * @description This enables the getting and setting of BitmapFilter properties directly on targets, using the convention short-filtername+"_"+filterprop. * <br><br>For a complete list of shortcut properties call {gray com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP#getAllShortcuts} or {gray com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP#traceAllFilters}.<br><br> * Also sets _global references to @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP and all filter classes so timeline coders can avoid using import statements.<br><br> * Note that you do not need to call this method if you're using {gray com.mosesSupposes.fuse.ZigoEngine#simpleSetup}, it will be called automatically. *
see: com.mosesSupposes.fuse.ZigoEngine#simpleSetup * @see com.mosesSupposes.fuse.ZigoEngine#register */ public static function simpleSetup() : Void { initialize(MovieClip.prototype, Button.prototype, TextField.prototype); _global.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP = @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP; for (var i:String in fclasses[i]; } } /** * Internal; Ensures import */ private static var shortcuts:Object; /** * Internal; resolve object for shortcut getters */ private static var sro:Object; /** * Adds shortcuts to all target objects passed. * @description This enables the getting and setting of BitmapFilter properties directly on targets, using the convention short-filtername+"_"+filterprop. *
For a complete list of shortcut properties call {gray com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP#getAllShortcuts} or {gray com.mosesSupposes.fuse.@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP#traceAllFilters}.
* @param accepts one or more MovieClips, TextFields, or Buttons to initialize with shortcuts. * @see #deinitialize */ public static function initialize(target:Object):Void { if (shortcuts = {getFilterName:function (f:BitmapFilter):String { return @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.getFilterName(f); }, getFilterIndex:function (f:Object):Number { return @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.getFilterIndex(this, f); }, getFilter:function (f:Object, createNew:Boolean):BitmapFilter { return @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.getFilter(this, f, createNew); }, writeFilter:function (f:Object, pObj:Object):Number { return @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.writeFilter(this, f, pObj); }, removeFilter:function (f:Object):Boolean { return @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.removeFilter(this, f); }, getFilterProp:function (prop:String, createNew:Boolean) { return @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.getFilterProp(this, prop, createNew); }, setFilterProp:function (prop:String, v:Object):Void { @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProp(this, prop, v); }, setFilterProps:function (fOrPObj:Object, pObj:Object):Void { @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProps(this, fOrPObj, pObj); }, traceAllFilters:function ():Void { @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.traceAllFilters(); }}; gro = {__resolve:function (name:String):Function { var f:Function = function ():BitmapFilter { var local:Object = this; if (local['filters'] != undefined) { var splitname[1] == 'blur') { splitname[0]+"Filter", false)[sro = {__resolve:function (name:String):Function { var f:Function = function (val:Object) { var local:Object = this; if (local['filters'] != undefined) { @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProp(this, name, val); } }; return f; }}; } if (arguments[0] == null) { return; } // make sure only filterable targets are initialized! var valid:Array = [MovieClip, Button, TextField]; for (var i:String in arguments) { var ok:Boolean = false; for (var j:String in valid) { if (arguments[i] instanceof valid[j] || arguments[i] == Function(valid[j]).prototype) { ok = true; break; } } if (!ok) { FuseKitCommon.error('201', i); continue; } for (var fclasses) { var fclasses[f) { // excluding .clone and any other method encountered if (typeof filtername.substr(0, -6)+"_"+b; (arguments[i]).addProperty(eigenschaft, sro[eigenschaft]); // must remain overwritable for direct initialization of individual targets. _global.ASSetPropFlags(arguments[i], eigenschaft, 3, 1); if (b == 'blurX') { eigenschaft = eigenschaft.slice(0, -1); (arguments[i]).addProperty(eigenschaft, sro[eigenschaft]); _global.ASSetPropFlags(arguments[i], eigenschaft, 3, 1); } } } for (var s:String in shortcuts[s]; _global.ASSetPropFlags(arguments[i], s, 7, 1); } } } /** * Removes shortcuts from specific targets or from MC, Button & TF prototypes if no targets are passed. * @param accepts one or more MovieClips, TextFields, or Buttons to strip FusFMP shortcuts from, or pass nothing/null to undo {gray #simpleSetup}. * @see #initialize */ public static function deinitialize():Void { if (filtername:String in f:BitmapFilter = new (filtername])(); for (var b:String in f[b] == 'function') { continue; } var eigenschaft:String = shortcuts) { // 0,2 is NOT a mistake, do not change _global.ASSetPropFlags(arguments[i], s, 0, 2); delete (arguments[i])[s]; } } } /** * Quick way to get a filter instance's class name. * @description *// list filter in my_mc by name to output window * for (var i:String in my_mc.filters) { * trace( @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.getFilterName(my_mc.filters[i]) ); * }* @param myFilter:BitmapFilter):String { if (fclasses) { if (fclasses[a]).prototype) { return a; } } return null; } /** * Gets current filter index. * @param myFilter BitmapFilter instance, String (like "BlurFilter" or "Blur"), or class constructor * @return index of filter in filters Array or -1 if filter doesn't exist. * @see #getFilter */ public static function getFilterIndex(myFilter:Object):Number { if (myFilter = myFilter); if (filters_temp:Array = filters_temp.length; i++) { if ((myFilter.__proto__) { return i; } } return -1; } /** * Returns an existing filter from targ's filters Array or null if doesn't exist, or usecreateNew
if you want a new instance to be created regardless. * @param myFilter BitmapFilter instance, String (like "BlurFilter" or "Blur"), or class constructor * @param obj:Object, createNew:Boolean):BitmapFilter { var obj, index == -1) { if (index = writeFilter(myFilter); if (obj.filters[obj target filter's parent * @param propsObj optional, a generic object customizing the new filter, like{blurX:50,quality:1}
* @return index in target's filters array (or -1 if fails) * @see #removeFilter * @see #getFilterProp * @see #setFilterProp * @see #setFilterProps */ public static function writeFilter(myFilter:Object, fclasses == undefined) { initialize(null); } getInstance(myFilter === null) { return -1; } var obj.filters; var obj, index == -1) { myFilter); } else { index] = obj.filters = propsObj == 'object') { setFilterProps(myFilter, index = getFilterIndex(myFilter); return (obj target filter's parent * @param obj:Object, fclasses == undefined) { initialize(null); } getInstance(filters_temp:Array = index:Number = getFilterIndex(myFilter); if (filters_temp.splice(obj.filters = obj target filter's parent * @param createNew Boolean variable to set whether or not to create new filter instance * @return the value of the property, usually a number * @see #writeFilter * @see #getFilterProp * @see #setFilterProp * @see #setFilterProps */ public static function getFilterProp(filtername:String, splitname:Array = splitname[1] == 'blur') { obj, createNew)[obj target filter's parent * @param val Properties and values * @description Support for multiple targets and multiple properties. There are two distinct syntaxes.
examples:@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProps([my_mc,my_txt], { Blur_blurX:50, Bevel_blurX:1 }); // multiple targs, multiple filters * @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProps(my_mc, 'Blur', { blurX:50, blurY:0, quality:3 }); // write a customized blur filter to my_mc
* @see #getFilterProp * @see #setFilterProps * @see #writeFilter * @see #removeFilter */ public static function setFilterProp(propname:Object, fclasses == undefined) { initialize(null); } var propname.split("_"); var splitname[0]+"Filter"); if (fname] == undefined) { return; } var fclasses[prop:String = index:Number = (index>-1) { var obj.filters[f.__proto__ == filter = prop == 'blur') { val; val; } else { if (val == 'string' && val.charAt(0) == '#') { val.slice(1); } val.charAt(1)).toLowerCase() != 'x') ? Number('0x'+val); } } prop] = index == -1) { filter]; } else { var obj.filters; index] = obj.filters = obj target filter's parent * @param val Properties and values * @description Support for multiple targets and multiple properties. There are two distinct syntaxes.
examples:@ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProps([my_mc,my_txt], { Blur_blurX:50, Bevel_blurX:1 }); // multiple targs, multiple filters * @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP.setFilterProps(my_mc, 'Blur', { blurX:50, blurY:0, quality:3 }); // write a customized blur filter to my_mc
* @see #getFilterProp * @see #setFilterProp * @see #writeFilter * @see #removeFilter */ public static function setFilterProps(filterOrPropsObj:Object, fclasses == undefined) { initialize(null); } if (!(obj = [fo:Object = new Object(); var val:Object; if (arguments.length == 3) { // 2nd param filter, 3rd param short names like blur for (var i:String in filter:BitmapFilter = getFilter(filterOrPropsObj, true); // param3:createNew if (prefix:String = getFilterName(prop in fo[propsObj[prop in val = prop]; if (prefix) == 0) { prop.slice(prop == 'blur') { BlurFilter(val); BlurFilter(val); } else if (prop.charAt(2) != 'l' && typeof val.charAt(0) == '#') { val.slice(1); } val.charAt(1)).toLowerCase() != 'x') ? Number('0x'+val); } else { prop] = obj[i], filterOrPropsObj == 'object') { // 2 params. obj contains long names like Blur_blur filterOrPropsObj; for (propsObj) { // organize all props passed by filter class names var prop.split("_"); var splitname[0]+"Filter"; if (fname] == undefined) { continue; } if (fname] == undefined) { fname] = {}; } if (fo[propsObj[fo[propsObj[fo[splitname[1]] = prop]; } } for (var i:String in fname:String in filter:BitmapFilter = getFilter(fname, true); // param3:createNew if (prop in fname]) { fo[prop]; if (prop.charAt(2) != 'l' && typeof val.charAt(0) == '#') { val.slice(1); } val.charAt(1)).toLowerCase() != 'x') ? Number('0x'+val); } prop] = obj[i], fclasses == undefined) { initialize(null); } var fa:Array = []; for (var fclasses) { var fclasses[f) { if (typeof filtername.substr(0, -6)+'_'+b); if (b == 'blurX') { fa.push(fclasses == undefined) { initialize(null); } var s:String = "------ @ax-actionscript-video-com-mosesSupposes-fuse-FuseFMP filter properties ------\n"; for (var fclasses) { s += (f:BitmapFilter = new (filtername])(); for (var b:String in f[b] == 'function') { continue; } // excluding .clone and any other method encountered s += (' - '+filtername.substr(0, -6)+'_blur'); } // show "_blur" props } s += '\n'; } FuseKitCommon.output(s); } /** * Internal - generates or returns existing BitmapFilter based on input type: constructor, instance, long/short-name string */ private static function myFilter:Object):BitmapFilter { if (myFilter); } if (typeof fclasses) { if (fclasses[j]) { return (new (myFilter == "string") { var myFilter); if (filterStr += 'Filter'; } // allow string to omit 'Filter'. for (var j:String in filterStr) { return (new (