最新下载
热门教程
- 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"));
}
}
}
相关文章
- 《无限暖暖》织衣蛛获得方法 12-26
- 《无限暖暖》美食家蜜蜂获得方法 12-26
- 《无限暖暖》泳镜蝽获得方法 12-26
- 《无限暖暖》芭蕾豆娘获得方法 12-26
- 《无限暖暖》刺绣蛾获得方法 12-26
- 《无限暖暖》尖帽仙获得方法 12-26