繁体   English   中英

AS3:如何从影片剪辑的内部退回到主框架

[英]AS3 : how to back from inside of movie clip to main frame

我在主机架上的另一个影片剪辑中有一个影片剪辑(符号2)。 当影片剪辑完成播放时,我想回到第2帧中的主时间轴(第200帧)。 然后在最后一个影片剪辑帧(第200帧)上执行此操作:

MovieClip(root).gotoAndStop(2);

它可以正常工作,我转到主框架(第2帧),但是我也遇到了一个错误:

TypeError:错误#1009:无法访问空对象引用的属性或方法。 在hehe_fla :: Symbol2_2 / frame200()[hehe_fla.Symbol2_2 :: frame200:1]

我认为您应该这样做:(注释在代码中)

symbol_2.addEventListener(MouseEvent.CLICK, function(e){

    trace(e.currentTarget.name)             // trace the name of symbol_2, gives you of course symbol_2
    trace(e.currentTarget.parent.name)      // trace the name of the parent of symbol_2, gives the name of your object (the parent clip of symbole_2)

    trace(e.currentTarget.root.name)        // trace the name of the root of symbol_2 : root1
    trace(e.currentTarget.parent.root.name) // trace the name of the root of the parent of symbol_2 : root1
                                            // here you should get the same name, because it's the same root
                                            // and that's why we can do like this : 

    e.currentTarget.root.gotoAndStop(2)
                                            // or like this, to go to and stop in the frame 2 of root

    e.currentTarget.parent.root.gotoAndStop(2)

})

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM