flash on 2011-8-18

by Cao
■ABC File MinorVersion:16 , MajorVersion:46
INT cnt=20
UINT cnt=1
DOUBLE cnt=20
STRING cnt=216
NAMESPACES cnt=29
NAMESPACE_SETS cnt=5
MULTINAMES cnt=191
Methods cnt=34
METADATA cnt=0
INTERFACE cnt=3
CLASS cnt=3
SCRIPT cnt=3
■script0■
■class(instance)_index:0
♥0 | Line 473 | Modified 2011-08-18 12:29:55 | MIT License
play

ActionScript3 source code

/**
 * Copyright Cao ( http://wonderfl.net/user/Cao )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/gmkn
 */

//■ABC File MinorVersion:16 , MajorVersion:46

//INT cnt=20
//UINT cnt=1
//DOUBLE cnt=20
//STRING cnt=216
//NAMESPACES cnt=29
//NAMESPACE_SETS cnt=5
//MULTINAMES cnt=191
//Methods cnt=34
//METADATA cnt=0
//INTERFACE cnt=3
//CLASS cnt=3
//SCRIPT cnt=3

//■script0■

package{

    import __AS3__.vec.Vector
    import com.adobe.images.JPGEncoder
    import flash.display.Bitmap
    import flash.display.BitmapData
    import flash.display.Shape
    import flash.display.SimpleButton
    import flash.display.Sprite
    import flash.display.StageAlign
    import flash.display.StageQuality
    import flash.events.Event
    import flash.events.MouseEvent
    import flash.events.StatusEvent
    import flash.media.Camera
    import flash.media.Video
    import flash.net.URLLoader
    import flash.net.URLRequest
    import flash.net.URLRequestMethod
    import flash.text.TextField
    import flash.text.TextFieldAutoSize
    import flash.utils.ByteArray
    

    //■class(instance)_index:0
    public class Main extends Sprite
    {
        //static constructor
        public static function Main$cinit()
        {    //MethodID:0, LocalCount= 1 , MaxScope= 1, MaxStack= 1, CodeLength= 3
        }

        //constructor
        public function Main():void
        {    //MethodID:1, LocalCount= 1 , MaxScope= 1, MaxStack= 3, CodeLength= 198
            this.bd = new Vector.<BitmapData>();
            this.images = new Vector.<Sprite>();
            this.capBt = new SimpleButton();
            this.capLabel = new TextField();
            this.closeBt = new SimpleButton();
            this.closeLabel = new TextField();
            this.trblBt = new SimpleButton();
            this.trblLabel = new TextField();
            this.kimeBt = new SimpleButton();
            this.kimeLabel = new TextField();
            this.trblTag = new Shape();
            this.trblTagname = new TextField();
            this.kimeTag = new Shape();
            this.kimeTagname = new TextField();
            this.dialog = new Shape();
            this.yesBt = new SimpleButton();
            this.noBt = new SimpleButton();
            this.dialogTxt = new TextField();
            this.yesLabel = new TextField();
            this.noLabel = new TextField();

            super();

            if(stage){
                this.init();
            }else{
                addEventListener(Event.ADDED_TO_STAGE, this.init);
            }
        }

        //variables/etc.
        private var video_obj:Video;                                    //slotID:0
        private var camera_obj:Camera;                                  //slotID:0
        private var preview_area:Shape;                                 //slotID:0
        private var i:Number = 0.0;                                     //slotID:0
        private var urlRequest:URLRequest;                              //slotID:0
        private var urlLoader:URLLoader;                                //slotID:0
        private var phpPre:String = "http://localhost:3000/customers/"; //slotID:0
        private var phpPost:String = "/images/upload";                  //slotID:0
        private var phpPath:String;                                     //slotID:0
        private var reqPath:String;                                     //slotID:0
        private var fileName:String;                                    //slotID:0
        private var img:Bitmap;                                         //slotID:0
        private var bd:Vector.<BitmapData>;                             //slotID:0
        private var images:Vector.<Sprite>;                             //slotID:0
        private var currentSelection:uint = 0;                          //slotID:0
        private var previousSelection:int = -1;                         //slotID:0
        private var capBt:SimpleButton;                                 //slotID:0
        private var capLabel:TextField;                                 //slotID:0
        private var closeBt:SimpleButton;                               //slotID:0
        private var closeLabel:TextField;                               //slotID:0
        private var trblBt:SimpleButton;                                //slotID:0
        private var trblLabel:TextField;                                //slotID:0
        private var kimeBt:SimpleButton;                                //slotID:0
        private var kimeLabel:TextField;                                //slotID:0
        private var trblTag:Shape;                                      //slotID:0
        private var trblTagname:TextField;                              //slotID:0
        private var kimeTag:Shape;                                      //slotID:0
        private var kimeTagname:TextField;                              //slotID:0
        private var trblId:int = -1;                                    //slotID:0
        private var kimeId:int = -1;                                    //slotID:0
        private var dialog:Shape;                                       //slotID:0
        private var yesBt:SimpleButton;                                 //slotID:0
        private var noBt:SimpleButton;                                  //slotID:0
        private var dialogTxt:TextField;                                //slotID:0
        private var yesLabel:TextField;                                 //slotID:0
        private var noLabel:TextField;                                  //slotID:0
        private var mode:String;                                        //slotID:0

        private function init(hug1:Event=null):void
        {    //MethodID:3, LocalCount= 5 , MaxScope= 2, MaxStack= 6, CodeLength= 1279
             var e:Event = null;                                    //slotID:1
             var w:int;                                             //slotID:2
             var h:int;                                             //slotID:3
             var fps:Number;                                        //slotID:4
             var txt:String;                                        //slotID:5
             var vars:Object;                                       //slotID:6
             var j:String;                                          //slotID:7

            txt = null;
            j = null;
            e = hug1;
            stage.quality = StageQuality.MEDIUM;
            stage.align = StageAlign.TOP_LEFT;

            removeEventListener(Event.ADDED_TO_STAGE, this.init);

            this.camera_obj = Camera.getCamera();
            w = 352;
            h = 264;
            fps = 30;

            this.camera_obj.setMode(w, h, fps);
            this.camera_obj.addEventListener(StatusEvent.STATUS, function(hug1:StatusEvent):void{    //MethodID:2, LocalCount= 3 , MaxScope= 0, MaxStack= 2, CodeLength= 80
                switch(hug1.code){
                case "Camera.Unmuted":
                    break;
                case "Camera.Muted":
                    break;
                default:
                    break;
                }
            });

            this.video_obj = new Video(352, 264);

            this.video_obj.attachCamera(this.camera_obj);
            addChild(this.video_obj);

            vars = loaderInfo.parameters;

            for(j in vars){
                txt = j;
            }

            this.capBt.x = 10;
            this.capBt.y = 10;
            this.capBt.upState = this.makeRoundRect(0xCCFF, 100, 40);
            this.capBt.overState = this.makeRoundRect(0x99FF, 100, 40);
            this.capBt.downState = this.makeRoundRect(0xCCFF, 100, 40);
            this.capBt.hitTestState = this.capBt.upState;

            addChild(this.capBt);

            this.capLabel.text = "CAP";
            this.capLabel.autoSize = TextFieldAutoSize.LEFT;
            this.capLabel.x = ((10 + (this.capBt.width / 2)) - (this.capLabel.width / 2));
            this.capLabel.y = ((10 + (this.capBt.height / 2)) - (this.capLabel.height / 2));
            this.capLabel.mouseEnabled = false;

            addChild(this.capLabel);

            this.closeBt.x = 240;
            this.closeBt.y = 10;
            this.closeBt.upState = this.makeRoundRect(0xFFCC00, 100, 40);
            this.closeBt.overState = this.makeRoundRect(0xFF9900, 100, 40);
            this.closeBt.downState = this.makeRoundRect(0xFFCC00, 100, 40);
            this.closeBt.hitTestState = this.closeBt.upState;
            this.closeBt.visible = false;

            addChild(this.closeBt);

            this.closeLabel.text = "CLOSE";
            this.closeLabel.autoSize = TextFieldAutoSize.LEFT;
            this.closeLabel.x = ((240 + (this.closeBt.width / 2)) - (this.closeLabel.width / 2));
            this.closeLabel.y = ((10 + (this.closeBt.height / 2)) - (this.closeLabel.height / 2));
            this.closeLabel.mouseEnabled = false;
            this.closeLabel.visible = false;

            addChild(this.closeLabel);

            this.trblBt.x = 126;
            this.trblBt.y = 10;
            this.trblBt.upState = this.makeRoundRect(0xFFCEFF, 100, 40);
            this.trblBt.overState = this.makeRoundRect(0xFF80FF, 100, 40);
            this.trblBt.downState = this.makeRoundRect(0xFFCEFF, 100, 40);
            this.trblBt.hitTestState = this.trblBt.upState;
            this.trblBt.visible = false;

            addChild(this.trblBt);

            this.trblLabel.text = "肌トラブル";
            this.trblLabel.autoSize = TextFieldAutoSize.LEFT;
            this.trblLabel.x = ((126 + (this.trblBt.width / 2)) - (this.trblLabel.width / 2));
            this.trblLabel.y = ((10 + (this.trblBt.height / 2)) - (this.trblLabel.height / 2));
            this.trblLabel.mouseEnabled = false;
            this.trblLabel.visible = false;

            addChild(this.trblLabel);

            this.kimeBt.x = 10;
            this.kimeBt.y = 10;
            this.kimeBt.upState = this.makeRoundRect(0xCCFF, 100, 40);
            this.kimeBt.overState = this.makeRoundRect(0x99FF, 100, 40);
            this.kimeBt.downState = this.makeRoundRect(0xCCFF, 100, 40);
            this.kimeBt.hitTestState = this.kimeBt.upState;
            this.kimeBt.visible = false;

            addChild(this.kimeBt);

            this.kimeLabel.text = "キメ";
            this.kimeLabel.autoSize = TextFieldAutoSize.LEFT;
            this.kimeLabel.x = ((10 + (this.kimeBt.width / 2)) - (this.kimeLabel.width / 2));
            this.kimeLabel.y = ((10 + (this.kimeBt.height / 2)) - (this.kimeLabel.height / 2));
            this.kimeLabel.mouseEnabled = false;
            this.kimeLabel.visible = false;

            addChild(this.kimeLabel);
            this.trblTag.graphics.beginFill(0xFFCEFF);
            this.trblTag.graphics.drawRoundRect(0, 0, 60, 20, 15);
            this.trblTag.graphics.endFill();

            this.trblTag.visible = false;

            addChild(this.trblTag);

            this.trblTagname.text = "肌トラブル";
            this.trblTagname.autoSize = TextFieldAutoSize.LEFT;
            this.trblTagname.x = 0;
            this.trblTagname.y = 0;
            this.trblTagname.mouseEnabled = false;
            this.trblTagname.visible = false;

            addChild(this.trblTagname);
            this.kimeTag.graphics.beginFill(0xCCFF);
            this.kimeTag.graphics.drawRoundRect(0, 0, 60, 20, 15);
            this.kimeTag.graphics.endFill();

            this.kimeTag.visible = false;

            addChild(this.kimeTag);

            this.kimeTagname.text = "キメ";
            this.kimeTagname.autoSize = TextFieldAutoSize.LEFT;
            this.kimeTagname.x = 0;
            this.kimeTagname.y = 0;
            this.kimeTagname.mouseEnabled = false;
            this.kimeTagname.visible = false;

            addChild(this.kimeTagname);

            this.phpPath = (this.phpPre + txt + this.phpPost);

            this.capBt.addEventListener(MouseEvent.CLICK, this.capture);
            this.closeBt.addEventListener(MouseEvent.CLICK, this.close);
            this.trblBt.addEventListener(MouseEvent.CLICK, this.showDialog);
            this.kimeBt.addEventListener(MouseEvent.CLICK, this.showDialog);
        }

        private function makeRoundRect(hug1:uint, hug2:int, hug3:int):Shape
        {    //MethodID:4, LocalCount= 5 , MaxScope= 1, MaxStack= 6, CodeLength= 48
            var hug4:Shape = new Shape();

            hug4.graphics.beginFill(hug1);
            hug4.graphics.drawRoundRect(0, 0, hug2, hug3, 15);
            hug4.graphics.endFill();

            return hug4;
        }

        private function capture(hug1:MouseEvent):void
        {    //MethodID:5, LocalCount= 6 , MaxScope= 1, MaxStack= 5, CodeLength= 220
            var hug2:BitmapData = new BitmapData(this.camera_obj.width, this.camera_obj.height);

            hug2.draw(this.video_obj);
            this.bd.push(hug2);

            this.img = new Bitmap(this.bd[this.i]);
            this.img.scaleX = 0.19;
            this.img.scaleY = 0.19;
            this.img.x = (this.i * 71);
            this.img.y = 270;
            var hug3:Sprite = new Sprite();

            hug3.addChild(this.img);
            addChild(hug3);
            this.images.push(hug3);
            this.images[this.i].addEventListener(MouseEvent.CLICK, this.enlarge);
            addChild(this.images[this.i]);
            setChildIndex(this[this.i++], 3);

            if(this.i == 5){
                this.capBt.visible = false;
                this.capLabel.visible = false;
            }
        }

        private function enlarge(hug1:MouseEvent):void
        {    //MethodID:6, LocalCount= 3 , MaxScope= 1, MaxStack= 4, CodeLength= 575
            var hug2:uint = 0;

            while(hug2 < this.images.length){
                if(hug1.target == this.images[hug2]) this.currentSelection = hug2;

                if(this.images[hug2].scaleX == 5.27) this.previousSelection = hug2;

                hug2++;
            }

            if(this.images[this.currentSelection].scaleX == 1){
                this.closeBt.visible = true;
                this.closeLabel.visible = true;

                if((this.currentSelection != this.trblId) && (this.currentSelection != this.kimeId)){
                    this.trblBt.visible = true;
                    this.trblLabel.visible = true;
                    this.kimeBt.visible = true;
                    this.kimeLabel.visible = true;
                }else{
                    this.trblBt.visible = false;
                    this.trblLabel.visible = false;
                    this.kimeBt.visible = false;
                    this.kimeLabel.visible = false;
                }

                if(this.previousSelection != (-1)){
                    this.images[this.previousSelection].scaleX = 1;
                    this.images[this.previousSelection].scaleY = 1;
                    this.images[this.previousSelection].x = 0;
                    this.images[this.previousSelection].y = 0;
                    this.previousSelection = -1;
                }
            }else if(this.images[this.currentSelection].scaleX == 5.27){
                if(this.closeBt.visible == false){
                    this.closeBt.visible = true;
                }else{
                    this.closeBt.visible = false;
                }

                if(this.closeLabel.visible == false){
                    this.closeLabel.visible = true;
                }else{
                    this.closeLabel.visible = false;
                }

                if((this.currentSelection != this.trblId) && (this.currentSelection != this.kimeId)){
                    if(this.trblBt.visible == false){
                        this.trblBt.visible = true;
                    }else{
                        this.trblBt.visible = false;
                    }

                    if(this.trblLabel.visible == false){
                        this.trblLabel.visible = true;
                    }else{
                        this.trblLabel.visible = false;
                    }

                    if(this.kimeBt.visible == false){
                        this.kimeBt.visible = true;
                    }else{
                        this.kimeBt.visible = false;
                    }

                    if(this.kimeLabel.visible == false){
                        this.kimeLabel.visible = true;
                    }else{
                        this.kimeLabel.visible = false;
                    }
                }else{
                    this.trblBt.visible = false;
                    this.trblLabel.visible = false;
                    this.kimeBt.visible = false;
                    this.kimeLabel.visible = false;
                }
            }

            this.images[this.currentSelection].scaleX = 5.27;
            this.images[this.currentSelection].scaleY = 5.27;
            this.images[this.currentSelection].x = (0 - (374.18 * this.currentSelection));
            this.images[this.currentSelection].y = -1423;
        }

        private function close(hug1:MouseEvent):void
        {    //MethodID:7, LocalCount= 2 , MaxScope= 1, MaxStack= 2, CodeLength= 101
            this.images[this.currentSelection].scaleX = 1;
            this.images[this.currentSelection].scaleY = 1;
            this.images[this.currentSelection].x = 0;
            this.images[this.currentSelection].y = 0;
            this.closeBt.visible = false;
            this.closeLabel.visible = false;
            this.trblBt.visible = false;
            this.trblLabel.visible = false;
            this.kimeBt.visible = false;
            this.kimeLabel.visible = false;
        }

        private function showDialog(hug1:MouseEvent):void
        {    //MethodID:8, LocalCount= 3 , MaxScope= 1, MaxStack= 6, CodeLength= 665
            var hug2:uint = 0;

            while(hug2 < this.images.length){
                this.images[hug2].removeEventListener(MouseEvent.CLICK, this.enlarge);

                hug2++;
            }

            this.closeBt.visible = false;
            this.closeLabel.visible = false;
            this.trblBt.visible = false;
            this.trblLabel.visible = false;
            this.kimeBt.visible = false;
            this.kimeLabel.visible = false;

            this.dialog.graphics.beginFill(0xFFFFFF);
            this.dialog.graphics.drawRoundRect(66, 100, 220, 80, 15);
            this.dialog.graphics.endFill();
            addChild(this.dialog);

            this.yesBt.x = 86;
            this.yesBt.y = 150;
            this.yesBt.upState = this.makeRoundRect(0xCCFF, 80, 20);
            this.yesBt.overState = this.makeRoundRect(0x99FF, 80, 20);
            this.yesBt.downState = this.makeRoundRect(0xCCFF, 80, 20);
            this.yesBt.hitTestState = this.yesBt.upState;

            addChild(this.yesBt);

            this.noBt.x = 187;
            this.noBt.y = 150;
            this.noBt.upState = this.makeRoundRect(0xFFCC00, 80, 20);
            this.noBt.overState = this.makeRoundRect(0xFF9900, 80, 20);
            this.noBt.downState = this.makeRoundRect(0xFFCC00, 80, 20);
            this.noBt.hitTestState = this.noBt.upState;

            addChild(this.noBt);

            if(hug1.target == this.trblBt){
                this.mode = "trbl";
                this.dialogTxt.text = "肌トラブル画像を登録します。\nよろしいですか?";
            }else{
                this.mode = "kime";
                this.dialogTxt.text = "キメ画像を登録します。\nよろしいですか?";
            }

            this.dialogTxt.autoSize = TextFieldAutoSize.LEFT;
            this.dialogTxt.x = ((66 + (this.dialog.width / 2)) - (this.dialogTxt.width / 2));
            this.dialogTxt.y = ((100 + (this.dialog.height / 3)) - (this.dialogTxt.height / 2));
            this.dialogTxt.mouseEnabled = false;

            addChild(this.dialogTxt);

            this.yesLabel.text = "はい";
            this.yesLabel.autoSize = TextFieldAutoSize.LEFT;
            this.yesLabel.x = ((86 + (this.yesBt.width / 2)) - (this.yesLabel.width / 2));
            this.yesLabel.y = ((150 + (this.yesBt.height / 2)) - (this.yesLabel.height / 2));
            this.yesLabel.mouseEnabled = false;

            addChild(this.yesLabel);
            this.yesBt.addEventListener(MouseEvent.CLICK, this.upload);

            this.noLabel.text = "いいえ";
            this.noLabel.autoSize = TextFieldAutoSize.LEFT;
            this.noLabel.x = ((187 + (this.noBt.width / 2)) - (this.noLabel.width / 2));
            this.noLabel.y = ((150 + (this.noBt.height / 2)) - (this.noLabel.height / 2));
            this.noLabel.mouseEnabled = false;

            addChild(this.noLabel);
            this.noBt.addEventListener(MouseEvent.CLICK, this.cancelDialog);
        }

        private function upload(hug1:MouseEvent):void
        {    //MethodID:9, LocalCount= 5 , MaxScope= 1, MaxStack= 3, CodeLength= 547
            this.yesBt.removeEventListener(MouseEvent.CLICK, this.upload);

            var hug2:uint = 0;

            while(hug2 < this.images.length){
                this.images[hug2].addEventListener(MouseEvent.CLICK, this.enlarge);

                hug2++;
            }

            if(this.mode == "trbl"){
                this.reqPath = (this.phpPath + "?cat=1");
            }else if(this.mode == "kime"){
                this.reqPath = (this.phpPath + "?cat=2");
            }

            var hug3:JPGEncoder = new JPGEncoder(80);
            var hug4:ByteArray = hug3.encode(this.bd[this.currentSelection]);
            this.urlRequest = new URLRequest(this.reqPath);
            this.urlLoader = new URLLoader();
            this.urlRequest.contentType = "application/octet-stream";
            this.urlRequest.method = URLRequestMethod.POST;
            this.urlRequest.data = hug4;

            this.urlLoader.load(this.urlRequest);

            this.images[this.currentSelection].scaleX = 1;
            this.images[this.currentSelection].scaleY = 1;
            this.images[this.currentSelection].x = 0;
            this.images[this.currentSelection].y = 0;
            this.closeBt.visible = false;
            this.closeLabel.visible = false;
            this.trblBt.visible = false;
            this.trblLabel.visible = false;
            this.kimeBt.visible = false;
            this.kimeLabel.visible = false;

            if(this.mode == "trbl"){
                this.trblTag.x = ((this.currentSelection * 71) + 3);
                this.trblTag.y = 285;
                this.trblTag.visible = true;
                this.trblTagname.x = ((this.currentSelection * 71) + 6);
                this.trblTagname.y = 285;
                this.trblTagname.visible = true;

                removeChild(this.trblBt);
                removeChild(this.trblLabel);

                this.trblId = this.currentSelection;
            }else if(this.mode == "kime"){
                this.kimeTag.x = ((this.currentSelection * 71) + 3);
                this.kimeTag.y = 285;
                this.kimeTag.visible = true;
                this.kimeTagname.x = ((this.currentSelection * 71) + 20);
                this.kimeTagname.y = 285;
                this.kimeTagname.visible = true;

                removeChild(this.kimeBt);
                removeChild(this.kimeLabel);

                this.kimeId = this.currentSelection;
            }

            removeChild(this.dialog);
            removeChild(this.dialogTxt);
            removeChild(this.yesBt);
            removeChild(this.yesLabel);
            removeChild(this.noBt);
            removeChild(this.noLabel);
        }

        private function cancelDialog(hug1:MouseEvent):void
        {    //MethodID:10, LocalCount= 3 , MaxScope= 1, MaxStack= 3, CodeLength= 162
            this.noBt.removeEventListener(MouseEvent.CLICK, this.cancelDialog);

            var hug2:uint = 0;

            while(hug2 < this.images.length){
                this.images[hug2].addEventListener(MouseEvent.CLICK, this.enlarge);

                hug2++;
            }

            removeChild(this.dialog);
            removeChild(this.dialogTxt);
            removeChild(this.yesBt);
            removeChild(this.yesLabel);
            removeChild(this.noBt);
            removeChild(this.noLabel);

            this.closeBt.visible = true;
            this.closeLabel.visible = true;
            this.trblBt.visible = true;
            this.trblLabel.visible = true;
            this.kimeBt.visible = true;
            this.kimeLabel.visible = true;
        }
    }
}

//■script1■
//skip components :com.adobe.images
//as filename :JPGEncoder.as

//■script2■
//skip components :com.adobe.images
//as filename :BitString.as