- Home /
Question by
dvidunis · Nov 26, 2014 at 03:27 PM ·
javascriptarrayclasstype
Create an array of classes, of different type.
I have this class:
public static class CharTypes {
public class Foo {
function action1 () {
}
function action2 () {
}
}
public class Bar {
function action1 () {
}
function action2 () {
}
}
var index = [
Foo,
Bar
];
}
And the internal system stores those types by number, so to access a specific action from a type, I would do this:
CharTypes.index[internalStuff.id].action1();
But this throws
BCE0019: 'action1' is not a member of 'System.Type'.
How do I make the index a type that allows me to reference actionX()?
Comment
Best Answer
Answer by dvidunis · Nov 26, 2014 at 04:05 PM
Nevermind, figured it out. I made a CharTypeTemplate class, and made all others extend it.
public static class CharTypes {
private class CharTypeTemplate {
function action1 () {}
function action2 () {}
}
public class Foo extends CharTypeTemplate {
function action1 () {
}
function action2 () {
}
}
public class Bar extends CharTypeTemplate {
function action1 () {
}
function action2 () {
}
}
var index:CharTypeTemplate = [
Foo,
Bar
];
}