actionscript - Error playing a frame for the third time -


i have flash file first frame contains 2 buttons, 1 of takes user second frame, , other takes them third frame. @ each of frames, various text fields , variables can manipulated via simplebuttons. both frame 2 , frame 3 have "back" buttons take them frame 1.

currently when user navigates frame 1 second time (thus playing third time), second button appears no longer exist, , receive error. both buttons on frame 1 placed via flash ide. why button popping out of existence, when did fine previous 2 times? below code frame 1. "back" buttons simple remove event listeners , call gotoandstop(1)

var inited:boolean; var cache:sharedobject; var libsans:font = new libsansreg();  this.addeventlistener(event.enter_frame, frameenter); stats.addeventlistener(mouseevent.click, statsclicked); modules.addeventlistener(mouseevent.click, modsclicked);  function initcache():void {     this.cache = sharedobject.getlocal("rpg_shooter") }  function frameenter(e:event):void {     if (!inited)     {         inited = true         initcache()         this.gotoandstop(1)     } }  function statsclicked(e:mouseevent):void {     this.removeeventlistener(event.enter_frame, frameenter)     stats.removeeventlistener(mouseevent.click, statsclicked)     modules.removeeventlistener(mouseevent.click, modsclicked)     this.gotoandstop(2) }  function modsclicked(e:mouseevent):void {     this.removeeventlistener(event.enter_frame, frameenter)     stats.removeeventlistener(mouseevent.click, statsclicked)     modules.removeeventlistener(mouseevent.click, modsclicked)     this.gotoandstop(3) } 

i had similar problem @ 1 point. has garbage collection not best in flash begin with, ide's compiler settings make more insane. there couple of tricks can try might help.

  • make sure remove listeners before leaving frame.
  • go "blank" frame (something still has background , styling, no interact-able components) 5/1000 of second
  • set variable names "null" on frame 1 (so if component on frame 3 named "foo" put foo = null on frame one)
  • put var foo:movieclip on frame 1. repeat movieclips might using named ahead of time.

Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -