On 2008-04-20, at 06:13 EDT, Gilad Parann-Nissany wrote:
2. In general how would we write ActionScript code in an OL method ?

any ideas? sugegstions? code examples are requested especially.

Our script is a superset of ActionScript. Whatever you want to write in ActionScript, you can write in Javascript, which you can write in an OL method. If you want to call a built-in ActionScript function, you simply call it. The only thing you would want to take care about is that your application will then be non-portable. Here is an example of some code that calls into either the DHTML or SWF runtime, depending on which platform it is compiled for. This sample comes from the LFC kernel, it is the platform-specific implementation of a portable LFC API:

        if ($js1) {
            var why;
            if(window.XMLHttpRequest) {
                try {
                    this.socket = new XMLHttpRequest();
                } catch(e) {
                    why = e;
                }
            } else if(window.ActiveXObject) {
                try {
                    this.socket = new ActiveXObject("Msxml2.XMLHTTP");
                } catch(e) {
                    why = e;
                    try {
this.socket = new ActiveXObject("Microsoft.XMLHTTP");
                    } catch(e) {
                        why = e;
                    }
                }
            }
        } else if ($as2) {
// We'll instantiate a LoadVars object when needed, for Flash runtime
            this.socket = new LoadVars();
            this.returnval = new LoadVars();
            // callback from Flash LoadVars.sendAndLoad()
            this.returnval.onData = this.flashOnLoadHandler;
        } else {
            Debug.error("Unsupported platform");
        }

$js1 and $as2 are commpile-time constants that are defined for the SWF and DHTML runtimes. The compiler will optimize away the if branches that are not applicable.


Reply via email to