Created
November 4, 2011 12:03
-
-
Save devboy/1339193 to your computer and use it in GitHub Desktop.
Mixins with include in AS3
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
// ActAsDog.as | |
public function bark(): void | |
{ | |
trace("bark"); | |
} | |
// ActAsCat.as | |
public function meow(): void | |
{ | |
trace("meow"); | |
} | |
// CatDogHybrid.as | |
package | |
{ | |
class CatDogHybrid | |
{ | |
include "ActAsCat.as" | |
include "ActAsDog.as" | |
} | |
} | |
// Test.as | |
var hybrid = new CatDogHybrid(); | |
hybrid.meow() // meow | |
hybrid.bark() // bark |
tschneidereit
commented
Nov 4, 2011
via email
:)
Me too - apart from higher-order typing for functions the lack of
mixins (or, much better yet: traits) is my single-most important gripe
with the language.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment