[Part 3 of 8]
Take a look at the following startMovie handler. Some global variables are declared and then assigned values. The stepNumber variable is used determine how many modification steps have already been performed, and therefore, how blocky the next modification will be. The gSourceMember variable contains a reference to the original cast member-we'll be referencing that each time a new modification takes place. The gSourceImage variable will be a reference to the new cast member being created. The image of the original graphic is placed in the new cast member, and the sprite is set to use this new member instead of the original. Each time a modification is performed, the resulting image will be placed in that new cast member and the modified image will show on the Stage. If you have your Cast window open when the new(#bitmap) command is issued, you'll see the new cast member appearing in the Cast.
on startMovie global stepNumber -- For counting the morphing steps global gSourceImage -- Our new working cast member global gSourceMember -- The original cast member stepNumber = 1 -- Create a new bitmap to contain the -- image that will be modified, so we -- don't mess with the original. gSourceImage = new(#bitmap) gSourceImage.name = "SourceImage" gSourceImage.image = sprite(1).member.image -- Create a reference to the sprite's -- original member gSourceMember = sprite(1).member -- Set the sprite's member to the (for now) -- identical new member sprite(1).member = gSourceImage end
There is also a stopMovie hander that removes the newly created cast member from the cast. Otherwise, you'll get a new cast member each time you run the movie.
on stopMovie -- Remove the new bitmap, otherwise we'll -- get a new one each time the program -- runs. global gSourceImage if not voidP(gSourceImage) then erase gSourceImage gSourceImage = void end if end
For starters, you might want to comment out the stopMovie handler so your modified image will still be visible when the movie stops. When you're comfortable with what you're seeing you can uncomment it again.
With the setup taken care of, it's time to write a mouseUp handler for the button that will perform the modification. This is where we begin using imaging Lingo, starting with the image function. The image keyword actually comes in two flavors. As a property, it can be used to access an image of a bitmap or text cast member, the Stage, or a window. To save a copy of the Stage, for example, you might issue a command such as:
member("saveStage").image = (the Stage).image