如何更改movieclip as3(how to change movieclip as3)

编程入门 行业动态 更新时间:2024-10-19 04:23:01
如何更改movieclip as3(how to change movieclip as3)

我想在1帧上更改2个动画片段,第一个动画片段用于启动应用程序时的介绍,第二个动画片段是第一个继续。 我的代码:

var sunR1:classSunRays1; //movieclip export var sunR2:classSunRays2; //movieclip export function intro():void{ sunR1 = new clsSunRays1(); sunR1.x = mapW/2; sunR1.y = mapH/2; sunR1.width += 200; sunR1.height += 200; stage.addChild(sunR1); if (sunR1.currentFrame == sunR1.totalFrames){ stage.removeChild(sunR1); sunR2 = new clsSunRays2(); sunR2.x = mapW/2; sunR2.y = mapH/2; sunR1.width += 200; sunR1.height += 200; stage.addChild(sunR2); } }

i want to change 2 movieclip on 1 frame, first movieclip is for intro when app is started, and the second movieclip is continue of first. here my code :

var sunR1:classSunRays1; //movieclip export var sunR2:classSunRays2; //movieclip export function intro():void{ sunR1 = new clsSunRays1(); sunR1.x = mapW/2; sunR1.y = mapH/2; sunR1.width += 200; sunR1.height += 200; stage.addChild(sunR1); if (sunR1.currentFrame == sunR1.totalFrames){ stage.removeChild(sunR1); sunR2 = new clsSunRays2(); sunR2.x = mapW/2; sunR2.y = mapH/2; sunR1.width += 200; sunR1.height += 200; stage.addChild(sunR2); } }

最满意答案

您可以尝试以下方法:

function intro():void { sunR1 = new classSunRays1(); sunR1.stop(); sunR1.x = mapW/2; sunR1.y = mapH/2; sunR1.width += 200; sunR1.height += 200; stage.addChild(sunR1); // adding a function to be called in the last frame (when you will apply your logic) sunR1.addFrameScript(sunR1.totalFrames -1, changeMovieClip); sunR1.play(); } function changeMovieClip():void { sunR1.stop(); stage.removeChild(sunR1); sunR2 = new classSunRays2(); sunR2.stop(); sunR2.x = mapW/2; sunR2.y = mapH/2; sunR2.width += 200; sunR2.height += 200; stage.addChild(sunR2); sunR2.play(); }

You can try something like:

function intro():void { sunR1 = new classSunRays1(); sunR1.stop(); sunR1.x = mapW/2; sunR1.y = mapH/2; sunR1.width += 200; sunR1.height += 200; stage.addChild(sunR1); // adding a function to be called in the last frame (when you will apply your logic) sunR1.addFrameScript(sunR1.totalFrames -1, changeMovieClip); sunR1.play(); } function changeMovieClip():void { sunR1.stop(); stage.removeChild(sunR1); sunR2 = new classSunRays2(); sunR2.stop(); sunR2.x = mapW/2; sunR2.y = mapH/2; sunR2.width += 200; sunR2.height += 200; stage.addChild(sunR2); sunR2.play(); }

更多推荐

本文发布于:2023-07-26 15:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1277478.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何更改   movieclip   change

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!