最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
flash实现背景移动
时间:2022-07-02 17:04:13 编辑:袖梨 来源:一聚教程网
flash实现背景移动package cn.flash023{
import fl.controls.Button;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.display.Sprite;
public class Ving extends Sprite {
private var show_sprite:Sprite;
private var point:uint;
public function Ving():void {
show_sprite=new Sprite;
point =new uint;
init();
}
private function init():void {
addChild(show_sprite);
for (var p:uint=0; p<9; p++) {
var _pinging=new Ping(String(p+1));
_ping.x=p%3*550,_ping.y=uint(p/3)*400;
show_sprite.addChild(_ping);
_ping.addEventListener("live",onClick);
}
}
private function onClick(_evt:MouseEvent):void {
var _pinging =_evt.target as Ping;
point!=_ping["_btnmode"]&&show_sprite.addEventListener ("enterFrame",moveShow);
point=_ping["_btnmode"];
}
private function moveShow(_evt:Event):void {
var _sprite:Sprite=_evt.target as Sprite;
_sprite.x+=(-point%3*550-_sprite.x)*.2;
_sprite.y+=(-uint(point/3)*400-_sprite.y)*.2;
Math.abs (-point%3*550-_sprite.x)<.2&&Math.abs (-uint(point/3)*400-_sprite.y)<.2&&_sprite.removeEventListener ("enterFrame",moveShow);
}
}
}
package cn.flash023{
import flash.display.Sprite;
import flash.events.MouseEvent;
import flash.events.Event;
import fl.controls.Button;
import flash.text.TextField;
public class Ping extends Sprite {
public var _btnmode:uint;
public function Ping(_l:String=""):void {
label_txt.text=_l;
_btnmode=new uint;
init();
}
private function init():void {
for (var _p:uint=0; _p
if (_btn) {
_btn.label =String(_p);
_btn.addEventListener("click",onClick);
}
}
}
private function onClick(_evt:Event):void {
var _btn:Button =_evt.target as Button;
_btnmode=uint(_btn.label)-1;
dispatchEvent(new MouseEvent("live"));
}
}
}
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22