问题描述
我开始用AS3编程ICM使用Flash Builder 4。
I am starting with AS3 programming icm with Flash Builder 4.
我创建了一个主类,它是初始阶段。
I have created a "Main" class which is the initial stage.
在这个阶段有一个叫做mcMain影片剪辑。
On this stage there is a movieclip called mcMain.
在此mcMain是4其他影片剪辑:mcStats1 mcStats2 mcStats3 mcStats4
In this mcMain is 4 other movieclips: mcStats1 mcStats2 mcStats3 mcStats4
我怎样才能从code访问这些mcStats1-4让他们去另一帧?
How can I access these mcStats1-4 from the code to make them go to another frame?
我想:
var t:MovieClip = MovieClip(getChildByName("mcMain"));
t.getChildByName("mcStats1").gotoAndPlay(3);
但是,这只是不断给我空引用错误:类型错误:错误#1009:无法访问空对象引用的属性或方法
But that just keeps giving me null reference errors:TypeError: Error #1009: Cannot access a property or method of a null object reference.
所以,我应该怎么解决这个问题?
So how should I solve this?
推荐答案
我想它了自己,这并不容易,但apperantly类型转换是在AS3的答案。
I figured it out myself, it wasn't easy but apperantly typecasting is the answer in AS3.
var p1:mcUserStats; //class name
p1 = ((this.mcMain as MovieClip).mcStats1 as mcUserStats);
这篇关于在影片剪辑访问影片剪辑的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!