flash on 2013-8-20

by marcsali
♥0 | Line 118 | Modified 2013-08-20 01:23:10 | MIT License
play

ActionScript3 source code

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

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" backgroundColor="#000000" 
horizontalAlign="center" verticalAlign="middle" height="100%" width="100%" verticalGap="0" horizontalGap="0">

<mx:Script>
    <![CDATA[
        import mx.controls.Alert;
        import mx.controls.Image;

        private var blnFirst:Boolean = true;
        private var arr0:Array = new Array();
        private var arr1:Array = new Array();
        private var arr2:Array = new Array();
        private var count:int = 0;
        private var arr:Array = new Array();
        private var pl1Won:Boolean = false;
        private var pl2Won:Boolean = false;

        public function img_click(event:Event):void
        {
            if(event.currentTarget.enabled)
            {
                count++;
                if(blnFirst)
                {
                    blnFirst = false;
                    var itemp:Image = new Image();
                    itemp.percentHeight = 100;
                    itemp.percentWidth = 100;
                    itemp.source = "Images/Circle.png";
                    event.currentTarget.addChild(itemp);
                    event.currentTarget.enabled = false;
                    arrayInsert(event.currentTarget.id,true);
                }
                else
                {
                    blnFirst = true;
                    var itemp:Image = new Image();
                    itemp.percentHeight = 100;
                    itemp.percentWidth = 100;
                    itemp.source = "Images/Cross.png";
                    event.currentTarget.addChild(itemp);
                    event.currentTarget.enabled = false;
                    arrayInsert(event.currentTarget.id,false);
                }
            }

            if(count == 9)
            {
                arr = [arr0, arr1, arr2];
            }
        }

        private function arrayInsert(id:String,value:Boolean):void
        {
            if(id == "box00")
                arr0[0] = value;    
            if(id == "box01")
                arr0[1] = value;
            if(id == "box02")
                arr0[2] = value;
            if(id == "box10")
                arr1[0] = value;
            if(id == "box11")
                arr1[1] = value;    
            if(id == "box12")
                arr1[2] = value;
            if(id == "box20")
                arr2[0] = value;    
            if(id == "box21")
                arr2[1] = value;    
            if(id == "box22")
                arr2[2] = value;
        }

        private function btn_click():void
        {
                        for(var i:int=0;i<3;i++)
            {
                for(var j:int=0;j<3;j++)
                {
                    //very confused in this part
                }
            }
                            }

    ]]>
</mx:Script>
<mx:VBox height="500" width="500" borderStyle="solid"  borderColor="#000000"
    backgroundColor="#ffffff" verticalGap="0" horizontalGap="0">

    <mx:HBox width="100%" height="33.3%" horizontalGap="0" verticalGap="0">

        <mx:Box height="100%" width="33.3%" borderStyle="solid" borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box00" >
        </mx:Box>
        <mx:Box height="100%" width="33.3%" borderStyle="solid" borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box01">
        </mx:Box>
        <mx:Box height="100%" width="33.4%" borderStyle="solid" borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box02">
        </mx:Box>

    </mx:HBox>
    <mx:HBox width="100%" height="33.3%" horizontalGap="0" verticalGap="0">

        <mx:Box height="100%" width="33.3%" borderStyle="solid" borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box10">
        </mx:Box>
        <mx:Box height="100%" width="33.3%" borderStyle="solid" borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box11">
        </mx:Box>
        <mx:Box height="100%" width="33.4%" borderStyle="solid"  borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box12">
        </mx:Box>

    </mx:HBox>
    <mx:HBox width="100%" height="33.4%" horizontalGap="0" verticalGap="0">

        <mx:Box height="100%" width="33.3%" borderStyle="solid"  borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box20">
        </mx:Box>
        <mx:Box height="100%" width="33.3%" borderStyle="solid"  borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box21">
        </mx:Box>
        <mx:Box height="100%" width="33.4%" borderStyle="solid"  borderColor="#000000" backgroundColor="#ffffff"
            click="{img_click(event);}" id="box22">
        </mx:Box>

    </mx:HBox>

</mx:VBox>

<mx:Button click="{btn_click();}" />

</mx:Application>