|
An interactive swf file (th999.swf), incorporated in the hot pepper as a simple picture. If you want to feel the experience, try Linos's quiz on Triangles. |
|
the Protocol The teacher, who wants to create Interactive swf files, must conform to the following rules.
|
|
An almost complete but extremely abstract program is the following.
package {
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.net.LocalConnection;
import flash.events.StatusEvent;
import fl.controls.Button;
public class Th999 extends Sprite {
private var conn1, conn2: LocalConnection;
private var percentageOfSuccess: Number;
// ----------------------------------------------------------------------------
public function Th999() {
percentageOfSuccess = 0;
conn2 = new LocalConnection();
conn2.client = this;
try {
conn2.connect ('HOT_PEPPER')
}
catch (error: ArgumentError) {}
var sendBtn: Button = new Button();
sendBtn.label = 'Submit';
sendBtn.addEventListener (MouseEvent.CLICK, sendMessage);
addChild (sendBtn)
}
// ----------------------------------------------------------------------------
private function sendMessage (e: MouseEvent): void {
conn1.send ('hotPepper', 'localConnectionHandler1', percentageOfSuccess);
try {
conn1.close()
}
catch (error: ArgumentError) {}
}
// ----------------------------------------------------------------------------
public function localConnectionHandler2 (workout, canAnswer, newQuestion: Boolean, directory: String): void {
try {
conn2.close()
}
catch (error: ArgumentError) {}
if (canAnswer) {
conn1 = new LocalConnection();
conn1.addEventListener (StatusEvent.STATUS, onStatus1)
}
}
// ----------------------------------------------------------------------------
private function onStatus1 (e: StatusEvent): void {
switch (e.level) {
case 'status':
break;
case 'error':
}
}
// ----------------------------------------------------------------------------
}
} |