Characteristics

  • An 11 x 8 grid of things
  • things exists in one of two states—either up or down
  • Starting condition is boeard is drawn and things are placed on
    the grid and randomly assigned an up or down state
  • Winning condition is to get all things in down state

Rule

When the player clicks on a thing, all adjacent things reverse their state.

Pseudocode:
    if (thing is clicked){
        invert state of thing
        invert state of thing above
        invert state of thing below
        invert state of thing to right
        invert state of thing to left
    }


  1. Create a new Flash Document 700 x500 with a 62 fps rate.

  2. Import your image if you are using an existing image.

  3. Create a new movie clip symbol (+F8) and call it thing
    or

  4. Create another movie clip and name it hole

    1. Name layer 1 ground

    2. Create a colored square 60 x 60 pixels with the registration at the top left corner:


    3. Create a new layer and name it hole. Use the Color Mixer and the Oval tool to create a shape with a gradient fill:


    4. Create a new layer and name it thing

    5. Drag an instance of thing from library and place it in the hole:


    6. Create a new layer and call it mask. Paint over thing:


    7. CTRL+click on layer and create a mask.

    8. On thing layer click on frame 20 and insert a keyframe.

    9. CTRL+click to create a motion tween

    10. Insert a keyframe at 10 and move image to up position (you may have to unlock it first)


    11. In frame 20 of other layers, insert a frame

    12. Create a new layer and name it Actions

    13. Click on frame 1 and open Actionscript window. Add:
      this.onRelease=this._parent.thingClick;
      stop();
      


    14. Click on frame 10 and open Actionscript window. Add the same code:
      this.onRelease=this._parent.thingClick;
      stop();
      


  5. Click on Scene 1.

  6. In Library set the linkage property of hole


  7. Create a new layer and name it Actions

  8. You want to place your tiles on a grid.If w=tile.width and h=tile.height:
    (0*w),(0*h) (1*w),(0*h) (2*w),(0*h) (3*w),(0*h) (4*w),(0*h) (5*w),(0*h) (6*w),(0*h) (7*w),(0*h) (8*w),(0*h) (9*w),(0*h) (10*w),(0*h)
    (0*w),(1*h) (1*w),(1*h) (2*w),(1*h) (3*w),(1*h) (4*w),(1*h) (5*w),(1*h) (6*w),(1*h) (7*w),(1*h) (8*w),(1*h) (9*w),(1*h) (10*w),(1*h)
    (0*w),(2*h) (1*w),(2*h) (2*w),(2*h) (3*w),(2*h) (4*w),(2*h) (5*w),(2*h) (6*w),(2*h) (7*w),(2*h) (8*w),(2*h) (9*w),(2*h) (10*w),(2*h)
    (0*w),(3*h) (1*w),(3*h) (2*w),(3*h) (3*w),(3*h) (4*w),(10*h) (5*w),(3*h) (6*w),(3*h) (7*w),(3*h) (8*w),(3*h) (9*w),(3*h) (10*w),(3*h)
    (0*w),(4*h) (1*w),(4*h) (2*w),(4*h) (3*w),(4*h) (4*w),(10*h) (5*w),(4*h) (6*w),(4*h) (7*w),(4*h) (8*w),(4*h) (9*w),(4*h) (10*w),(4*h)
    (0*w),(5*h) (1*w),(5*h) (2*w),(5*h) (3*w),(5*h) (4*w),(10*h) (5*w),(5*h) (6*w),(5*h) (7*w),(5*h) (8*w),(5*h) (9*w),(5*h) (10*w),(5*h)
    (0*w),(6*h) (1*w),(6*h) (2*w),(6*h) (3*w),(6*h) (4*w),(10*h) (5*w),(6*h) (6*w),(6*h) (7*w),(6*h) (8*w),(6*h) (9*w),(6*h) (10*w),(6*h)
    (0*w),(7*h) (1*w),(7*h) (2*w),(7*h) (3*w),(7*h) (4*w),(10*h) (5*w),(7*h) (6*w),(7*h) (7*w),(7*h) (8*w),(7*h) (9*w),(7*h) (10*w),(7*h)
    Click on frame 1 and open Actionscript window. Add:
    COLUMNS=__;
    ROWS=__;
    TILE_X=__;
    TILE_Y=__;
    
    /*create an offset so that your character 
    stays on the screen */
    TILE_Y_OFFSET=10;
    
    init();
    
    
    //create function that draws grid
    function init(){
        var thingCount=0;
        //create a nested loop to create a matrix
        for (var i=0;i<COLUMNS;i++){
            //create a loop with var j between 0 and ROWS
            ____________________________________________    
                /*the upper left will be called "hole_0_0"
                the lower right "hole_10-7
                */
                var h=this.attachMovie("hole",("hole_"+i+"_"+j),thingCount++);
                
                //place the current tile on the board
                h._x=i*TILE_X;
                h._y=j*TILE_Y+______________;
                
                /*keep track of column and row for tile
                so that you can know where the adjacent
                things are*/
                h.column=__;
                h.row=__;
                
                /*create a conditional that
                calls Math.random() which returns a number 
                between 0 (inclusive) and 1(exclusive)
                and compares it to .5 so that
                you have aa 50/50 chance of playing 
                frame 1 or frame 10*/
                if(Math.random()>.5){
                    h.gotoAndPlay(10);
                }
            }
        }
        
    }
    //this fn is connectedto onRelease() of your hole mc
    function thingClick(){
        this.play();
        //changes the state of the tile to the left
        this._parent["hole_"+(this.column-1)+"_"+(this.row)].play();
        
        //changes the state of the tile to the right
        ___________________________________________________________
        
        //changes the state of the tile above
        ___________________________________________________________
        
        //changes the state of the tile below
        ___________________________________________________________
        
        /*this prevents multipleclicks while changing state,
        as well as, allows youto click on clip again
        after state change*/
        delete this.onRelease;
    }