An example of an object which requires an implementation of the interface.
//This code is valid, and the execution will be successful.
function executeInterface1(executeThis){
var castedIface = executeThis.cast('TestInterface');
castedIface.testMethod1(1,2,3);
}
//This code is valid, but the execution will not be successful.
function executeInterface2(executeThis){
var castedIface = executeThis.cast('TestInterface');
castedIface.testMethod2(4,5,6);
}
Alright, lets instanciate, the objects and set them to variables.
Feel free to type in the variables and take a look, on the firebug window!
InitedTestObject = new TestObject();
//variable not used in this example, but I thought I would still make it available!
CastedTestInterface = InitedTestObject.cast('TestInterface');
Ok, so lets try it out! We wrap it all up in some simple div tags with onclick events.
onclick="executeInterface1(InitedTestObject)"
onclick="executeInterface2(InitedTestObject)"
Yes I know putting it onclick events within div tags lessens the awesomness of the example, but I am not going to hassle the reader with the event model.
Click Here To Run Test 1
Click Here To Run Test 2