【问题标题】:How to activate a TextField and Duplicate Movie Clips如何激活文本字段和复制影片剪辑
【发布时间】:2016-04-04 13:06:18
【问题描述】:

我想问,
1 如何将焦点放在 AS3 中的 TextField 上。我通常在 AS2 中使用

Selection.setFocus("<name of textfield instance>");
fscommand("activateTextField");

2.如何在 AS3 中复制影片剪辑。在我正在使用的 AS2 中

 <name of movie clip>.duplicateMovieClip();

谢谢

【问题讨论】:

    标签: actionscript-3 flash


    【解决方案1】:

    这是两个独立的问题,均在线回答:

    1. 使用stage.focus 将焦点设置在任何显示对象上:

      stage.focus = name_of_textfield;
      
    2. 没有直接等效于duplicateMovieClip,但您可以通过从原始显示对象类创建new 实例并复制原始属性来实现approximately the same thing

      function duplicateDisplayObject(target:DisplayObject):DisplayObject {
          var targetClass:Class = Object(target).constructor;
          var duplicate:DisplayObject = new targetClass() as DisplayObject;
      
          // duplicate properties
          duplicate.transform = target.transform;
          duplicate.filters = target.filters;
          duplicate.cacheAsBitmap = target.cacheAsBitmap;
          duplicate.opaqueBackground = target.opaqueBackground;
          if (target.scale9Grid)
              duplicate.scale9Grid = target.scale9Grid;
          if (target.parent)
              target.parent.addChild(duplicate);
          if (target.hasOwnProperty("graphics") && target["graphics"] is Graphics)
              Graphics(duplicate["graphics"]).copyFrom(Graphics(target["graphics"]));
      
          return duplicate;
      }
      
      duplicateDisplayObject(name_of_movieclip);
      

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-23
      • 1970-01-01
      • 1970-01-01
      • 2020-02-21
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      相关资源
      最近更新 更多