Flash8 Learning: Examples of fuzzy filters

Source: Internet
Author: User
Tags define imageclip numeric net variables
Filter

Effect:

This is FLASH8 help inside the file, Han part of the hope that everyone short complement, the picture link has been made into a SWF file, loaded into the main file, the example of the use of 3 components, respectively: CheckBox. ComboBox. Numericstepper.
The as frame code is as follows:


System.security.allowDomain ("http://www.helpexamples.com");
Import Flash.filters.DropShadowFilter;
Import Flash.filters.BlurFilter;
Declare Two Boolean variables that determine
Whether or not to use the corresponding filters.
Initialize both to false.
var Isdropshadow:boolean = false;
var Isblur:boolean = false;
Declare Some variables that specify properties
for the filters.
var dropshadowdistance:number = 10;
var dropshadowangle:number = 40;
var dropshadowblur:number = 4;
var bluramount:number = 10;
ADD event listeners to the components.
Imagecb.addeventlistener ("Change", toggleimage);
Dropshadowch.addeventlistener ("click", Toggledropshadow);
Dropshadowdistancens.addeventlistener ("Change", updatedropshadowproperties);
Dropshadowblurns.addeventlistener ("Change", updatedropshadowproperties);
Dropshadowanglens.addeventlistener ("Change", updatedropshadowproperties);
Blurch.addeventlistener ("click", Toggleblur);
Bluramountns.addeventlistener ("Change", updateblurproperties);
Set The data provider of the image ComboBox. Use
Loaded external SWF picture movie
Imagecb.dataprovider = [{label: ' Image 1 ', Data: ' http://media.163888.net/virtualdir1/2005/10/25/19/Flash/ 29659091551783.swf "},
{label: "Image 2", Data: "Http://media.163888.net/virtualdir1/2005/10/25/19/Flash/29659091858160.swf"},
{label: "Image 3", Data: "http://media.163888.net/virtualdir1/2005/10/25/19/Flash/29659092104237.swf"}];
Set properties of the components.
Dropshadowch.label = "Shadow";
Dropshadowdistancens.maximum = 50;
Dropshadowdistancens.value = 10;
Dropshadowanglens.maximum = 360;
Dropshadowanglens.stepsize = 10;
Dropshadowanglens.value = 40;
Dropshadowblurns.value = 4;
Blurch.label = "Fuzzy";
Bluramountns.maximum = 20;
Bluramountns.value = 10;
Define a listener object to use with the
Moviecliploader object. When the image loads
Into the player, set the Loading Image label ' s
Visibility to false.
var imagelistener:object = new Object ();
Imagelistener.onloadinit = function (clip:movieclip): Void {
Loadingimagelbl.visible = false;
};
Make a movie clip in order to display the images.
Nest a movie clip within
The images into the nested clip. The nested clip
is necessary because once the image of loaded into
The clip, you cannot apply filters to it. You can,
However, apply filters to the parent clip.
This.createemptymovieclip ("Imageclip", 1);
Imageclip.createemptymovieclip ("Nestedclip", 1);
Place the movie clip.
imageclip._x = 155;
imageclip._y = 80;
Define the Moviecliploader instance.
var imageloader:moviecliploader = new Moviecliploader ();
Imageloader.addlistener (Imagelistener);
Load the image from the ' The ' combo box item into
The nested clip.
Imageloader.loadclip (Imagecb.value, Imageclip.nestedclip);
When the user selects a different image from
The combo box, display the Loading Image label,
and load the new image.
function Toggleimage (event:object): Void {
Loadingimagelbl.visible = true;
Imageloader.loadclip (Imagecb.value, Imageclip.nestedclip);
}
Set the value of Isdropshadow to match the
Checked state of the check box.
function Toggledropshadow (event:object): Void {
Isdropshadow = event.target.selected;
SetFilters ();
}
Set the value of Isblur to match the checked
State of the check box.
function Toggleblur (event:object): Void {
Isblur = event.target.selected;
SetFilters ();
}
Set the property variables according to the
Numeric stepper values.
function Updatedropshadowproperties (event:object): Void {
Dropshadowdistance = Dropshadowdistancens.value;
Dropshadowblur = Dropshadowblurns.value;
Dropshadowangle = Dropshadowanglens.value;
SetFilters ();
}
Set Bluramount According to the numeric stepper.
function Updateblurproperties (event:object): Void {
Bluramount = Bluramountns.value;
SetFilters ();
}
function SetFilters (): Void {

Define a new array for the filters.
var filtersarr:array = new Array ();

If Isdropshadow is true, make a new
Dropshadowfilter object, and add it to the array.
if (Isdropshadow) {
var dropshadow:dropshadowfilter = new Dropshadowfilter (dropshadowdistance, Dropshadowangle, 0, DropShadowBlur, Dropshadowblur);
Filtersarr.push (DropShadow);
}
If Isblur is true, make a new Blurfilter object,
and add it to the array.
if (Isblur) {
var blur:blurfilter = new Blurfilter (Bluramount, Bluramount);
Filtersarr.push (Blur);
}

Assign the filters array to the filters property
of Imageclip in order that the filters would
Get applied.
Imageclip.filters = Filtersarr;

My e-text is not good, I hope you can add.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.