如何删除previous SWF时输入新的SWF(AS3)......?previous、SWF

2023-09-09 21:51:33 作者:冷血范

我创建双问答游戏与3 SWF文件(main.swf中,A.swf,B.swf中),当我的main.swf加载到另一个swf例如成(B.swf中)后重新回到主力。瑞士法郎再次,它完全没有误差修改...但是当这个过程不断循环,它看起来像垃圾邮件的CPU内存占用...什么编码,我应该用于解决呢? (**我猜是因为previous SWF文件的内存不能完全消除时输入另一个SWF,新的SWF刚刚更换的顶部) (我用.unload(),removeChild之(),停止()等等,似乎并不能解决这个problem..i并尽我所能来解决,但失败) 我认为必须有一些codeS用于解决这个问题,我不知道是什么else.can给我一点的办法呢?

I am creating double Quiz games with 3 swf files(main.swf,A.swf,B.swf),when i load from Main.swf into another swf example into(B.swf) and reload back to Main.swf again,it works perfectly without erros... but when this process keep on looping, its seems like spamming CPU memory usage...what coding i should used to solve it? (**i guess because the previous swf file's memory not totally remove when enter another swf, new swf just replacing on top) (I used .unload(),removeChild (),stop() so on seems doesn't solve this problem..i did try my best to solve but fail) I think there must be some codes used solve this,i dunno what else.can give me little solutions?

您所有的善良会非常AP preciate :) 谢谢

Your all Kindness will be very appreciate:) Thanks

推荐答案

您无需重新加载在一个循环的每个SWF!分配一个变量被加载的SWF来代替,而使用该变量与SWF交互。

You don't need to reload each SWF in a loop! Assign a variable to the loaded SWF instead and use that variable to interact with the swf.

  private var swfA:MovieClip;

  private function onLoadComplete( event:Event ):void
  {
       //if you've loaded A.swf
       swfA = event.currentTarget.content;
  }

这一点上,您可以:

  //hide the swf
  swfA.visible = false;

  //remove it from stage
  removeChild( swfA );

如果你有它链接到自己的类,你甚至可以调用方法或设置属性

And if you had linked it to its own class , you could even call methods or set properties

  //for instance...
  swfA.answers = [ answer1 , answer2 .... , answern]; 
  swfA.showResult();