【问题标题】:Actionscript for remove button element删除按钮元素的动作脚本
【发布时间】:2014-07-23 15:16:11
【问题描述】:

当我们传递按钮 ID 时,我如何删除 actionscript 中的按钮。

<fx:Script>
    <![CDATA[
public function removebutton(buttonid:String):void
        {
            hb1.removeElementAt(buttonid);
        }
]]>
</fx:Script>


 <s:HGroup id="hb1">

</s:HGroup>

【问题讨论】:

    标签: actionscript-3 apache-flex actionscript flex4


    【解决方案1】:

    正如 SharpEdge 所说,没有可用于通过 id 获取元素的公共函数,但解决方法是:

    public function removebutton(buttonid:String):void
    {
        for (var i:int = 0; i < hb1.numChildren; i++)
        {
            var object:Object = hb1.getChildAt(i);
    
            if (object.id == buttonid)
            {
                hb1.removeElementAt(i);
                break;
            }
        }
    }
    

    【讨论】:

      【解决方案2】:

      可以使用getChildByName(),Flex中没有getElementByID()。

      public function removebutton(buttonid:String):void
          {
              hb1.removeElement(hb1.getChildByName(buttonid) as IVisualElement);
          }
      

      【讨论】:

        猜你喜欢
        • 2011-05-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-27
        • 1970-01-01
        • 1970-01-01
        • 2019-07-04
        • 2012-08-02
        相关资源
        最近更新 更多