tailieunhanh - Essential ActionScript 3.0 PHẦN 8

Khi tạo ra các điều khiển giao diện người dùng với các hiệu ứng hoạt hình, xem xét mở rộng lớp khung Flex hơn là tạo ra một thư viện hình ảnh động tùy chỉnh. cácMột bản demo Animator (tiếp theo) | Example 24-9. An Animator demo continued Create a circle to animate var circle Shape new Shape 10 0x666666 0X999999 0 0 25 addChild circle Create an Animator to animate the circle circleAnimator new Animator circle Register for mouse clicks mouseDownListener When the user clicks the stage animate the circle to the point that was clicked. private function mouseDownListener e MouseEvent void Convert the point from the Stage instance s coordinate system to this AnimationLibDemo instance s coordinate system var mousePt Point globalToLocal new Point 500 _ _ jr When creating user interface controls with animated effects consider extending the Flex framework s class rather ĨỊÃ than creating a custom animation library. The UIComponent class comes equipped with an extensive toolset for adding effects to custom user interface controls. Velocity-Based Animation In the Flash runtime the specific timing of both scheduled screen-update checks and events is not guaranteed. The event often executes later than the time scheduled by the designated frame rate and events often occur later than the time specified by a Timer object s delay variable. These delays can result in unpredictable animation. To guarantee that a given object will travel a specified distance in a specified amount of time we must set its position according to its velocity . its rate of speed in a particular direction . Example 24-10 shows the basic technique. Example 24-10. Calculating position based on velocity package import . import . import . Velocity-Based Animation 627 Example 24-10. Calculating position based on velocity continued Moves an object a specified number of pixels per second no matter what the frame rate

TỪ KHÓA LIÊN QUAN