Home > Articles

  • Print
  • + Share This

[Part 2 of 8]

The theory behind the mosaic-type transition that we are going to make is simple. If you copy an image into a box that is only one-fourth as big, you loose three quarters of the pixels. If you then copy the image back into a box the same size as the original, you don't get back the information that was lost. Instead, each pixel is duplicated in three others to make up the added space. You can consider the modified image to be made up of blocks of four identical pixels instead of single pixels. If you squint just right, the modified image will look almost like the original. If you perform the same operation with an increasingly smaller box, the resulting image will become progressively boxier. Because the boxes are created from the original image, the colors of the boxes will maintain a similarity to the original colors, providing the transition.

figure 1

When the image is boxy enough, the new image is slipped in, also boxy, and then the reverse process makes the new image come to view.

Let's start simple and create a script that performs one step for each mouse click on a button. For this movie, we'll need an image and a button, and then we'll write some handlers. You can follow along using you own image, or download the example file which contains the complete version. If you are creating your own movie from scratch, you should be able to copy the source for the handlers right from these pages as we discuss them.

Download mosaic1.dir

Getting weird characters when you try to download? Right-Click (Win) or Ctrl-Click (Mac) and use SAVE THIS LINK AS... and select SOURCE in the dialogue box

Place the image in sprite channel 1 and the button in sprite channel 2. Create an exitFrame handler in the behavior channel at the last frame of the sprites that loops on the frame:

on exitFrame me
  go to the frame
end

While you can actually modify the image of a cast member, doing so isn't such a good idea, for two reasons: Modifying a cast member means that you don't have the original anymore, and modifying a cast member is much slower than modifying an image object in memory. Since you can't modify a sprite's image, only the sprite cast member's image, we will need to have a cast member containing the modified image. We don't want to modify our original cast member, or we wouldn't be able to run the program more than once. The easiest fix is to create a new cast member, and that is what we'll do first. Later, we'll be creating image objects to perform the modifications, and one of those will then be placed in the new cast member.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

There are currently no related titles. Please check back later.