This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param resource | |
* align the specfied resource to top-left coordinate | |
*/ | |
function handleResetTopLeftPos(resource:Sprite):Sprite{ | |
var s:Sprite = new Sprite(); | |
resource.parent.addChildAt(s, resource.parent.getChildIndex(resource)); | |
s.addChild(resource.parent.removeChild(resource)); | |
var leftTop:Point = getLeftTopPosition(resource); | |
var originX:Number = resource.x; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.events.IEventDispatcher; | |
import flash.utils.Dictionary; | |
/** | |
* @inspired from 'Bumpslide ActionScript Library' s Delegate class | |
* TODO | |
*/ | |
public class Delegate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in 用于在诸如Dictionary Object 对象中尝试返回指定键是否存 | |
var d = new Dictionary(); | |
var s = new Sprite(); | |
d[s] = true; | |
trace(s in d); // true | |
但目前假设d对象是自定义类, 并且覆盖了Object的toString()方法, | |
同时在toString()方法中, 正巧有访问为空的自定义属性,而s又正好不是d | |
对象的键, 那么此时居然会触发TypeError空对象错误, 解决方法是使用[] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
包外类和以Internal申明的类无法在外部实例化, 但一个方法可以使其在外部实例化。 | |
将该类实例或类引用保存在外部可访问的数据结构内, 然后获取,外部定义的变量名需要以*号为类型符。 | |
需要获取类定义的话, 可通过访问Object的constructor属性来获取从而避免通过平常方式( | |
getDefinitionByName)获取时产生的ReferenceError错误, 同时调用方法是需要使用数组访问符[]来 | |
调用这些类所定义的方法 | |
internal class InternalClassShow{ | |
public function show():void{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
诸如目前无法在外部实例化一个可以存储指定包外类类型的Vector对象 | |
问题重现: | |
(使用一个用数组实现的对象池类在存储包外类时, 由于无法获取到包外类的类定义, | |
造成一个"ReferenceError: Error #1065 :xx变量未定义"的报错, 下面假设该包外类类名为TestInternal, 位于gist.github.com包下的Test类中) | |
/** | |
* TODO | |
* 该方法判断指定对象是否为包外类所创建 | |
* @param runIn | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
/** | |
* forked from http://jacksondunstan.com/articles/1848 | |
*/ | |
public class SortedArray | |
{ | |
private var _ary:Array = []; | |
private var _start:int = 0; | |
private var _middle:int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.display.Sprite; | |
import flash.events.ErrorEvent; | |
import flash.events.UncaughtErrorEvent; | |
import flash.external.ExternalInterface; | |
public class Console extends Sprite | |
{ | |
public function Console():void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.utils.Dictionary; | |
/** | |
* this class inspiration from gskinner.com | |
* @see wwww.gskinner.com | |
*/ | |
public class WeakMap | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package | |
{ | |
import flash.events.Event; | |
import flash.events.EventPhase; | |
import flash.events.IEventDispatcher; | |
/** | |
* 仅执行一次事件处理方法, 随即删除 | |
* @see http://stackoverflow.com/questions/2476386/as3-event-listener-that-only-fires-once?rq=1 | |
* @example |