最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
flash as3.0简单计数器代码
时间:2022-07-02 17:02:35 编辑:袖梨 来源:一聚教程网
function mc_press(_mc:MovieClip) {
_mc.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,d_f);
}
function d_f(e:MouseEvent) {
var str:String=e.target.name.slice(0,e.target.name.length-3);
var myclass=getDefinitionByName(str);
var my_mc=new myclass();
my_mc.startDrag(true);
addChild(my_mc);
my_mc.addEventListener(flash.events.MouseEvent.MOUSE_DOWN,mc_d);
my_mc.addEventListener(flash.events.MouseEvent.MOUSE_UP,mc_u);
}
function mc_d(e:MouseEvent) {
e.target.startDrag();
if (fang_mc.hitTestPoint(e.target.x,e.target.y)) {
e.target.isHitTest=true;
} else {
e.target.isHitTest=false;
}
}
function mc_u(e:MouseEvent) {
e.target.stopDrag();
var class_str:String=getQualifiedClassName (e.target);
var class_name=getDefinitionByName(class_str);
if (!e.target.isHitTest) {
if (fang_mc.hitTestPoint(e.target.x,e.target.y)) {
class_name.num++;
}
} else {
if (!fang_mc.hitTestPoint(e.target.x,e.target.y)) {
class_name.num--;
}
}
back_txt.text=String(back.num);
blue_txt.text=String(blue.num);
red_txt.text=String(red.num);
}
mc_press(back_mc);
mc_press(blue_mc);
mc_press(red_mc);
类:
package {
import flash.display.MovieClip;
public class back extends MovieClip {
public static var num:int=0;
public var isHitTest:Boolean=false;
public function back() {
}
}
}
package {
import flash.display.MovieClip;
public class blue extends MovieClip {
public static var num:int=0;
public var isHitTest:Boolean=false;
public function blue() {
}
}
}
package {
import flash.display.MovieClip;
public class red extends MovieClip {
public static var num:int=0;
public var isHitTest:Boolean=false;
public function red() {
}
}
}
类的功能很简单,主要用于计数和判断!
桌面.rar:桌面.rar
//改进:定义一个父亲给三个类:
package {
import flash.display.MovieClip;
public class color extends MovieClip {
public var isHitTest:Boolean=false;
public function color() {
}
}
}
package {
import flash.display.MovieClip;
public class back extends color {
public static var num:int=0;
public function back() {
}
}
}
package {
import flash.display.MovieClip;
public class blue extends color {
public static var num:int=0;
public function blue() {
}
}
}
package {
import flash.display.MovieClip;
public class red extends color {
public static var num:int=0;
public function red() {
super();
}
}
}
相关文章
- 《无限暖暖》天星之羽获得位置介绍 12-20
- 《流放之路2》重铸台解锁方法介绍 12-20
- 《无限暖暖》瞄准那个亮亮的成就怎么做 12-20
- 《无限暖暖》魔气怪终结者完成方法 12-20
- 《无限暖暖》曙光毛团获得位置介绍 12-20
- 《无限暖暖》日光果获得位置介绍 12-20