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);
Class:
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 () {
}
}
}
The function of the class is very simple, mainly used for counting and judging!
Desktop. RAR: Desktop. rar
Improvement: Definition of a father to three classes:
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 ();
}
}
}