We Recommend

Essential ActionScript 3.0 Essential ActionScript 3.0
The book focuses on the core language and object-oriented programming, but also adds a deep look at the centerpiece of Flash Player's new API: display programming. Enjoy hundreds of brand new pages covering exciting new language features, such as the DOM-based event architecture, E4X, and namespaces--all brimming with real-world sample code.


Posted By

mswallace on 06/26/07


Tagged

event listener onEnterFrame


Versions (?)


Who likes this?

6 people have marked this snippet as a favorite

bartekk
copyleft
andrewrench
fukami
abdsign
taboularasa


onEnterFrame Event using Actionscript 3


Published in: ActionScript 3 


Got this out of the o'reilly ActionScript 3.0 Cookbook


  1. package {
  2. import flash.display.Sprite;
  3. import flash.events.Event;
  4.  
  5. public class ExampleApplication extends Sprite{
  6.  
  7. public function ExampleApplication(){
  8. graphics.lineStyle(1,0,1);
  9. addEventListener(Event.ENTER_FRAME, onEnterFrame);
  10. }
  11. private function onEnterFrame(event:Event):void{
  12. graphics.lineTo(Math.random() * 400, Math.random() * 400);
  13. }
  14. }
  15. }

Report this snippet 

You need to login to post a comment.