Đang chuẩn bị liên kết để tải về tài liệu:
Essential ActionScript 3.0 PHẦN 8

Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ

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 mx.core.UIComponent 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 circle.graphics.lineStyle 10 0x666666 circle.graphics.beginFill 0X999999 circle.graphics.drawCircle 0 0 25 addChild circle Create an Animator to animate the circle circleAnimator new Animator circle Register for mouse clicks stage.addEventListener MouseEvent.MOUSE_DOWN 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 e.stageX e.stageY circleAnimator.animateTo mousePt.x mousePt.y 500 _ _ jr When creating user interface controls with animated effects consider extending the Flex framework s mx.core.UIComponent 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 TimerEvent.TIMER events is not guaranteed. The Event.ENTER_FRAME event often executes later than the time scheduled by the designated frame rate and TimerEvent.TIMER 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 i.e. 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 flash.display. import flash.events. import flash.utils. 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