Make Flash Animations, Video, Slideshows, Text Effects, Buttons & Menus. Designer Templates, 250 Effects, plus Components & Video Controls

简体中文 繁體中文 Français Español Italiano 日本 Polski Deutsch SWiSHzone.com
SWiSHzone.com Banner
You are here: Home > Community > Tutorials
Community
FREE TOOLS!
Laboratory
Community Overview
Movies
Components
Effects
Screencast Tutorials
> Tutorials
Official Blog
Forums
Other Forums
Request help
Search Tutorials

 All words
 Any words

 Similar words
 Exact words

Number of Results:
Monthly Newsletter
Get our monthly newsletter for all the latest news
competitions, tutorials and tips > Sign Up Now

SWiSH Max: Making SWiSHMax Puzzle Game in 5 minutes
Creator: Ali Imran
Website: http://www.swish-db.com
Submitted: Wed Nov 24 2004
Description: Make your own SWiSHMax Puzzle Game in 5 minutes!
Zip File: Download


Making SWiSHMax Puzzle Game in 5 minutes

Preview:
Content Partner



Swish-DB.com

Swish-DB.com is an amazing SWiSH community with hundreds of tutorials and resources.

Feature of this tutorial:
User do not need to define/write any actionscript for any button (just copy and paste).

Steps:
  • Start new empty SWiSH Max file
  • Insert desired image or draw rectangle and use Titled Image but dimensions of the the shape must be round (e.g. 201 not 201.2)
  • Break the shape into desired number of pieces using desired columns and rows e.g. 4 and 4. so the total pieces become (4x4) 16.
  • These pieces will automatically be grouped, you simply UpGroup them by pressing Ctrl+U.
  • Select all shapes click Convert to Button. So that each shape is converted into separate button.
  • Now rename the buttons in series are they are ordered, from top to bottom as b1,b2,b3, upto b16.
  • Slect the button, which you want be acting as blank piece, and set its alpha to 0
  • Now paste following code in you main timeline:
    onLoad() {
       bw=b1._width;
       bh=b1._height;
       blankPiece = b13; //
       Result = new Array();  
       
       TOTAL_PIECES = 16;
       
       swap = function (obj1, obj2) {
           temp = new Object();
           temp._x=obj1._x;
           temp._y=obj1._y;
           
           obj1._x=obj2._x;
           obj1._y=obj2._y;
           
           obj2._x=temp._x;
           obj2._y=temp._y;
           delete temp;
       };
       
       cx=cy=0;
       for(i=TOTAL_PIECES; i>0; i--) {
           btn = eval("b"+i);
           Result[i]=new Object();
           Result[i].XX = btn._x;
           Result[i].YY = btn._y;
           
           btn.useHandCursor=false;
           if(btn == blankPiece)
               continue;
           btn.onRollOver = function() {
               this._alpha=50;
           };
           btn.onRollOut = function() {
               this._alpha=100;
           };
           btn.onPress = function() {
               if( //TOP
               blankPiece._x==this._x &&
               blankPiece._y==this._y-bh
               ) {
                   swap(this,blankPiece);
                   this._alpha=100;
               } else
               if( //LEFT
               blankPiece._x==this._x-bw &&
               blankPiece._y==this._y
               ) {
                   swap(this,blankPiece);
                   this._alpha=100;
               } else
               if( //BOTTOM
               blankPiece._x==this._x &&
               blankPiece._y==this._y+bh
               ) {
                   swap(this,blankPiece);
                   this._alpha=100;
               } else
               if( //RIGHT
               blankPiece._x==this._x+bw &&
               blankPiece._y==this._y
               ) {
                   swap(this,blankPiece);
                   this._alpha=100;
               }        
               if(CheckMove()) {
          gameWon();          
               }
           };
       }
       RandomShuffle = function (N) {
           for(i=0; i0; i--) {
               bt = eval("b"+i);
               bt._x=Result[i].XX;
               bt._y=Result[i].YY;
           }
       };
       CheckMove = function() {
           for(i=TOTAL_PIECES; i>0; i--) {
               bt = eval("b"+i);
               if(bt._x != Result[i].XX
                   || bt._y != Result[i].YY)
               return false;
           }
           return true;
       }
    }
    

  • Change the button name in following line of code I had b13 acting as blank piece you may assign any button name which is used as blank piece
      blankPiece = b13;
    

  • Then assign the value to variable TOTAL_PIECES as the number of pieces. If you have 16 buttons, just assign 16 to it e.g.
       TOTAL_PIECES = 16;
    
    GAME IS READY NOW....


    Some more instructions for Moderte and Advanced Level Scriptors

    I. To refresh the board use fucntion RefreshAll()
    on(press) {
      RefreshAll();
    }
    

    II. To shuffle blocks/pieces use
    on(press) {
      RandomShuffle(3);
    }
    
    where 3 is the number of shuffles, to make game more tough increase it

    Question: How to know the user has completed the game? Answer:
    implement function 'gameWin()' in your main timeline and write code in it what soever you wish to do when user wins, such as
    function gameWin() {
      Message = "Congratulations! You have compelted";
    }
    
    or even you may implement it within onLoad event handler of the main timeline such as
    onLoad() {
       ......
       ......
       ......
       ......
       ......
       ......
       
       gameWin = function() {
    	Message = "Congratulations! You have compelted";
       };
    }
    
    Recomendation:
    To have 100% results use image of same width and height and put image on round position before cutting in pieces (as X:110, Y:112 not X:110.3, Y:112.45)

    Click here to View Online functional Example
    Click here to download Example File

    Regards
    Ali Imran
    CEO www.swish-db.com


  • Search | Privacy policy | Contact us | Site Map | Copyright SWiSHzone.com Pty Ltd 1999-2010