Skip to content

Instantly share code, notes, and snippets.

@nowri
Created April 30, 2012 09:39
Show Gist options
  • Save nowri/2556883 to your computer and use it in GitHub Desktop.
Save nowri/2556883 to your computer and use it in GitHub Desktop.
既存のクラスをインターフェイス化する簡単な方法
public function move(d:IDisplayObject):void
{
d.asDisplayObject.x += 10;
d.asDisplayObject.y += 10;
}
public interface IDisplayObject
{
function get asDisplayObject():DisplayObject;
}
//-----------------------------
// 既存のクラスをインターフェイス化する簡単な方法
//
// @see http://www.be-interactive.org/index.php?itemid=553
//-----------------------------
public class MyDisplayObject extends Sprite implements IDisplayObject
{
//...
public function get asDisplayObject():DisplayObject
{
return this;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment