📄 hintassembling.as
字号:
//***********************************HintAssembling class*********************
//***************************import FormatText class**************************
import pssclasses.*;
//***********************************HintAssembling class*********************
import pssclasses.hint.*;
class HintAssembling extends MovieClip {
//********************define variables******************
private var hintContainerName:String = "HintContainer";
private var hintContainerDepth:Number = 1;
private var hintContainer:MovieClip;
// movie inside
// hint background
private var hintBGHolderLinkageName:String = "HintBgHolder";
private var hintBGHolderName:String = "HintBgHolder";
// depth inside hintContainer
private var hintBGHolderDepth:Number = 0;
private var hintBGHolder:MovieClip;
// hint white blick
private var HintWhiteLinkageName:String = "HintWhite";
private var HintWhiteName:String = "HintWhite";
// depth inside hintContainer
private var HintWhiteDepth:Number = 2;
private var HintWhite:MovieClip;
// hint Punkt HintPunct
private var hintPunktLinkageName:String = "HintPunct";
private var hintPunktName:String = "HintPunct";
// depth inside this
private var hintPunktDepth:Number = 0;
private var hintPunkt:MovieClip;
// inside hintPunkt movie arrow_mc
private var hintArrow:MovieClip;
// hint Label
private var HintLabelName:String = "HintLabel";
// depth inside hintContainer
private var HintLabelDepth:Number = 1;
private var HintLabel:MovieClip;
private var hintLabelField:TextField;
// hint label text field
// label text field property
private var labelFont:String = "Verdana";
private var labelSize:Number = 10;
private var labelTopColor:Number = 0x000000;
private var labelBold:Boolean = false;
private var labelAlign:String = "left";
private var labelMultyLine:Boolean = true;
private var labelAutoSize:Boolean = true;
private var labelMargin:Number = 5;
// movie inside backgroundHolder
//**************left_mc*******************
private var LeftMC:MovieClip;
// movie inside left_mc
//top_mc
private var LeftMC_top:MovieClip;
//center_mc
private var LeftMC_center:MovieClip;
//bot_mc
private var LeftMC_bot:MovieClip;
//****end*******left_mc*******************
//**************center_mc*******************
private var CenterMC:MovieClip;
// movie inside center_mc
//top_mc
private var Center_top:MovieClip;
//center_mc
private var Center_center:MovieClip;
//bot_mc
private var Center_bot:MovieClip;
//****end*******center_mc*******************
//**************right_mc*******************
private var RightMC:MovieClip;
// movie inside center_mc
//top_mc
private var Right_top:MovieClip;
//center_mc
private var Right_center:MovieClip;
//bot_mc
private var Right_bot:MovieClip;
//****end*******right_mc*******************
//*****************HintWhite*****************
// lt_mc
private var HW_lt:MovieClip;
// lc_mc
private var HW_lc:MovieClip;
// tc_mc
private var HW_tc:MovieClip;
// cc_mc
private var HW_cc:MovieClip;
// rt_mc
private var HW_rt:MovieClip;
// rc_mc
private var HW_rc:MovieClip;
//*****end*********HintWhite*****************
// this
private var __this:MovieClip;
//hint place
private var __parent:MovieClip;
// hint from mouse margin in percent
private var mouseMarginPercent:Number = 10;
// position by mouse
private var xyPosition:String = "Bottom";
// minimum hint height
private var miniHintHeight:Number = 20;
// minimum hint width
private var miniHintWidth:Number = 30;
// white blik size in percent
private var whiteBlikPercent:Number = 30;
// *******************define metods********************
private function HintAssembling() {
__this = this;
__parent = __this._parent;
//********************************buil HintContainer********************
hintContainer = __this.createEmptyMovieClip(hintContainerName, hintContainerDepth);
//***********************************define movieclip variables***************************
// hint Punkt HintPunct
hintPunkt = __this.attachMovie(hintPunktLinkageName, hintPunktName, hintPunktDepth);
// hint background
hintBGHolder = hintContainer.attachMovie(hintBGHolderLinkageName, hintBGHolderName, hintBGHolderDepth);
// ************************************************movie inside backgroundHolder
//**************left_mc*******************
LeftMC = hintBGHolder.left_mc;
// movie inside left_mc
//top_mc
LeftMC_top = LeftMC.top_mc;
//center_mc
LeftMC_center = LeftMC.center_mc;
//bot_mc
LeftMC_bot = LeftMC.bot_mc;
//****end*******left_mc*******************
//**************center_mc*******************
CenterMC = hintBGHolder.center_mc;
// movie inside center_mc
//top_mc
Center_top = CenterMC.top_mc;
//center_mc
Center_center = CenterMC.center_mc;
//bot_mc
Center_bot = CenterMC.bot_mc;
//****end*******center_mc*******************
//**************right_mc*******************
RightMC = hintBGHolder.right_mc;
// movie inside center_mc
//top_mc
Right_top = RightMC.top_mc;
//center_mc
Right_center = RightMC.center_mc;
//bot_mc
Right_bot = RightMC.bot_mc;
//****end*******right_mc*******************
// hint white blick
HintWhite = hintContainer.attachMovie(HintWhiteLinkageName, HintWhiteName, HintWhiteDepth);
//*************************************************movie inside HintWhite
// lt_mc
HW_lt = HintWhite.lt_mc;
// lc_mc
HW_lc = HintWhite.lc_mc;
// tc_mc
HW_tc = HintWhite.tc_mc;
// cc_mc
HW_cc = HintWhite.cc_mc;
// rt_mc
HW_rt = HintWhite.rt_mc;
// rc_mc
HW_rc = HintWhite.rc_mc;
//***********************************define movieclip variables***************************
// born textfield
bornTextField(hintContainer);
}
//**********************************build hint hitarea************************
private function buildHint():Void {
resizeHintBG(hintContainer);
resizeHintWhiteBlik(hintBGHolder);
}
// ****end*********build hint hit area*********************
//******************************place and resize hintMovie*********************
//hint BG
private function resizeHintBG(container:MovieClip, aWidth:Number, aHeight:Number):Void {
if (!aWidth) {
var __width:Number = hintLabelField._width;
var __height:Number = hintLabelField._height;
} else {
var __width:Number = aWidth;
var __height:Number = aHeight;
}
//********if hint width or height < minimum width and minimum height
if (__height<miniHintHeight) {
__height = miniHintHeight;
}
if (__width<miniHintWidth) {
__width = miniHintWidth;
}
//*****end**if hint width or height < minimum width and minimum height
//***************resize by width************
CenterMC._x = LeftMC._x+LeftMC._width;
CenterMC._width = __width;
RightMC._x = CenterMC._x+CenterMC._width;
// **************resize by heigth************
//left
LeftMC_center._y = LeftMC_top._y+LeftMC_top._height;
LeftMC_center._height = __height;
LeftMC_bot._y = LeftMC_center._y+LeftMC_center._height;
//center
Center_center._y = Center_top._y+Center_top._height;
Center_center._height = __height;
Center_bot._y = Center_center._y+Center_center._height;
//right
Right_center._y = Right_top._y+Right_top._height;
Right_center._height = __height;
Right_bot._y = Right_center._y+Right_center._height;
}
// hint whiteBlik
private function resizeHintWhiteBlik(container:MovieClip):Void {
var __width:Number = container._width;
var __height:Number = hintBGHolder._height;
var __margin:Number = 2;
var pixelFromPercent:Object = percentToPixel(100, whiteBlikPercent, __width, __height);
HintWhite._x = __margin;
HintWhite._y = 2;
//width
HW_tc._x = HW_lt._width;
HW_tc._width = CenterMC._width-__margin;
HW_rt._x = HW_tc._x+HW_tc._width;
// height
// left
HW_lc._y = HW_lt._y+HW_lt._height;
HW_lc._height = pixelFromPercent.h;
//center
HW_cc._y = HW_tc._y+HW_tc._height;
HW_cc._width = HW_tc._width;
HW_cc._height = pixelFromPercent.h;
//right
HW_rc._y = HW_rt._y+HW_rt._height;
HW_rc._x = HW_cc._width+HW_cc._x;
HW_rc._height = pixelFromPercent.h;
}
//****end*********************place and resize hintMovie*********************
// ******************calculate percent to pixel from width and height******************
private function percentToPixel(percentW:Number, percentH:Number, fromW:Number, fromH:Number):Object {
var browserSize:Object = new Object();
var stageWidthPix:Number = fromW;
var stageHeightPix:Number = fromH;
browserSize.w = Math.round(stageWidthPix/100*percentW);
browserSize.h = Math.round(stageHeightPix/100*percentH);
return browserSize;
}
// ****end***********calculate percent to pixel from width and height******************
//**********************************born text field************************
private function bornTextField(labelPlace:MovieClip):Void {
//******************FormatText class******************
//FormatText.setTextFieldProp(textFieldField:TextField, autoSizeField:Boolean, selectableText:Boolean, embedFont:Boolean, sharpness:Number, gridFitType:String,htmlText:Boolean,labelMultyLine:Boolean)
// FormatText.setTextFieldFormat(textFieldField:TextField, font:String, size:Number, color:Number, bold:Boolean, underLine:Boolean, align:String, leftMargin:Number, rightMargin:Number)
//top text field
hintLabelField = labelPlace.createTextField(HintLabelName, HintLabelDepth, 0, 0, 40, 40);
FormatText.setTextFieldProp(hintLabelField, labelAutoSize, false, false, -400, "pixel", true, labelMultyLine);
FormatText.setTextFieldFormat(hintLabelField, labelFont, labelSize, labelTopColor, labelBold, false, labelAlign, labelMargin, labelMargin);
}
// ****end*********born text field*********************
private function labelPlace(container:MovieClip):Void {
hintLabelField._x = (container._width-hintLabelField._width)/2;
hintLabelField._y = (container._height-hintLabelField._height)/2-1;
}
//******************labelHolder place*************************
private function placeHint():Void {
// valuet hint from mouse margin
var mMargin:Object = percentToPixel(mouseMarginPercent, 0, __this._width, __this._height);
__this._x = __parent._xmouse-mMargin.w-mMargin.w/2;
__this._y = __parent._ymouse;
hintPunkt._x = mMargin.w-2;
//*********** if hint width or height bigest as stage
//**************************stage width***************************
if (__this._x+__this._width+10>Stage.width) {
__this._x = Stage.width-__this._width-1;
__this._y = __parent._ymouse;
hintPunkt._xscale *= -1;
hintPunkt._x = __parent._xmouse-__this._x+hintPunkt._width/2-2;
}
if (__this._x<0) {
__this._x = 1;
hintPunkt._x = __parent._xmouse-__this._x-hintPunkt._width/2+2;
}
//**************************stage height***************************
if (__this._y+__this._height+10>Stage.height) {
xyPosition = "Top";
}
// place in position
hintContainerPlace(xyPosition);
}
private function hintContainerPlace(position:String):Void {
switch (position) {
case "Top" :
hintPunkt._y = hintContainer._height+hintPunkt._height-2;
hintPunkt._yscale *= -1;
__this._y = _root._ymouse-__this._height;
break;
case "Bottom" :
hintContainer._y = hintPunkt._height-2;
break;
case "Left" :
break;
case "Right" :
break;
}
}
//******end*********labelHolder place*************************
//********************************** set labelText************************
public function labelText(labelText:String, limitW:Number):Void {
hintLabelField.text = labelText;
if (limitW) {
hintLabelField._width = limitW;
hintLabelField.wordWrap = true;
}
// build end resize
buildHint();
// label place
labelPlace(hintContainer);
//hint place
placeHint();
}
public function labelHtmlText(labelText:String, limitW:Number):Void {
hintLabelField.htmlText = labelText;
if (limitW && hintLabelField._width>limitW) {
hintLabelField._width = limitW;
hintLabelField.wordWrap = true;
}
// build end resize
buildHint();
// label place
labelPlace(hintContainer);
//hint place
placeHint();
}
// ****end********* set labelText*********************
//************************************ALERT METODS***************************
//******end*************************ALERT METODS***************************
// *************end class*****************
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -