English 中文(简体)
从动态的电影剪辑中传出的电影剪辑(root)会产生错误1034
原标题:Calling MovieClip(root) from a dynamic MovieClip instance produces error 1034

NINJA EDIT: For some reason, the same code works now, without any problem at all. I don t know what happened, or why, but I no longer have this problem

Here s the original post:


简言之,我制作了一个电影剪辑,用添加语(Child)播放,在我试图把这部法典称作时:

MovieClip(root).someFunction();

它投掷Error #1034:Cerscion不成功:不能转换闪光:Stage@4034f71至闪光。

我确实可以指出,这部法典为什么赢得工作。 物体本身运行良好,因为我可以在其内部要求职能(该法典实际上属于一项职能)。 这只是一个有问题的法典。

谁能告诉我我我我我什么是错了?

EDIT: To better illustrate the situation, here s my pieces of code:

我在电影剪辑中担任这一职务:

function bombReset():void
{
    bBombIsDropped = false;
    tCarpetBombTween.gotoAndStop(0);
    this.visible = false;
    MovieClip(root).carpetBombAttack(iPosition);
}

在Sepene(主动、最外的上级)上,我有以下职能:

function carpetBombAttack(position:int):void
{
    damagePlant(15,vTileOccupant[(position-1)]);
}

如果我通过添加炸弹和把炸弹雷帽打成一个电影剪辑,那么闪电会留下一个错误。

如果我打电话给炸弹Reset时,我手动地拖拉电影剪辑,那将做罚款。

问题回答

您的错误意味着,汇编者不知道MovieClipStage是怎样的。 而且,我并不肯定,但我认为,即使你(casted)在舞台上不存在的汇编者将鞭打>。 http://www.ohchr.org。

解决这一问题的适当途径是将文件类别分配给你的项目,并制作<条码>。 a 公共方法(公务职能)。

非工作人员解决方案(我有时在I m being时使用)如下:

Object(this.stage).someFunction();

这是因为你是 原型播种<>> 代码>,使编辑认为它是一种<代码>。 目标,而不是<代码>Stage。 <代码>Objects 能够拥有任何数目的无证特性和功能,从而允许您在上打电话。 目标 无论它们是否属于类别定义的一部分(甚至不属于类别的定义,即你会遇到麻烦)。

<代码>Stage的继承:Stage ->显示 目的 集装箱 -> 反对——> ...... ,MovieClip:MovieClip -> Sprite -> showObject 集装箱 -> 反对——和; ......(I d与docs直接链接,但页数在我上坠毁)。

虽然他们共用共同的基础班级,但<代码> 分阶段<>/代码>和<代码>MovieClip 班级实际上没有关系,因此试图放下一门课,因为另一班失败。

在您重新做时,MovieClip(root)打字,而不是root as 电影/Clip。 因此,你重犯了错误。

Either cast it directly to the object that has the someFunction() defined, use the solution defined by Jackson, or if you absolutely know it s there, you can also do root["someFunction"]()





相关问题
Attaching a property to an event in Flex/AS3

I have a parameter that needs to be passed along with an event. After unsuccessful attempts to place it on the type by extending the class, I ve been advised in another SO question to write a custom ...

Sorting twodimensional Array in AS3

So, i have a two-dimensional Array of ID s and vote count - voteArray[i][0] = ID, voteArray[i][1] = vote count I want the top 3 voted items to be displayed in different colors, so i have a 2nd Array -...

Virtual Tour using sketch up, ajax, flash technologies

I want to know if there are existing technology that make your 3d models in sketch into virtual tours, using either Ajax or Flash for web presentation. If there s none, which will be a good approach ...

What s a good way of deserializing data into mock objects?

I m writing a mock backend service for my flex application. Because I will likely need to add/edit/modify the mock data over time, I d prefer not to generate the data in code like this: var mockData =...

AS3 try/catch out of memory

I m loading a few huge images on my flex/as3 app, but I can t manage to catch the error when the flash player runs out of memory. Here is the what I was thinking might work (I use ???? because i dont ...