/* * copyright SAMSTUDIO.20051212.Popup * * POPUP组件,自动居中,fla中修改UI样式 * * // usage import com.UI.Popup; var PopupObj:Popup = new Popup(this,9999); PopupObj.pop("welcome!"); */ class com.UI.Popup { private var _self:MovieClip; private var _depth:Number; public function Popup(target:MovieClip,depth:Number) { _self = target; _depth = depth; } public function pop(txt:String) { _self.attachMovie("Popup", "PopupMc",_depth); with(_self.PopupMc){ popup_mc.msg_txt.text = txt; popup_mc_point = new Object(); popup_mc_point.x = (Stage.width-popup_mc._width)/2; popup_mc_point.y = (Stage.height-popup_mc._height)/2; globalToLocal(popup_mc_point); popup_mc._x = popup_mc_point.x; popup_mc._y = popup_mc_point.y; bg_mc.useHandCursor = false; bg_mc._height = Stage.height; bg_mc._width = Stage.width; bg_point = new Object(); bg_point.x = 0; bg_point.y = 0; localToGlobal(bg_point); bg_mc._x = bg_point.x; bg_mc._y = bg_point.y; popup_mc.onEnterFrame = function() { if ( Key.isDown(Key.ENTER) || Key.isDown(Key.SPACE) || Key.isDown(Key.ESCAPE) ) { del(); //delete this.onEnterFrame; } }; popup_mc.ok_btn.onRelease = function() { del(); }; } } public function del() { removeMovieClip(this); } }