最新下载
热门教程
- 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();
}
}
}
相关文章
- 人们熟悉的寄居蟹属于以下哪种分类 神奇海洋11月21日答案 11-21
- 第五人格11.22共研服有什么更新 11月22日共研服更新内容介绍 11-21
- 原神恰斯卡怎么培养 11-21
- 无期迷途四星装束是谁 11-21
- 王者荣耀帝丹高中校服怎么获得 11-21
- 光遇姆明季后续版本怎么玩 11-21