Single Image role action processing

Source: Internet
Author: User

Read the article on the internet about this: Use the BitmapData class, to cut the picture. Personally feel less trouble. Also, sometimes we might put the game's vegetarian village into a vector. To reduce the volume of flash.
Here's a personal view.
Fortunately Flash8 gives us: the Movieclip.cacheasbitmap attribute, the vector map is cached as a bitmap. I can check the help:
Mentioned: It is a good idea to use the Cacheasbitmap property with movie clips that are primarily static content and that are not scaled and rotated frequently. For such a movie clip, Cacheasbitmap can improve performance when you convert a movie clip (changing its x and Y positions).
In this way we make a single action, just put all the action in vector form, into a MC, with rows and columns.
To use a program to control: put a movie symbol on it to mask, displaying the animation of the current one.
The material for this example is a bitmap.
/* Operating principle
Create a new empty movie symbol: "Mc_tablemovie" as the container for the animation, animate the picture and import it into the library. plus the connection symbol. I set this up as "1."
Then set a Tablemovie animation object to Mc_tablemovie, and the object automatically generates two mcimg in "Mc_tablemovie": An animated picture, Mcmask: A movie symbol for masking.
In _root.onenterframe, to do the loop play
*/
_root.createemptymovieclip ("Mc_tablemovie", _root.getnexthighestdepth ());
mc_tablemovie._x = 28;
Mc_tablemovie._y = 20;
Mc_tablemovie.attachmovie ("1", "Mcimg", mc.getnexthighestdepth ());
MC Container, Link number
Starx,stary the start of an animated element in a picture
Hang,lie: Rows, Columns
W,h: Wide, high
Movietype 0 Loop Display column//currently only 0 Type 1 loop show all
var Obj_mc_tablemovie:tablemovie = new Tablemovie (Mc_tablemovie, "1", 0, 0, 4, 4, 63, 93, 0, 1);
Obj_mc_tablemovie.sethang (3);
Keys
var numfx:number = 1;
var DISTANCE = 5;
//
_root.onenterframe = function () {
Obj_mc_tablemovie.go ();
As far as this picture is concerned, the state of each line of code in one Direction.
Obj_mc_tablemovie.sethang (NUMFX);
};
Key
Keyboard Detection///////////////
var keylistener_obj:object = new Object ();
Keylistener_obj.onkeydown = function () {
Switch (Key.getcode ()) {
Case Key.space:
Trace ("Space");
Break
Case Key.left:
NUMFX = 1;
Break
Case KEY.UP:
NUMFX = 3;
Break
Case Key.right:
NUMFX = 2;
Break
Case Key.down:
NUMFX = 0;
Break
}
};
Key.addlistener (Keylistener_obj);


Tablemovie class
Class Tablemovie {
public Var Mc:movieclip;
//
public Var Moivesd:number;
private var moivesd_i = 1;
//
private Var Mcimg:movieclip;
private Var Mcmask:movieclip;
//
private Var Starx:number;
private Var Stary:number;
private Var Hang:number;
private Var Lie:number;
private Var W:number;
private Var H:number;
private Var Ew:number;
private Var Eh:number;
Current
public Var Nx:number;
public Var Ny:number;
private Var Movietype:number;
//
MC Container, Link number
Starx,stary the start of an animated element in a picture
Hang,lie: Rows, Columns
W,h: Wide, high
Movietype 0 Loop Display column//Currently only makes 0 1 loops showing all
Current multiple of FPS moves MOIVESD
function Tablemovie (Mc:movieclip, linkid:string, Starx:number, Stary:number, Hang:number, Lie:number, W:Number, H: Number,
Movietype:number, Moivesd:number) {
THIS.MC = MC;
THIS.MOIVESD = MOIVESD;
//
NX = 0;
NY = 0;
//
This.starx = Starx;
This.stary = Stary;
This.hang = Hang;
This.lie = Lie;
This. w = w;
This. h = h;
This.movietype = Movietype;
//
This. EW = W/lie;
This. EH = H/hang;
//
Mcimg = Mc.attachmovie (LinkId, "Mcimg", mc.getnexthighestdepth ());
//
Mcmask = Mc.createemptymovieclip ("Mcmask", mc.getnexthighestdepth ());
Mcmask.beginfill (0XFF00FF, 100);
Mcmask.linestyle (0, 0XFF00FF, 100);
Mcmask.moveto (0, 0);
Mcmask.lineto (EW, 0);
Mcmask.lineto (EW, EH);
Mcmask.lineto (0, EH);
Mcmask.lineto (0, 0);
Mcmask.endfill ();
//
Mcimg.setmask (Mcmask);
}
function Go () {
if (MOIVESD_I++>MOIVESD) {
Moivesd_i = 1;
//
if (Movietype = = 0) {
nx++;
if (Nx>=lie) {
NX = 0;
}
Sethanglie ();
else if (Movietype = 1) {
did not make
} else {
Trace ("type specifies error!");
}
}
}
End Go
function Sethanglie () {
mcimg._x =-(NX*EW);
mcimg._y =-(Ny*eh);
}
function Sethang (numhang:number) {
if (numhang<0 | | numhang>hang) {
NY = Hang;
return 0;
}
NY = Numhang;
}
}
////

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.