actionscript 3 - Reset position of background -


in background.as have following code make background scroll:

package{      //defining class     import flash.display.movieclip;     import flash.events.event;      public class background extends movieclip{          function background()         {             //executes enterframe function             addeventlistener("enterframe", enterframe);          }          function enterframe(e:event)         {             this.x -= 1;         }     } } 

the background moveclip linkage set background. wondering how reset background it's starting position within function in main.as

you can store original position before changes applied, , refer that:

public class background extends movieclip {      private var _startposition:point;       public function background()     {         _startposition = new point(x, y);         addeventlistener(event.enter_frame, _enterframe);     }       private function _enterframe(e:event):void     {         x -= 1;     }       public function reset():void     {         x = _startposition.x;         y = _startposition.y;     }  } 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -