[7849] | 1 | package {
|
---|
| 2 | import flash.external.ExternalInterface;
|
---|
| 3 |
|
---|
| 4 | /**
|
---|
| 5 | * This manages all External calls, not all players have this ability (Flex does not,
|
---|
| 6 | * flash in a browser does, flash standalone does not)
|
---|
| 7 | *
|
---|
| 8 | * We also have an optional chart_id that the user may set, this is passed out
|
---|
| 9 | * as parameter one if it is set.
|
---|
| 10 | */
|
---|
| 11 | public class ExternalInterfaceManager
|
---|
| 12 | {
|
---|
| 13 | public var has_id:Boolean;
|
---|
| 14 | public var chart_id:String;
|
---|
| 15 |
|
---|
| 16 | private static var _instance:ExternalInterfaceManager;
|
---|
| 17 |
|
---|
| 18 | public static function getInstance():ExternalInterfaceManager {
|
---|
| 19 |
|
---|
| 20 | if (_instance == null) {
|
---|
| 21 | _instance = new ExternalInterfaceManager();
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | return _instance;
|
---|
| 25 | }
|
---|
| 26 |
|
---|
| 27 | public function setUp(chart_id:String):void {
|
---|
| 28 | this.has_id = true;
|
---|
| 29 | this.chart_id = chart_id;
|
---|
| 30 | tr.aces('this.chart_id',this.chart_id);
|
---|
| 31 | }
|
---|
| 32 |
|
---|
| 33 | // THIS NEEDS FIXING. I can't figure out how to preprend the chart
|
---|
| 34 | // id to the optional parameters.
|
---|
| 35 | public function callJavascript(functionName:String, ... optionalArgs ): * {
|
---|
| 36 |
|
---|
| 37 | // the debug player does not have an external interface
|
---|
| 38 | // because it is NOT embedded in a browser
|
---|
| 39 | if (ExternalInterface.available) {
|
---|
| 40 | if ( this.has_id ) {
|
---|
| 41 | tr.aces(functionName, optionalArgs);
|
---|
| 42 | optionalArgs.unshift(this.chart_id);
|
---|
| 43 | tr.aces(functionName, optionalArgs);
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | return ExternalInterface.call(functionName, optionalArgs);
|
---|
| 47 | }
|
---|
| 48 |
|
---|
| 49 | }
|
---|
| 50 | }
|
---|
| 51 | }
|
---|