0

基本上,我想在有人进入新页面时删除我的播放/暂停按钮,但同时,如果我的视频处于活动状态,它也会将其删除。

目前这是我删除它们的代码。

    if (header.text == "Gallery") {
    myvid.stop();
removeChild(myvid);
trace("stuff got removed")
removeChild(iplaybtn); removeChild(istopbtn); removeChild(iplaybtn2); removeChild(istopbtn2);
removeChild(play0); removeChild(stop0); removeChild(play1); removeChild(stop1);

}else{
trace("gallerybutton has been click.");
myvid.stop();
removeChild(myvid);

}


问题是,它的工作原理是,它会删除视频,然后是按钮,但问题是,如果视频没有激活,它不会删除按钮 =/。

无法弄清楚如何做出适用于两者的条件语句,但它会检查两者是否都已完成或两者都执行。

求助!

4

2 回答 2

0

不确定“如果视频未激活”是什么意思另外,我不知道 header.text 是什么,但我假设一个文本字段。

我认为您只需要一个 OR 语句,如下所示:

if (header.text == "Gallery" || <<code if video is active>>) {
于 2013-07-04T14:07:35.827 回答
0

前面的答案看起来是正确的,您可能正在寻找逻辑运算符。这些是您可以使用的运算符:

|| (OR operator) will run the code if any condition is true.
&& (AND operator) will run the code if all conditions are true.
! (NOT operator) will run the code if the condition is not true (i.e. false!)

您可以在此处找到有关运算符及其用法的更多信息:http: //www.adobe.com/devnet/actionscript/learning/as3-fundamentals/operators.html

我不确定您是要删除所有内容还是仅删除舞台上的某些内容,但是如果您要删除所有内容,也可以使用:

for (var i:int = (numChildren - 1); i >= 0; i--) {
  removeChild(getChildAt(0));
}

或者

while (numChildren > 0) {
  removeChildAt(0);
}
于 2013-07-04T14:46:37.560 回答