包类 {
import flash.display.Sprite;
import Classes.Image_SS;
import flash.events.Event;
public class image_class extends Sprite
{
public static var ss:Image_SS = new Image_SS("3D_solid_surface_1",2);
static public function image_class()
{
addChild(ss);
ss.alpha = 0;
ss.x = -2000;
var tw1:my_Tween = new my_Tween(ss,"x",0,1,"Out");
var tw2:my_Tween = new my_Tween(ss,"alpha",1,1,"Out");
}
static public function remove():void
{
removeChild(ss);
/*
var tw3:my_Tween = new my_Tween(ss,"x",2000,1,"In");
var tw4:my_Tween = new my_Tween(ss,"alpha",0,1,"In");
tw3.addEventListener(Event.COMPLETE, onCOM);
function onCOM(e:Event):void
{
ss.alpha = 0;
ss.x = -2000;
}
*/
}
}
} 我不知道为什么它不起作用。 请有人告诉我这里有什么问题,这个erorr是什么意思 在我忘记之前,我将功能改为公共功能,并没有改变任何内容。
答案 0 :(得分:2)
构造函数(image_class)不能是静态方法。从声明中删除静态
答案 1 :(得分:1)
扩展我的评论..(未经测试,仅基于您发布的代码)
//package Classes
package
{
import flash.display.Sprite;
import flash.events.*; //covers all events used in this code (inc mouse events)
import Classes.Image_SS;
public class image_class extends Sprite
{
public var ss:Image_SS = new Image_SS ("3D_solid_surface_1",2);
public function image_class()
{
addChild(ss);
//remove(); //do remove without mouse
ss.addEventListener(MouseEvent.CLICK, remove); //for remove via mouse
ss.alpha = 0;
ss.x = -2000;
var tw1:my_Tween = new my_Tween(ss,"x",0,1,"Out");
var tw2:my_Tween = new my_Tween(ss,"alpha",1,1,"Out");
}
//public function remove():void //do without mouse click
public function remove(event:MouseEvent):void //do via mouse click event
{
removeChild(ss);
/*
var tw3:my_Tween = new my_Tween(ss,"x",2000,1,"In");
var tw4:my_Tween = new my_Tween(ss,"alpha",0,1,"In");
tw3.addEventListener(Event.COMPLETE, onCOM);
function onCOM(e:Event):void
{
ss.alpha = 0;
ss.x = -2000;
}
*/
}
}
} //close or end package