Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to read (and maybe change) the sources of the core Flash class files?

I would like to read the source of the flash.net.FileReference class. Is this possible? Where can I find the source files, do they come with the Adobe Flash or Flash Builder?

like image 512
jayarjo Avatar asked May 18 '11 14:05

jayarjo


1 Answers

To read the flash package files, you can find the playerglobal.swc - change the name to playerglobal.zip and unzip the package. Then, decompile the library.swf file and get the script files. Here's what I found for FileReference:

//FileReference
package flash.net 
{
    import flash.events.*;
    import flash.utils.*;

    public class FileReference extends flash.events.EventDispatcher
    {
        public function FileReference()
        {
            super();
            return;
        }

        public function upload(arg1:flash.net.URLRequest, arg2:String="Filedata", arg3:Boolean=false):void
        {
        }

        private function _load(arg1:flash.utils.ByteArray):void
        {
        }

        public function load():void
        {
            this._load(new ByteArray());
            return;
        }

        public function get size():uint
        {
        }

        public function get type():String
        {
        }

        public function browse(arg1:Array=null):Boolean
        {
        }

        public function get name():String
        {
        }

        public function get creator():String
        {
        }

        public function get creationDate():Date
        {
        }

        public function download(arg1:flash.net.URLRequest, arg2:String=null):void
        {
        }

        public function get modificationDate():Date
        {
        }

        public function get data():flash.utils.ByteArray
        {
        }

        public function cancel():void
        {
        }

        private function _save(arg1:flash.utils.ByteArray, arg2:String):void
        {
        }

        public function save(arg1:*, arg2:String=null):void
        {
            var defaultFileName:String=null;
            var data:*;
            var d:flash.utils.ByteArray;

            var loc1:*;
            data = arg1;
            defaultFileName = arg2;
            d = new ByteArray();
            if (data == null) 
            {
                throw new ArgumentError("data");
            }
            if (data is String) 
            {
                d.writeUTFBytes(data as String);
            }
            else if (data is XML) 
            {
                d.writeUTFBytes((data as XML).toXMLString());
            }
            else if (data is ByteArray) 
            {
                d.writeBytes(data as ByteArray);
            }
            else 
            {
                try 
                {
                    d.writeUTFBytes(data);
                }
                catch (e:Error)
                {
                    throw new ArgumentError("data");
                }
            }
            d.position = 0;
            if (defaultFileName == null) 
            {
                defaultFileName = "";
            }
            this._save(d, defaultFileName);
            return;
        }
    }
}

I highly recommend not changing this file and rather extend it and override the functions you need to modify. Otherwise, you'll need to recompile the library.swf and create a custom playerglobal.swc.

like image 61
Corey Avatar answered Oct 05 '22 07:10

Corey