Home > Articles

  • Print
  • + Share This

[Part 6 of 8]

The next manifestation of our movie adds the opposite behavior-starting with a fully-boxed image and ending up with a regular image. This version still uses a button to implement the transition, but provides a transition to a new image. With a little work, this sort of implementation could be used to progress through a series of images. You might, for example, create a list of member references and then cycle through them. The movie is simplified by using hard-coded references to the original and new images, but converting to variables would be simple. Here's the new version, including the second image (did I mention that that's me in the pictures?).

Download mosaic3.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

The startMovie and stopMovie handlers in the movie script are identical to the previous versions. The mouseUp handler is only changed by the addition of a global variable gOutgoing that lets the movie know whether the image is the "from" image getting boxy (gOutgoing = TRUE) or the "to" image that is getting less boxy.

on mouseUp
  global stepNumber, isTransforming, 
  isTransforming = TRUE
  stepNumber = 1
  gOutgoing = TRUE  
  -- Means alter the FROM image,
  -- as opposed to the NEXT image.

The exitFrame handler, on the other hand, has some extensive changes. Like the exitFrame handler in the mosiac2 movie, this behavior is intended to be dropped onto a sprite. Notice how the gOutgoing variable is used to determine whether the "from" image is being modified or the "to" image:

on exitFrame
  global stepNumber, isTransforming, 
         gOutgoing, gSourceImage
  if isTransforming = TRUE then
    w = member("crouchA").width
    h = member("crouchA").height
    -- Create an image object
    imSource = image(w, h, the colorDepth)
    -- Create an image object that is 
    -- smaller, but watch out for 
    -- divide-by-zero.
    if stepNumber <> 0 then
      imSmall = image(w/(stepNumber*4), 
                      the colorDepth)
      imSmall = image(w, h, the colorDepth)
    end if

    if gOutgoing then
      imSource = 
      stepNumber = stepNumber + 1
      if stepNumber > 10 then 
        stepNumber = 10
        gOutgoing = FALSE
      end if
      -- Now to bring in the new image
      -- New image needs to start off in 
      -- mosaic form
      imSource = 
      stepNumber = stepNumber - 1
      if stepNumber = -1 then 
        isTransforming = FALSE
      end if
    end if
    gSourceImage.image = imSource
    sprite(1).member = gSourceImage
  end if

For the outgoing modification process the same stepNumber counter is used, only this time it counts down instead of up. As the counter gets smaller, so do the sizes of the mosaics used in the modification. Everything else, such as the copyPixels operations, works pretty much the same as before.

  • + Share This
  • 🔖 Save To Your Account

Related Resources

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