// ------------------------------------------------------------------------------------------------------------------ // skipCache.as 跳过缓存 /* ************************************************************** * Developed by R.Arul Kumaran [arul@shockwave-india.com] * * for more code keep visiting [www.shockwave-india.com/blog] * ************************************************************** version 1.1 Last updated on 9, Jan 2004 */ /* | Useful when you don't want your server files to be cached by both server and browser | | getSkipCacheString() - Return a blank string("") when the swf is running as a local file and | returns a random string like "?CacheBuster=0.0308893630281091×tamp=1073037565155" | when the swf is from a web server | */ _global.getSkipCacheString = function() { if (getSkipCacheString.isLocalPlayback) { return ""; } dStr = "×tamp="+new Date().getTime(); return "?CacheBuster="+Math.random()+dStr; }; getSkipCacheString.isLocalPlayback = _url.indexOf("file") == 0; /* //sample usage #include "skipCache.as" my_xml = new XML(); my_xml.onData = function(dta) { trace(dta); }; my_xml.load("myfile.xml"+getSkipCacheString()); // ------------------------------------------------------------------------------------------------------------------ // toString.as 打印obj的所有内容 /* ************************************************************ Developed by R.Arul Kumaran [arul@shockwave-india.com] * for more code keep visiting [www.shockwave-india.com/blog] * ************************************************************ version 3.6 Last updated on 12 Oct, 2003 Thanks to Ampre[ampreind@hotmail.com] for the initial improvements to my Object.toAS() code */ /* | Object.toString() - Create a actionscript string for the given object with out circular references | Useful for tracing objects for local and remote debugging | | ActionScript(Object, 'name_of_the_variable') - gets complete reusable actionscript of the Object including circular reference */ _global.ActionScript = function(obj, name) { ActionScript._Dump = []; var str = name+' = '+obj.toString(name)+ActionScript.lineBrake+ActionScript._Dump.join(ActionScript.lineBrake); delete ActionScript._Dump; return str; }; ActionScript.lineBrake = "\n"; ActionScript.spacer = "\t"; ActionScript.makeString = function(t, name, spacer) { var y = typeof (t); switch (y) { case "object" : return (ActionScript.getString(t, name, spacer, t instanceof Array ? 1 : 0)); case "function" : return (ActionScript.getString(t, name, spacer, 2)); case "boolean" : case "number" : return (t); case "string" : return (t.toString()); case "movieclip" : var m = t._target.split('/').join('.'); return (m.length>1 ? '_root'+m : '_root'); default : return (y == '' ? t : y); } }; ActionScript.getString = function(t, name, spacer, mode) { var s = new String(); if(spacer==undefined)spacer=''; t.__name__ = name; t.IsCircularReference = true; ASSetPropFlags(t, "IsCircularReference,__name__", 1); for (var i in t) { var special = false; var l = i.length; while (l--) { var c = i.charAt(l); if ("abcdefghijklmnopqrstuvwxyz0123456789_".indexOf(c.toLowerCase())<0) { special = true; break; } } if (!t[i].IsCircularReference) { if (special) { ActionScript._Dump.push(t.__name__+'[\"'+i+'\"] = '+ActionScript.makeString(t[i], name+'.'+i, spacer+ActionScript.spacer)+';'); } else { switch (mode) { case 0 : //Objects var rS = ActionScript.makeString(t[i], name+'.'+i, spacer+ActionScript.spacer); if (rS != '' && rS != undefined) { s += ActionScript.lineBrake+spacer+ActionScript.spacer+i+':'+rS+", "; } break; default : //Object definition if (isNaN(i)) { var rS = ActionScript.makeString(t[i], name+'.'+i, ''); if (rS != '' && rS != undefined) { ActionScript._Dump.push(t.__name__+'.'+i+' = '+rS+';'); } } } } } else { if (isNaN(i)) { ActionScript._Dump.push(special ? t.__name__+'[\"'+i+'\"] = '+t[i].__name__ : t.__name__+'.'+i+' = '+t[i].__name__+';'); } } } switch (mode) { case 1 : //Array for (var i = 0; i> 16, g:(HEX >> 8) & 0xff, b:HEX & 0xff}; }; /* //Usage:- trace(HexToRGB(0x0c0c0c).r); //traces 12 (the red value) */ /*----------------------------------------------------- //twoDigit: adds "0" in front if the string is only // one digit also useful for converting date time strings */ function twoDigit(str) { return str.length == 1 ? "0"+str : str; } /* //Example:- var myDate = new Date(); var timeStr = twoDigit(myDate.getHours())+twoDigit(myDate.getMinutes()); trace(timeStr); //traces "01:09" */ // ------------------------------------------------------------------------------------------------------------------ // Object-copyProperties.as 对象属性拷贝 /* ************************************************************ Developed by R.Arul Kumaran [arul@shockwave-india.com] * for more code keep visiting [www.shockwave-india.com/blog] * ************************************************************ */ /* | Object.copyProperties(toObj, PropertyStr, exclude?) | | toObj: Object to which properties to be copied | | propertyStr: list of properties to be included or excluded in | "#property1#property2#property3#" format | | exclude: boolean specifies whether to exclude or include the properties | mentioned in the propertyStr */ Object.prototype.copyProperties = function(toObj, propertyStr, exclude) { if (this instanceof Array) { for (var i = 0; i