第二版对初版作了一些优化,其中最主要的优化就是将属性提示界面单独封装为一个类。这样不但减小了属性界面与editor功能的耦合,并且使整个代码清爽了许多,而且同时解决了一部分BUGjava
更新主要代码以下:优化
InforAlert.as package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.text.TextField; import flash.text.TextFieldAutoSize; import flash.text.TextFieldType; public class InforAlert extends Sprite {editor02 private var hotSpot:HotspotEditor02; private var txtBack:TextField; private var txtInput:TextField; private var txtInput1:TextField; private var txtInput2:TextField; private var txtLable1:TextField; private var txtLable2:TextField; private var txtLable3:TextField; private var btn1:TextField; private var btn2:TextField; public function InforAlert(hotSpot:HotspotEditor02) { this.hotSpot = hotSpot; init(); addToStage(); } private function init():void{ txtBack = new TextField(); txtInput = new TextField(); txtInput1 = new TextField(); txtInput2 = new TextField(); txtLable1 = new TextField(); txtLable2 = new TextField(); txtLable3 = new TextField(); btn1 = new TextField(); btn2 = new TextField(); txtInput.type = TextFieldType.INPUT; txtInput1.type = TextFieldType.INPUT; txtInput2.type = TextFieldType.INPUT; txtInput.width = 100; txtInput.height = 25; txtInput1.width = 100; txtInput1.height = 25; txtInput2.width = 100; txtInput2.height = 25; txtLable1.width = 100; txtLable1.height = 50; txtLable1.textColor = 0xffffff; txtLable2.width = 100; txtLable2.height = 50; txtLable2.textColor = 0xffffff; txtLable3.width = 100; txtLable3.height = 50; txtLable3.textColor = 0xffffff; btn1.width = 70; btn1.height = 25; btn1.autoSize = TextFieldAutoSize.CENTER; btn1.text = “肯定”; btn1.background = true; btn1.backgroundColor = 0xdddddd; btn2.width = 70; btn2.height = 25; btn2.autoSize = TextFieldAutoSize.CENTER; btn2.text = “取消”; btn2.background = true; btn2.backgroundColor = 0xdddddd; txtBack.background = 0xddff00; txtBack.backgroundColor = 0×000000; txtInput.background = 0xFFFFFF; txtInput1.background = 0xFFFFFF; txtInput2.background = 0xFFFFFF; txtBack.x = 500; txtBack.y = 150; btn1.x = txtBack.x+50; btn1.y = txtBack.y+110; btn1.addEventListener(MouseEvent.CLICK,hotSpot.baginDraw); btn2.x = txtBack.x+195; btn2.y = txtBack.y+110; btn2.addEventListener(MouseEvent.CLICK,hotSpot.baginDraw); txtInput.x = txtBack.x+120; txtInput.y = txtBack.y+20; txtInput1.x = txtBack.x+120; txtInput1.y = txtBack.y+50; txtInput2.x = txtBack.x+120; txtInput2.y = txtBack.y+80; txtLable1.x = txtBack.x+50; txtLable1.y = txtBack.y+20; txtLable2.x = txtBack.x+50; txtLable2.y = txtBack.y+50; txtLable3.x = txtBack.x+50; txtLable3.y = txtBack.y+80; txtBack.alpha = 0.25; txtBack.width = 300; txtBack.height = 150; txtLable1.text = “商品ID:”; txtLable2.text = “商品编号:”; txtLable3.text = “商品URL:”; } public function addToStage():void{ this.addChild(txtBack); this.addChild(txtLable1); this.addChild(txtLable2); this.addChild(txtLable3); this.addChild(txtInput); this.addChild(txtInput1); this.addChild(txtInput2); this.addChild(btn1); this.addChild(btn2); } } }
版本下载
this