var mclListener:Object = new Object();
mclListener.onLoadInit = function(target_mc:MovieClip) {
var blendModeClip:MovieClip =
target_mc.createEmptyMovieClip("blendModeType_mc", 20);
with (blendModeClip) {
beginFill(0x999999);
moveTo(0, 0);
lineTo(target_mc._width / 2, 0);
lineTo(target_mc._width / 2, target_mc._height);
lineTo(0, target_mc._height);
lineTo(0, 0);
endFill();
}
target_mc._x = (Stage.width - target_mc._width) / 2;
target_mc._y = (Stage.height - target_mc._height) / 2;
blendModeClip.blendMode = blendMode_cb.value;
};
this.createEmptyMovieClip("img_mc", 10);
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mclListener);
img_mcl.loadClip("http://www.helpexamples.com/flash/images/image1.jpg",
img_mc);
function cbListener(eventObj:Object):Void {
img_mc.blendModeType_mc.blendMode = eventObj.target.value;
}
blendMode_cb.addEventListener("change", cbListener);
This ActionScript code populates the combo box with each type of blending mode, so the
user can view each effect on the dynamically loaded image. A listener object is created,
which is used with a MovieClipLoader instance. The listener object defines a single event
listener,
onLoadInit
initialized by Flash. The event listener creates a new movie clip named
blendModeType_mc
half of the image. The currently selected blending mode for the ComboBox instance is
then applied to the
The rest of the code sets up the MovieClipLoader instance, which is responsible for
loading the specified image into a movie clip on the Stage. Finally, a listener is defined for
the
blendMode_cb
whenever a new item is selected from the ComboBox instance.
4.
Select Control > Test Movie to test the document.
, which is invoked when the image is completely downloaded and is
, and uses the Drawing API to draw a rectangular shape over the left
blendModeType_mc
ComboBox instance, which applies the selected blending mode
movie clip.
About blending modes
539
Need help?
Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?
Questions and answers