[swx] Catching PHP parse errors on Flash

Aral Balkan aral at aralbalkan.com
Tue Sep 25 14:11:18 PDT 2007


Hi Fabrício,

That's interesting -- thanks so much for sharing.

I'm assuming you're working with pre v.1 as you're returning this in
result[0] instead of result.

I'm going to look at what you're doing in more detail when I get a moment.

Take care,
Aral

On 9/25/07, Fabrício Seger Kolling <dulldusk at gmail.com> wrote:
> I've modified SWX so that i can return more information to flash.
>
> ExternalAsset._innerMovie.result[0] is now an object with five properties.
>
> error : Boolean - indicates is there was a user generated fatal error,
> leads to ExternalAsset.FAULT
> errorMsg : String - the fatal error message
> log : String - for debbugging server side scripts
> output : String - i use php output buffering to catch and parse into the
> swf any output previous to its generation
> data : Any Type - the actual data result from the method execution
>
> log and output properties only return when SWX is called on debug mode.
>
> The problem with PHP parse erros is that they are generated before the
> script execution, and always result on a plain text output, that can't
> be avoided or catched with output buffering.
> But when that happens, soon after _innerHolder.loadMovie(),
> _innerHolder.getBytesTotal() starts returning -1.
> So I stop the loader, and call ExternalAsset.loadPlainText() that uses
> LoadVars() to get the parse error and output it on flash.
>
> public function loadPlainText(){
>         log("SWX Calling method load on plain text mode");
>         var thisRef = this;
>         _loadVars = new LoadVars();
>         _loadVars.onData = function(src:String) {
>             if (src.length > 102400) {
>                 src = "> 10Kb";
>             } else if (src != undefined){
>                 src = Strings.trim(Strings.removeHTML(src));
>             }
>             thisRef.log("SWX Server Return:\n" + src);
>         };
>         _loadVars.onLoad = function(success:Boolean) {
>         };
>         if (_dataObject == null) {
>             _loadVars.load(_gateway, _loadVars, _encoding);
>         } else {
>             for (var i in _dataObject) {
>                 _loadVars[i] = _dataObject[i];
>             }
>             prepare(_loadVars);
>             _loadVars.sendAndLoad(_gateway, _loadVars, _encoding);
>         }
>     }
>
> It's more to tell you guys the solution i came up, error handling can be
> a real pain.
>
> Fabrício
>
> _______________________________________________
> swx mailing list
> swx at osflash.org
> http://osflash.org/mailman/listinfo/swx_osflash.org
>



More information about the swx mailing list