476
Animation, Filters, and Drawings
To change an image’s brightness:
1.
Create a new Flash document called
brightness.fla
.
2.
Select Frame 1 of the Timeline and add the following code to the Actions panel:
import flash.filters.ColorMatrixFilter;
System.security.allowDomain("http://www.helpexamples.com/");
var mcl_obj:Object = new Object();
mcl_obj.onLoadInit = function(target_mc:MovieClip):Void {
var myElements_array:Array = [1, 0, 0, 0, 100,
0, 1, 0, 0, 100,
0, 0, 1, 0, 100,
0, 0, 0, 1, 0];
var myColorMatrix_filter:ColorMatrixFilter = new
ColorMatrixFilter(myElements_array);
target_mc.filters = [myColorMatrix_filter];
}
this.createEmptyMovieClip("img_mc", this.getNextHighestDepth());
var img_mcl:MovieClipLoader = new MovieClipLoader();
img_mcl.addListener(mcl_obj);
img_mcl.loadClip("http://www.helpexamples.com/flash/images/image2.jpg",
img_mc);
This block of code uses the MovieClipLoader class to load an external JPEG. When the
image successfully loads, the MovieClipLoader class onLoadInit event handler is called
and modifies the image brightness to 100 using the ColorMatrixFilter filter.
3.
Select Control > Test Movie to test the document.
The image that you load into the SWF file changes its brightness when you test the SWF
file. View the image online (
http://www.helpexamples.com/flash/images/
image2.jpg
) to see the original appearance of the image.
For an example of scripted animation in Flash, you can find a sample source file,
animation.fla, in the Samples folder on your hard disk.
■
In Windows, browse to
boot drive
\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Animation.
■
On the Macintosh, browse to
Macintosh HD
/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/Animation.
You can also find samples of photo gallery applications on your hard disk. These files provide
examples of how to use ActionScript to control movie clips dynamically while loading image
files into a SWF file, which includes scripted animation. You can find the sample source files,
gallery_tree.fla and gallery_tween.fla, in the Samples folder on your hard disk.
■
In Windows, browse to
boot drive
\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\Galleries.
Содержание FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH
Страница 1: ...Learning ActionScript 2 0 in Flash...
Страница 8: ...8 Contents...
Страница 18: ...18 Introduction...
Страница 30: ...30 What s New in Flash 8 ActionScript...
Страница 66: ...66 Writing and Editing ActionScript 2 0...
Страница 328: ...328 Interfaces...
Страница 350: ...350 Handling Events...
Страница 590: ...590 Creating Interaction with ActionScript...
Страница 710: ...710 Understanding Security...
Страница 730: ...730 Debugging Applications...
Страница 780: ...780 Deprecated Flash 4 operators...
Страница 830: ...830 Index...