我在舞台大小的框架中有几个影片剪辑,我必须在这些页面之间切换一个按钮。
所以,如果我按下按钮,所有其他帧removeChild和他被调用的那个都应该去addChild。
编辑:我将动作脚本放在movieClip的时间轴中,因此按钮不在舞台上,但我使用动作脚本放入了影片剪辑。
所以DodgerThud在这里展示的是不可能的,因为按钮已经改变,因为那是在movieClip(s)中。
我想我需要在每个movieClip中放置相同的代码。
答案 0 :(得分:0)
像...一样的东西。
function tueHandler(e:MouseEvent):void
{
while(numChildren > 0)
removeChildAt(0);
addChild(whatever);
}
答案 1 :(得分:0)
将所有MovieClip放入Vector或Array。
当您单击该按钮时,您应循环浏览Vector / Array并检查MovieClip当前是否在contains(DisplayObject)
的舞台上。如果Movieclip IS当前在舞台上,请将其删除并在舞台上添加另一个,例如,Vector / Array中的下一个。
var vec:Vector.<MovieClip> = new Vector.<MovieClip>
vec[0] = new MovieClip();
vec[1] = new MovieClip(); //example with MovieClips
vec[2] = new MovieClip();
addChild(vec[0]); //add one of the MovieClips to stage
button.addEventListener(MouseEvent.CLICK, onClick);
function onClick(e:MouseEvent):void
{
for(var i:int = 0; i < vec.length; i++) //go through the Vector one by one
{
if(contains(vec[i]) //if the Object at position i in the Vector is on stage
{
removeChild(vec[i]); //remove the Object
var next:int = i; //create a temporary holder
if(next == vec.length) //check if the displayed Object was the last in the list
{
next = 0; //if so, set to 0
}else{
next++; //otherwise, only add 1
}
addChild(vec[next]); //add the next Object to the stage. If the removed Object was the last in the Vector, it'll add the first Object in the Vector to the list
break; //escape the for loop, otherwise it'll always only show the last Object
}
}
}