Created
April 30, 2012 09:39
-
-
Save nowri/2556883 to your computer and use it in GitHub Desktop.
既存のクラスをインターフェイス化する簡単な方法
This file contains hidden or 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
public function move(d:IDisplayObject):void | |
{ | |
d.asDisplayObject.x += 10; | |
d.asDisplayObject.y += 10; | |
} |
This file contains hidden or 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
public interface IDisplayObject | |
{ | |
function get asDisplayObject():DisplayObject; | |
} |
This file contains hidden or 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
//----------------------------- | |
// 既存のクラスをインターフェイス化する簡単な方法 | |
// | |
// @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