left_btn.addEventListener(MouseEvent.CLICK,l);
right_btn.addEventListener(MouseEvent.CLICK,r);
top_btn.addEventListener(MouseEvent.CLICK,t);
down_btn.addEventListener(MouseEvent.CLICK,d);
function l(event:MouseEvent) {
cat_mc.x=cat_mc.x-10;
}
function r(event:MouseEvent){
cat_mc.x=cat_mc.x+10;
}
function t(event:MouseEvent){
cat_mc.y=cat_mc.y-10;
}
function d(event:MouseEvent){
cat_mc.y=cat_mc.y+10;
}
big_btn.addEventListener(MouseEvent.CLICK,b);
small_btn.addEventListener(MouseEvent.CLICK,s);
function b(event:MouseEvent){
cat_mc.scaleX=cat_mc.scaleX+0.2;
cat_mc.scaleY=cat_mc.scaleY+0.2;
}
function s(event:MouseEvent){
cat_mc.scaleX=cat_mc.scaleX-0.2;
cat_mc.scaleY=cat_mc.scaleY-0.2;
}
roleft_btn.addEventListener(MouseEvent.CLICK,rol);
roright_btn.addEventListener(MouseEvent.CLICK,ror);
function rol(event:MouseEvent){
cat_mc.rotation=cat_mc.rotation-10;
}
function ror(event:MouseEvent){
cat_mc.rotation=cat_mc.rotation+10;
}
在这个实例中,没有首先声明变量;
结果发现:如果用反编软件将SWF反编之后,就出现了一段声明变量的句子;
package AS3_fla
{
import flash.display.*;
import flash.events.*;
dynamic public class MainTimeline extends MovieClip
{
public var top_btn:SimpleButton;
public var return_btn:SimpleButton;
public var roright_btn:SimpleButton;
public var big_btn:SimpleButton;
public var cat_mc:MovieClip;
public var roleft_btn:SimpleButton;
public var left_btn:SimpleButton;
public var right_btn:SimpleButton;
public var small_btn:SimpleButton;
public var down_btn:SimpleButton;
public function MainTimeline()
{
addFrameScript(0, this.frame1);
return;
}// end function
function frame1()
{
this.left_btn.addEventListener(MouseEvent.CLICK, this.l);
this.right_btn.addEventListener(MouseEvent.CLICK, this.r);
this.top_btn.addEventListener(MouseEvent.CLICK, this.t);
this.down_btn.addEventListener(MouseEvent.CLICK, this.d);
this.big_btn.addEventListener(MouseEvent.CLICK, this.b);
this.small_btn.addEventListener(MouseEvent.CLICK, this.s);
this.roleft_btn.addEventListener(MouseEvent.CLICK, this.rol);
this.roright_btn.addEventListener(MouseEvent.CLICK, this.ror);
return;
}// end function
public function s(event:MouseEvent)
{
this.cat_mc.scaleX = this.cat_mc.scaleX - 0.2;
this.cat_mc.scaleY = this.cat_mc.scaleY - 0.2;
return;
}// end function
public function ror(event:MouseEvent)
{
this.cat_mc.rotation = this.cat_mc.rotation + 10;
return;
}// end function
public function rol(event:MouseEvent)
{
this.cat_mc.rotation = this.cat_mc.rotation - 10;
return;
}// end function
public function b(event:MouseEvent)
{
this.cat_mc.scaleX = this.cat_mc.scaleX + 0.2;
this.cat_mc.scaleY = this.cat_mc.scaleY + 0.2;
return;
}// end function
public function l(event:MouseEvent)
{
this.cat_mc.x = this.cat_mc.x - 10;
return;
}// end function
public function r(event:MouseEvent)
{
this.cat_mc.x = this.cat_mc.x + 10;
return;
}// end function
public function d(event:MouseEvent)
{
this.cat_mc.y = this.cat_mc.y + 10;
return;
}// end function
public function t(event:MouseEvent)
{
this.cat_mc.y = this.cat_mc.y - 10;
return;
}// end function
}
}