我是 Flash AS3 的新手。我正在尝试创建影片剪辑> 我已经创建了基本代码,但我需要将其转换为包,以便可以从中创建 XX 个剪辑。
你能帮忙制作这个简单的包,这样我就可以像使用它一样使用它 var btn:Button = new Button("title");
// mc_main
var mc_main:MovieClip = new MovieClip();
//mc.graphics.lineStyle(1,0x0000CC);
mc_main.graphics.beginFill(0x0000CC);
mc_main.graphics.drawRect(0, 0, 400, 40);
mc_main.graphics.endFill();
mc_main.x = 80;
mc_main.y = 60;
addChild(mc_main);
//mc_txt
var mc_txt:TextField = new TextField();
mc_main.addChild(mc_txt);
mc_txt.text = 'Hello!';
mc_txt.x = 50;
mc_txt.y = 8;
//mc_txt Color
var tf:TextFormat = new TextFormat();
tf.size = 18;
tf.bold = true;
tf.font = "Arial"
tf.color = 0xFFFFFF;
mc_txt.setTextFormat(tf);
我想出了这个代码但不起作用
package com.fladev.button
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
public class Button extends MovieClip
{
private var Title:String;
private var Image:String;
public static var mc_main:MovieClip = new MovieClip();
public function Button(Title:String, Image:String) {
this.Title = Title;
this.Image = Image;
Draw_main();
}
private function Draw_main()
{
mc_main.graphics.beginFill(0x0000CC);
mc_main.graphics.drawRect(0, 0, 400, 40);
mc_main.graphics.endFill();
mc_main.x = 80;
mc_main.y = 60;
this.stage.addChild(mc_main);
}
}
}