如何从文档类中访问舞台上的动态文本字段 [英] How to access dynamic text field on stage from within the document class

查看:104
本文介绍了如何从文档类中访问舞台上的动态文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图访​​问一个文本输入,我已经放置在舞台上(影片剪辑中),但没有运气。

我已经为这个动态文本字段是currentUserCount定义的实例名称

我有这样的设置,在文档类ActionScript文件:

 包{

    进口对象类型:flash.events.Event;
    进口flash.net.URLLoader;
    进口flash.net.URLRequest;
    进口flash.display.Sprite;
    进口flash.display.DisplayObject;
    进口的flash.display.MovieClip;
    进口的flash.display.Stage;
    进口API元素flash.text.TextField;
    进口flash.text.TextFieldAutoSize;
    进口flash.text.TextFormat用于;

    公共类myProject的扩展Sprite {

        公共职能myProject的(){
            //尝试这样的东西
            跟踪(currentUserCount);
            跟踪(movieClipName.currentUserCount);
            跟踪(root.currentUserCount);
        }
    }
}
 

我在想什么?

当我运行此我得到的:

  1120:未定义的属性currentUserCount的访问。
1120:未定义的属性movieClipName的访问。
1119:的DisplayObject:可能未定义的属性movieClipName通过与静态类型flash.display使用参考访问。
1120:未定义的属性currentUserCount的访问。
 

解决方案

如果所有舞台上的影片剪辑的有它的内部同嵌套的剪辑,你也可以只引用内部片段,像这样:

 的(VAR I = 0; I< stage.numChildren;我++){
  变种MC = stage.getChildAt(I)
  mc.subClip.play()
}
 

I'm trying to access a text input that I've already placed on the stage (inside a movie clip) but with no luck.

I've defined an instance name for this dynamic text field which is currentUserCount

I've got something like this set up in the document class actionscript file:

package {

    import flash.events.Event;
    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.display.Sprite;
    import flash.display.DisplayObject;
    import flash.display.MovieClip;
    import flash.display.Stage;
    import flash.text.TextField;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextFormat;

    public class myProject extends Sprite {

        public function myProject() {
            // Trying stuff like
            trace(currentUserCount);
            trace(movieClipName.currentUserCount);
            trace(root.currentUserCount);
        }
    }
}

What am I missing?

When I run this I get:

1120: Access of undefined property currentUserCount.
1120: Access of undefined property movieClipName.
1119: Access of possibly undefined property movieClipName through a reference with static type flash.display:DisplayObject.
1120: Access of undefined property currentUserCount.

解决方案

If all of the movieclips on the stage had the same nested clip inside of it, you could also just reference the inner clips like so:

for (var i=0; i<stage.numChildren; i++){
  var mc = stage.getChildAt(i)
  mc.subClip.play()
}

这篇关于如何从文档类中访问舞台上的动态文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆