Tutorial Flash 8 API for new features
Looking at the above figure, the API for the Flash8 feature is mainly concentrated in the following 4 blocks
1 Graphic effects
[Filters] A variety of filters-related classes that Blur shadows and obscure these effects
Add to your MC.
[Geometry Classes] offers a variety of color transformations such as Matrix, point, Rectangle and Colortransforms
[MovieClip Extensions] In addition to allowing the MC to use filter,
Geometry outside. [Blending Modes] is also available. Can let each of the MC
The color of the dots is combined with the background, which can add a lot of effects. [Bitmap
Caching] can let a MC [Cacheasbitmap]. As a bitmap cache,
Not every time the vector calculation, improve the performance.
[Bitmap Display] provides access to bitmap accuracy to pixels
2 text effects:
[TextField Extensions],flash Some TextField in the central Plains
Added filter[filter] You can also define sharpness,thickness.
[Text Renderer control], text rendering method, such as
Antialiastype,colortype,gridfittype.
3 Files:
[Filereference]: For file upload and download
4 External interface
[Externalinterface]: for Flash and JavaScript
XML, the interaction.
The main classes are as follows:
BitmapData
BitmapData. Channel
Button
Externalinterface
Filereference
Filereferencelist
Filters
Bevelfilter
Bitmapfilter
Bitmapfilter. Quality
Bitmapfilter.type
Blurfilter
Colormatrixfilter
Convolutionfilter
Displacementmapfilter
Dropshadowfilter
Glowfilter
Gradientbevelfilter
Gradientglowfilter
Mode
Geom
ColorTransform
Matrix
Point
Rectangle
Transform
MovieClip
MovieClip. Blendmodetype
Text
TextRenderer
TextRenderer. Antialiastype
TextRenderer. ColorType
TextRenderer. FontStyle
TextRenderer. Gridfittype
TextField here for the fastest speed. Just use MTASC and writing books.
The method is as follows:
1 in
http://www.mtasc.org/Download Mtasc, extract to d:/mtasc/[any catalogue]
2 Add d:/mtasc/to Classpath.
3 new sonny.as in d:/mtasc/, code as follows:
Class Sonny {
function Sonny () {
var sonny_mc:movieclip = _root.createemptymovieclip ("Sonny", _root.getnexthighestdepth ());
sonny_mc._x = sonny_mc._y=100;
Sonny_mc.beginfill (0xff6633, 100);
Sonny_mc.moveto (0, 0);
Sonny_mc.lineto (100, 0);
Sonny_mc.lineto (100, 100);
Sonny_mc.lineto (0, 100);
Sonny_mc.lineto (0, 0);
var blurtest = new Flash.filters.BlurFilter ();
Blurtest.clone = true;
Blurtest.blurx = 20;
Blurtest.blury = 20;
Sonny_mc.filters = [Blurtest];
}
static function main () {
var tmp = new Sonny ();
}
}
Code Explanation:
First a new SONNY_MC is created, and then an Orange square is drawn in the middle.
And then through the blurfilter added a blur effect on the square
4 new Sonny.bat
Mtasc-header 300:300:25-main-version 8 sonny.as-swf sonny.swf
Pause
Double-click Sonny.bat. You can see the sonny.swf
You can see that the edge is a good blur effect as follows:
Environment: Windows system, Flash mx2004 Chinese version
1 into C:\Documents and Settings\
Your name\local Settings\Application Data\Macromedia\Flash MX 2004\zh_cn\configuration\publish Profiles
Note that the your name here is the username for your Windows system.
Will default.xml copy a copy. Named Flash8.xml. Will
Line 2nd <flash_profile version= "1.0" name= "Default File" >
Default file changed to Flash8
64 Lines <Version>7</Version> 7 to 8
2 Reboot the Flash8. In the release settings, click the Import button that follows the current configuration
and poured into Flash8.xml. Click OK below. As shown in the figure:
Good. Do a test right away:
Create a new FLA and add the following code to the Flash frame:
Create TextField
This.createtextfield ("Txtfield", This.getnexthighestdepth (), 10, 10, 300, 100);
Txtfield.html = true;
Txtfield.htmltext = "<font size=60>http://www.study-i.com"; ' target=_blank>http://www.study-i.com</ Font> ";
Txtfield.textcolor = 0x0055cc;
Txtfield.antialiastype = Flash.text.TextRenderer.AntiAliasType.ADVANCED;
var DropShadow = new Flash.filters.DropShadowFilter ();
Dropshadow.blurx = 5;
Dropshadow.blury = 5;
Dropshadow.distance = 3;
Dropshadow.angle = 35;
Dropshadow.quality = 2;
Dropshadow.alpha = 0.5;
Txtfield.filters = [DropShadow]; published. Attention. To see in IE. Because you typically only update the player in IE.
If there is a noticeable shadow underneath the word. It worked. The results are shown in the following illustration:
Let's take a look at the following example:
There are 3 photos:
GIF pictures are as follows:
PNG pictures are as follows
JPG pictures are as follows:
In Flash8, we can load them into flash.
Create a new FLA and add the following as code:
Stage.scalemode = "Noscale";
URLs = ["Progressive.jpg", "Test2.png", "test1.gif"];
var i = 0;
while (I < 3) {
var cl = this.createemptymovieclip ("Test" + I, i + 1);
Cl.createemptymovieclip ("Holder", 1);
Cl.holder.loadMovie (Urls[i]);
cl.onpress = function () {
This.startdrag ();
};
Cl.onrelease = function () {
This.stopdrag ();
};
i++;
The final results are as follows:
Look at the main methods of the Externalinterface class. As you can see, the Externalinterface class is primarily used to interact with XML and JavaScript.
_arraytoxml
_argumentstoxml
_objecttoxml
_toxml
_objecttoas
_arraytoas
_argumentstoas
_toas
_arraytojs
_objecttojs
_tojs
JavaScript to Flash
ActionScript
import Flash.external.ExternalInterface;
Class Externalinterfacetest
{
Public Function Externalinterfacetest ()
{
The first parameter is the function name exposed to JavaScript
The second argument is the real call
Externalinterface.addcallback ("Actionscriptfunction", actionscriptfunction);
}
Public Function Actionscriptfunction (input:string): String
{
Trace (input);
return input;
}
}html/JavaScript
</script>
Flash to JavaScript
InHTML page:
</script>
ActionScript
Import Flash.external.ExternalInterface;
}
You can refer to the following documentation:
Http://livedocs.macromedia.com/central/sdk/1_5/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Central_SDK &file=00000275.htm
The main methods of Filereference are 2:
The main methods are 2, browse (),
Post-click Popup File Selection box
Upload () If you upload the server script is sonny.jsp.
The upload can be written as
Upload ("sonny.jsp", "POST"); Upload common events are as follows:
Onuploadstart: Start uploading
Onuploadprogress Upload Progress
Onuploadsuccess Upload Successful
Onuploadfailed upload failed
OK, here's an example. Because there is no server support. The main introduction of the Browse section.
Create a new FLA, and then create a SONNY_MC and a sonny_txt on root [dynamic text]
Put the following script on the frame:
var fileref = (new Flash.net.FileReference ());
Sonny_mc.onrelease = function () {
if (Fileref.browse ()) {
Sonny_txt.text = "File Name:" + fileref.name;
}
};
Publish it. Look at the effect in the browser.
In general, the filter class is used to divide into 3 steps.
1 Setting the Filter object
2 define each parameter of the filter
3 Set the filters property of the MC with the effect to the array of the Filter object. The following is shown:
var myfilter = new Flash.filters.DropShadowFilter ();
Customize the filter through public properties
Mc.filters = [Myfilter];
A classic example is shown below. Shows the blur, Shadow, outer glow, inner glow Four effects (//blur,//shadow,//glowfilter (outer),//Glowfilter (inner))
Create a new FLA, draw a square, clearly named Clip_0 to Clip_3, and add the following code to the frame.
var myblur = new Flash.filters.BlurFilter ();
Myblur.clone = true;
Myblur.blurx = 20;
Myblur.blury = 20;
Clip_0.filters = [Myblur];
var Myshadow = new Flash.filters.DropShadowFilter ();
Myshadow.strength = 1;
Myshadow.blurx = 20;
Myshadow.blury = 20;
Myshadow.angle = 45;
Clip_1.filters = [Myshadow];
var myglow = new Flash.filters.GlowFilter ();
Myglow.strength = 1;
Myglow.blury = 20;
Myglow.blurx = 20;
Myglow.inner = false;
Myglow.color = 0xff0000;
Myglow.strength = 1;
Myglow.angle = 45;
Clip_2.filters = [Myglow];
var myglow = new Flash.filters.GlowFilter ();
Myglow.strength = 1;
Myglow.blury = 20;
Myglow.blurx = 20;
Myglow.inner = true;
Myglow.color = 0x000000;
Myglow.strength = 1;
Myglow.angle = 45;
Clip_3.filters = [Myglow];
You can see the following effects:
This paper mainly introduces the bitmap[bitmap class in Flash. Specifically, flash.display.BitmapData .
Mainly have SetPixel, getpixel, through these 2 aspects to provide the pixel operation on the bitmap
Let's take a look at an example right away:
Create a new FLA and place the following code on the frame:
var img_bmp = new Flash.display.BitmapData (256,256,true);
for (var y:number=0; y<256; y++) {
for (var x:number=0; x<256; x + +) {
var a:number = y;
var r:number = x;
var g:number = 256-x;
var b:number = 256-y;
var c:number = (a<<24) | (r<<16) | (g<<8) | (b<<0);
Img_bmp.setpixel32 (X,Y,C);
}
}
_root.createemptymovieclip ("BMP", 1);
_root.bmp.attachbitmap (Img_bmp, 2);
Release. The results appear as follows:
Here is an example of learning a foreign website, the code is as follows:
Pixelsize = 5; var contain = _root.createemptymovieclip ("contain", 1);
Contain._y = 235; BitmapData = new Flash.display.BitmapData (+, false);
Contain.attachbitmap (BitmapData, 1);
Bitmapdata.draw (clip);
for (var x=0; x<300/pixelsize; x + +)
{
for (var y=0; y<225/pixelsize; y++)
{
var seed = _root.bitmapdata.getpixel (x*pixelsize, y*pixelsize);
for (var a=0; a<pixelsize; a++)
{
for (var b=0; b<pixelsize; b++)
{
_root.bitmapdata.setpixel (X*pixelsize+a, y*pixelsize+b, Seed);
}
}
}
}
The results of the operation are as follows, the upper part of the figure is the original image, and the lower part is the resulting pixel graph: