Learning AS3: Dynamically modifying the frame frequency of a movie
Source: Internet
Author: User
Dynamically in AS3, you can use the stage class to dynamically modify the frame frequency of a movie.
The Stage object of the Stage class (Flash.display.Stage) is the stage for all Sprite and MovieClip and other components in the security sandbox. The frame frequency of a stage object can be any number from 0.01 to 1000. To modify the frame frequency, use the following code:
//change frame frequency to 12 frames per second (FPS) Stage.framerate = 12; The scope and class of a class method are bound together
AS3 is completely based on class constructs. When a class is created, parameters, variables, methods, or any instances of the class are created at the same time. Unlike AS2, a method in AS3 uses the same scope as the class when it executes. For example, the following code:
Package { Import Flash.display.Sprite;
public class Classscope extends Sprite {
Public Function Classscope () { Tracethis (); Output "Class Instance"
var obj:object = new Object (); Obj.tracethis = Tracethis; Obj.tracethis (); Output "Class Instance"
Tracethis.call (New Sprite ()); Output "Class Instance" }
public override function ToString (): String { Return "Class Instance"; }
Public Function tracethis (): void { Trace (this); } } Graphics objects and drawing APIs
Like AS1 and AS2, AS3 also provides a drawing API to draw vector segments and graphs. In AS3, however, the drawing API is defined as a drawing object (Flash.display.Graphics), independent of the Display object (displayed objects:moiveclip,sprites, and so on). Graphic objects have various drawing methods used to draw graphics internally. As before, the graphics content will be at the bottom of all objects. At the same time, there are some new ways to help you easily draw simple graphics in AS3. Including:
Draw a rectangle with a blue rounded corner
var square:sprite = new Sprite ();
Square.graphics.beginFill (0xFF);
Square.graphics.drawRoundRect (0, 0, 100, 50, 10, 10);
Square.graphics.endFill ();
AddChild (square);
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.