Using Sliding Puzzle AS2

Sliding Puzzle AS2 HelpSliding Puzzle AS2 Help

Help documentation and instructions about installing and using the Sliding Puzzle ActionScript 2.0 Component for Flash MX developed by someFrogs. 

Using Sliding Puzzle AS2 Component for Flash MX.

You can use a SlidingPuzzle component to build puzzles using your own pictures.

Sliding Puzzle ActionScript 2.0 Flash Component parameters

The following are authoring parameters that you can set for each SlidingPuzzle component instance in the Property inspector or in the Component Inspector panel:

picLinkage indicates a file reference to an external image (jpeg, swf) file or the linkage identifier of a movie clip symbol in the library that is set to Export for ActionScript. Additional explanation is provided in creating applicaions topic below for those who are not familiar to symbols in Flash.

puzzleRezH indicates one of the numbers (horizontal or vertical depending on dimensions of the picture) the picture will be divided to. This property is applied to bigger value of width and height if it is bigger than puzzleRezV. Available values are 2 to 12. The default value is 2.

puzzleRezV is the second resolution value and the multiply with puzzleRezH gives the total piece number of the puzzle. Available values are 2 to 12. The default value is 2.

autoStart is a Boolean value indicating if the puzzle shall start with the parameters set in the Property inspector or in the Component Inspector panel. If it's false a startPuzzle() command is expected to trigger the puzzle. True by default.

autoMix is a Boolean value indicating if the puzzle shall start mixing with the auto-calculated mix steps (5* pieceCount) immediately after start. If it's false a mixPuzzle(mixSteps) command is expected to trigger the mix. True by default.

You can write ActionScript to control these and additional options for SlidingPuzzle components using its properties, methods, and events. For more information, see SlidingPuzzle class Methods, Properties and Events documentation .

Creating an application with the Sliding Puzzle ActionScript 2.0 Component

The following procedure explains how to add a SlidingPuzzle component to an application while authoring.

To create an application with the SlidingPuzzle AS2 Flash component, do the following:

a) Importing the picture and converting it to symbol (skip this step if you want to render an external image file)

  1. Select File > Import to Stage.
  2. In the Import dialog box, select your picture file and click Open. Your picture must appear on the stage.
  3. Select your picture, select Modify > Convert to Symbol (or pres F8). In the Convert to Symbol dialog select Movie Clip as Behavior, Top-Left corner as registration, click Advanced button if the dialog is in Basic mode, select Export for ActionScript and Export in first frame,
  4. Enter myPicture in the Identifier field and click Ok.
  5. Delete the picture from the stage or resize it as a thumbnail to give visual idea to your users about the result of the puzzle.

Now you have your picture in your Library panel, marked as Export for ActionScript with Linkage Identifier myPicture and you are ready to continue with step b.

b) Setting Sliding Puzzle ActionScript 2.0 Flash Component to render the picture.

  1. Drag a SlidingPuzzle component from the Components panel to the Stage.
  2. Resize the component so it can contain the picture and some free space to be left in order to users can handle with the pieces.
  3. In the Property inspector, enter the instance name myPuzzle.
  4. In the Property inspector, enter myPicture or somedir/somefile.jpg for the picLinkage parameter and numbers between 2 and 12 for puzzleRezH and puzzleRezV.
  5. Select Control > Test Movie.

c) Adding a done listener to the puzzle.

  1. Select Frame 1 in the Timeline, open the Actions panel, and enter the following code:
    puzzleListener = new Object;puzzleListener.done = function() {  trace("the puzzle is done"); }myPuzzle.addEventListener("done", puzzleListener);   

    This block of code creates an event handler for the done event that sends a message to the Output panel.

Sliding Puzzle AS2 Installation & UpgradeSliding Puzzle AS2 Class

Sliding Puzzle AS2
Sliding Puzzle AS2

Sliding Puzzle ActionScript 2.0 is a Flash MX UI Component developed and packed as Extension by someFrogs. You can build and publish your own sliding puzzles easy if you are a litle familiar to Flash MX. Sliding Puzzle ActionScript 2.0 Component can render any external image (jpeg, swf and formats supported by Flash MX Player) file or any symbol in the Flash's library as a sliding puzzle.