Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

5.1. Jump Right In

We’ll start off with one of the most-desired features in the evolution of ActionScript: the ability to adjust the frame rate of a file with code. Consider a simple example that switches a SWF’s frame rate between 1 and 24 frames per second, with every click of the mouse. This script can be found in the frame_rate_trace.fla source file.

1    stage.frameRate = 24;
2
3    this.addEventListener(Event.ENTER_FRAME, onEnter, false, 0, true);
4    function onEnter(evt:Event):void {
5        trace(stage.frameRate);
6    }
7
8    stage.addEventListener(MouseEvent.CLICK, onClick, false, 0, true);
9    function onClick(evt:MouseEvent):void {
10        if (stage.frameRate == 24) {
11            stage.frameRate = 1;
12        } else {
13            stage.frameRate = 24;
14        }
15    }


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint