actionscript 3 - Compositing the stage's last frame -


i've created series of classes can used generate , render images. want store copy of last frame displayed can mix current frame create video sustain effect. brief overview of classes involved in example:

  • mastercontainer: subclass of sprite used main display object. generative classes placed in mastercontainer, , redrawn when container told render
  • customwave: subclass of shape used contain, draw, , manipulate graphicspath object. 1 of aforementioned 'generative classes'

my current attempt involves use of 2 mastercontainer objects - 1 current frame, , 1 last frame. if i'm not mistaken, current appearance of 1 mastercontainer (and children) can copied other command lastmaster.graphics.copyfrom(master.graphics);. consider following code:

var time:number; var master:mastercontainer = new mastercontainer();  //current frame var lastmaster:mastercontainer = new mastercontainer();  // last frame var wave:customwave = new customwave(new <number>[0,0,0,0],0xffffff,5);  //generator current frame master.registercomponent(wave);  //adds customwave , registers rendering loop addchild(lastmaster);  //add last frame stage addchild(master);  //add current frame stage addeventlistener(event.enter_frame, perframe);   function perframe(event:event):void{     time = 0.001 * gettimer();     lastmaster.graphics.copyfrom(master.graphics);  //copy previous frame's graphics     updatepoints();  //update path of customwave     updatecolor();  //update color of customwave     master.firerendercannon();  //redraw objects registered master } 

this seems work in theory, far can tell lastmaster ends no visible graphics content though master renders expected. i've tried several times test whether case, , pretty convinced that is, newish as3 , concerned overlooking - code looks should work. have suggestions on how test properly? there obvious defects within code cause lastmaster visually blank? there better way of accomplishing goal?

i think i'm in on head on this... love input. thanks!

after copied graphics, try it? method copyfrom works clocks, without problems. isn't here logic bug in code?

function perframe(event:event):void{     time = 0.001 * gettimer();     lastmaster.graphics.copyfrom(master.graphics);  //here     //master.graphics.copyfrom(lastmaster.graphics);     updatepoints();       updatecolor();       master.firerendercannon(); } 

example of copyfrom, works fine complexity of graphics:

var complex: shape = new shape(); adobeexample(complex.graphics); var test2: shape = new shape(); test2.graphics.copyfrom(complex.graphics); addchild(test2);  private function adobeexample(graphics: graphics):void{     // define line style     graphics.linestyle(2,0x000000);      // define fill     graphics.beginfill(0x666699);//set color      // establish new vector object commands parameter     var star_commands:vector.<int> = new vector.<int>();      // use  vector array push() method add moveto() , lineto() values     // 1 moveto command followed 3 lineto commands     star_commands.push(1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2);      // establish new vector object data parameter     var star_coord:vector.<number> = new vector.<number>();      // use vector array push() method add set of coordinate pairs     star_coord.push(0,0, 75,50, 100,0, 125,50, 200,0, 150,75, 200,100, 150,125, 200,200, 125,150, 100,200, 75,150, 0,200, 50,125, 0,100, 50,75, 0,0);     graphics.drawpath(star_commands, star_coord); } 

Comments

Popular posts from this blog

php - SPIP: From Tag directly to an article -

jquery - isAjaxRequest always return false -

ruby on rails - In a controller spec, how to find a specific tag in the generated view? -