SharpFlash.as
上传用户:lctyggxszx
上传日期:2022-06-30
资源大小:280k
文件大小:3k
- #include "wddx_mx.as"
- if (_global.$SharpFlash == undefined) {
- _global.$SharpFlash = new Object();
- _global.$SharpFlash.WDDX = new WDDX();
- // The callback list is a hash table of function
- // references so we can execute a function when
- // the SharpFlash wrapper is done executing.
- _global.$SharpFlash.CallBackList = new Object();
-
- // This is the function that is fired when a method is
- // done executing and needs to invoke a method inside
- // of the Flash app.
- _global.$onSFData = function(prop, oldVal, newVal) {
- var response_xml = new XML();
- response_xml.parseXML(newVal);
- response_xml = response_xml.firstChild.firstChild;
- var tmp = response_xml.childNodes[0].firstChild;
- // The callback functions up to this point have either 1
- // or 2 arguments, and we determind this by the number
- // of <arg> nodes in the xml packet sent from SharpFlash
- var argCount = response_xml.childNodes[1].childNodes.length;
- switch (argCount) {
- case 1:
- var arg1_wddx_xml = new XML();
- arg1_wddx_xml.parseXML(response_xml.childNodes[1].childNodes[0].firstChild);
- var funcArgs = new Array(1);
- funcArgs[0] = _global.$SharpFlash.WDDX.deserialize(arg1_wddx_xml);
-
- // Execute the callback function on the specified scope,
- // passing in the arguments given to us by the SharpFlash wrapper.
- _global.$SharpFlash.CallBackList[tmp].callback.apply(_global.$SharpFlash.CallBackList[tmp].scope, funcArgs);
-
- // debug code:
- //_root.callback_txt.text = "1 Arg Result: " + funcArgs[0];
- break;
-
- case 2:
- var arg1_wddx_xml = new XML();
- arg1_wddx_xml.parseXML(response_xml.childNodes[1].childNodes[0].firstChild);
- var arg2_wddx_xml = new XML();
- arg2_wddx_xml.parseXML(response_xml.childNodes[1].childNodes[1].firstChild);
- var funcArgs = new Array(2);
- funcArgs[0] = _global.$SharpFlash.WDDX.deserialize(arg1_wddx_xml);
- funcArgs[1] = _global.$SharpFlash.WDDX.deserialize(arg2_wddx_xml);
-
- // Execute the callback function on the specified scope,
- // passing in the arguments given to us by the SharpFlash wrapper.
- _global.$SharpFlash.CallBackList[tmp].callback.apply(_global.$SharpFlash.CallBackList[tmp].scope, funcArgs);
-
- // debug code:
- //_root.callback_txt.text = "2 Arg Result: [0] = " + funcArgs[0] + "n[1] = " + funcArgs[1];
- break;
- }
-
- // At this point we can do away with the data in the
- // CallBackList hashtable..
- // just mark the location as null and let the garbage collector
- // deal with it
- _global.$SharpFlash.CallBackList[tmp] = null;
- }
-
- // $SFData needs to be defined in _root (not _global) because of how the
- // variable is set within the ActiveX control
- _root.$SFData = "";
- _root.watch("$SFData", _global.$onSFData);
- }