Flash窗口ActionScript功能
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Flash窗口ActionScript功能相关的知识,希望对你有一定的参考价值。
Taken from a lynda.com tutorial on learning actionscript. Lots of comments for the moment.
//Create a global variable to hold the current top depth available var nTopDepth:Number; //Create an associative array to store the names of the opened windows var oOpenedWindows:Object = new Object(); //Add the 2 event handles to the buttons. Passes the id name through to the addWindow function. mcButtonOne.onRelease = function():Void { addWindow("WindowOne"); }; mcButtonTwo.onRelease = function():Void { addWindow("WindowTwo"); }; function addWindow(sLinkage:String):Void { //If a value already exists in the associative array for the window, return. if(oOpenedWindows[sLinkage] != undefined) { oOpenedWindows[sLinkage].swapDepths(nTopDepth);//if the window exists, bring the existing window to the top depth return; } var nIndex:Number = this.getNextHighestDepth();//get the next highest level to put the window on var mcWindow:MovieClip = this.attachMovie(sLinkage, "mcWindow" + nIndex, nIndex);//attach the selected window and apply the next highest depth mcWindow._x = 100;//set selected window to 100px mcWindow._y = 100;//set selected window to 100px nTopDepth = nIndex;//set the nTopDepth to nIndex we aquired above. oOpenedWindows[sLinkage] = mcWindow;//Insert a value into the associative array mcWindow.mcWindowBackground.onPress = function():Void { this._parent.swapDepths(nTopDepth);//swap the selected window with the current top depth to bring it to the front this._parent.startDrag();//target the window background, then its parent to add a drag function onPress }; mcWindow.mcWindowBackground.onRelease = function():Void { this._parent.stopDrag();//target the window background, then its parent to remove a drag function onRelease }; mcWindow.mcWindowBackground.onReleaseOutside = mcWindow.mcWindowBackground.onRelease; mcWindow.mcCloseSquare.onRelease = function():Void { delete oOpenedWindows[sLinkage]//remove the window from the array on close this._parent.removeMovieClip();//remove the movie clip when you press the close button. }; }
以上是关于Flash窗口ActionScript功能的主要内容,如果未能解决你的问题,请参考以下文章
ActionScript 3:在 Flash embed 中失去焦点时保持 textarea UIscrollbar 位置
Flash actionscript 3 功能需要鼠标点击事件吗?
Actionscript 3 vs Haxe:为新的 Flash 项目选择哪个?