Flash image cut into two dynamic results

Source: Internet
Author: User
The code is as follows: Copy code

Package {
Import flash. display. Sprite;
Import flash.net. URLRequest;
Import flash. display. Loader;
Import flash. display. Bitmap;
Import flash. display. BitmapData;
Import flash. events. Event;
Import flash. geom. Point;
Import flash. geom. Rectangle;
Public class Main extends Sprite {
Private var loader: Loader;
Public function Main (): void {
Loader = new Loader;
Loader. contentLoaderInfo. addEventListener (Event. COMPLETE, onLoadCompleteHandler );
Loader. load (new URLRequest ("mm.gif "));
}
Private function onLoadCompleteHandler (_ evt: Event): void {
Var _ bitmap: Bitmap=_evt.tar get. content as Bitmap;
Var _ BMI: BitmapData = _ bitmap. bitmapData;
For (var _ p: uint = 0; _ p <5; _ p ++ ){
Var p_bmi: BitmapData = new BitmapData (_ BMI. width, _ BMI. height *. 2 );
P_bmd.copyPixels (_ bone density, new Rectangle (0, _ p * _ bone density. height *. 2, _ BMI. width, _ BMI. height *. 2), new Point ());
Var _ sprite: Sprite = new Sprite;
_ Sprite. addChild (new Bitmap (p_bmi ));
_ Sprite. y = _ p * _ BMI. height *. 2;
_ Sprite. name = _ p % 2? "-": "+ ";
AddChild (_ sprite). addEventListener (Event. ENTER_FRAME, onEnterFrameHandler );
}
}
Private function onEnterFrameHandler (_ evt: Event): void {
Var _ sprite: Sprite pai_evt.tar get as Sprite;
_ Sprite. name = "-"? _ Sprite. x-= 3: _ sprite. x + = 3;
(_ Sprite. x <-_ sprite. width | _ sprite. x> stage. stageWidth) & _ sprite. removeEventListener (Event. ENTER_FRAME, onEnterFrameHandler );
}
}
}

Http://www.111cn.net/down/split.rar instance download address

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.