A couple of tips related to imaging Lingo and color conversion.
While you can capture an image of the Stage as easily as saying:
myImage = _movie.stage.image.duplicate()
You don't have much control. The following method allows you to capture any portion of the Stage, and resize it on the fly, returning a new image object:
on screenGrab newWidth, newHeight, croppingRect newIm = image(newWidth, newHeight, 24) newIm.copyPixels(_movie.stage.image, newIm.rect, croppingRect) return newIm end
This will then return an image that is the width and height you specify, and captured within the rectangle specified by croppingRect. For instance, if you have an 800 x 600 Stage, and want to turn it into a 320 x 240 thumbnail, you would use:
myImage = screenGrab(320, 240, rect(0, 0, 800, 600))
If you wanted to capture a particular sprite's image:
myImage = screenGrab(640, 480, sprite(1).rect)
This would create a 640 x 480 image of the area defined by sprite(1)'s rect.
Cross-Fading from any Frame
Not long ago I was finishing work on a large CD project when the client decided they wanted the previous screen to fade out whenever they navigated to a new screen. They didn't want to ante up for an Xtra, so I used a bit of creative imaging Lingo instead.
Essentially, it works like this: you place a small bitmap in a higher sprite channel than any other sprite in your movie. You then stretch this bitmap sprite so it covers the entire Stage. You can use a 100 x 100 bitmap, or even smaller, and stretch it appropriately. Next, you attach a simple behavior to the sprite that causes it to fade out:
property myCount on beginSprite me myCount = 0 end on enterFrame me if myCount < 21 then sprite(me.spriteNum).blend = 100 - (myCount * 5) myCount = myCount + 1 end if end
The first time through, myCount will be 0 and the blend of the sprite will be set to 100 (0 * 5), which of course is 100. On the 20th time through, myCount will be 20 and the blend will be 0. Thus, the sprite fades out over the course of 20 frames. Simple enough.
The real trick is in creating the frame behavior that gets attached to any frames you'll be navigating to, and want to fade in. The frame behavior takes an image of the previous frame and copies it into the bitmap holder you created, which then fades out because of the behavior attached to it. The frame behavior is as follows:
on prepareFrame me myIm = _movie.stage.image.duplicate() sprite(5).member.image = myIm sprite(5).blend = 100 end
The trick, of course, is in using the prepareFrame handler, which is executed before the new frame is drawn. Therefore, you get the image of the frame you're coming from, which fades out and leaves the frame you're going to. In this manner you can fade into any frame from any other frameall without an Xtra.
If you do want to use an Xtra instead, a popular maker of transition Xtras is DMTools, located at www.dmtools.com
You can use Lingo's color object to easily convert between different color values:
RGB to CMYK
The following method will allow you to turn an RGB color into a CMYK color.
on toCMYK RGBval c = ( 255 - rgbval.red ) / 255.0 m = ( 255 - rgbval.green ) / 255.0 y = ( 255 - rgbval.blue ) / 255.0 k = min ([c,m,y]) return [#c:c, #m:m, #y:y, #k:k] end
To use the method, place it in a movie script and call it, passing an RGB color in as the parameter:
trace(toCMYK(rgb(255, 120, 0))) -- [#c: 0.0000, #m: 0.5294, #y: 1.0000, #k: 0.0000]