Write a TIP class (AS)

xiaoxiao2021-03-06  19

Written a TIP class that implements the prompt information when the mouse slides.

You can dynamically change the target MC and other related properties, and you can control TIP running or not running. Mainly by run () and stoprun () (), you can choose whether or not to automatically call the Run () method in the constructor, and change When the target MC or changes some attributes, you need to call the RERUN () method to make the change take effect.

The specific implementation code is as follows:

/ ************************************************** ****************************************

Author: Tomato

Mail: supertomato@sjtu.edu.cn

Blog: http://blog.9cbs.net/crazytomato

*********************************************************** ******************************* /

class Tip {public var tipText: String; public var tipWidth: Number; public var tipHeight: Number; public var textFormat: TextFormat; public var tipTextColor: Number; public var tipBorderColor: Number; public var bgColor: Number; public var targetMovie: MovieClip Public Function ChangeTarget (_NewTarget: movieclip) {

STOPRUN ();

TargetMovie = _newtarget;

Run ();} private var _autoSize: String; public function get autoResize (): Boolean {if (_autoSize == "none") {return false;} else {return true;}} public function set autoResize (_bool: Boolean) {if (_bool == true) {_autoSize = "left";} else {_autoSize = "none";}} // save the interface to control the internal TextField private var _textField: TextField; public function get internalTextField (): TextField {return _textField;} public function Tip (_targetMovie: MovieClip, _tipText: String, _autoRun: Boolean) {targetMovie = _targetMovie; tipText = _tipText; tipWidth = 200; tipHeight = 20; _autoSize = "left"; tipTextColor = 0x000000; tipBorderColor = 0x000000; bgColor = 0xFFFFE1; _textField = null; if (_autoRun == true) {Run ();}} public function Run (): Void {var tipObj = this; targetMovie.onRollOver = function () {_root.createEmptyMovieClip ( " Tempmc ", _root.getnexthighestDepth ()); _root.tempmc.createtextfield (" Tiploader ", _Root.getNexThigHestDepth (), _ root._xmouse, _root._ymouse, tipWidth, tipHeight); with (_root.tempMC.tipLoader) {selectable = false; text = tipObj.tipText; background = true; border = true; autoSize = tipObj._autoSize; textColor = tipObj. tipTextColor; borderColor = tipObj.tipBorderColor; backgroundColor = tipObj.bgColor;} if ((tipObj.textFormat = null) && (tipObj.textFormat = undefined)!!) {_root.tempMC.tipLoader.setTextFormat (textFormat);} tipObj. _TextField = _root.tempmc.tiploader;} TargetMovie.onrollout =

转载请注明原文地址:https://www.9cbs.com/read-40307.html

New Post(0)