Foundation Flash CS5 For Designers- P16
Số trang: 50
Loại file: pdf
Dung lượng: 1.31 MB
Lượt xem: 15
Lượt tải: 0
Xem trước 5 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Foundation Flash CS5 For Designers- P16: Flash is one of the most engaging, innovative, and versatile technologies available-allowing the creation of anything from animated banners and simple cartoons to Rich Internet Applications, interactive videos, and dynamic user interfaces for web sites, kiosks, devices, or DVDs. The possibilities are endless, and now it just got better
Nội dung trích xuất từ tài liệu:
Foundation Flash CS5 For Designers- P16 BUILDING STUFFhugging the left edge of SeekBar. As it is, however, the numbers are easy. To coordinate its movementswith SeekBar, all SeekKnob has to do is know SeekBar‘s horizontal position (seekBar.x) and take intoconsideration SeekBar’s width (seekBar.width).To position the knob along the bar’s left edge, all you need to do set its MovieClip.x property to the bar’sMovieClip.x property. To slide it halfway across, set the knob’s x property to the x property of the bar,plus half of the bar’s width. To shove it all the way over, set its x property to bar’s, plus the full width of thebar. Keep this principle in mind as we work through the seek slider ActionScript.To begin, copy another one of the commented code block headers and paste it below the last bit ofActionScript (nextHandler(), from the Buttons section). Change the header’s caption to Seek slider,and then type in the following ActionScript, so that your code looks like this:////////////////////////////////////////// Seek slider////////////////////////////////////////// prepseekKnob.buttonMode = true;// eventsseekKnob.addEventListener(MouseEvent.MOUSE_DOWN, seekStartDrag);Like the Prev, Play/Pause, and Next movie clip “buttons,” the seekKnob instance needs to have itsbuttonMode property set to true. When the user clicks it, you want the user to be able to start draggingthat knob, so the MouseEvent.MOUSE_DOWN event is associated with a custom function you’re about towrite, called seekStartDrag(). That function is triggered when the user clicks the mouse (MOUSE_DOWN)on the seekKnob instance. Type the following new ActionScript:function seekStartDrag(evt:MouseEvent):void { if (song != null) { pauseSong(); rect = new Rectangle(seekBar.x, seekKnob.y, seekBar.width, 0); seekKnob.startDrag(true, rect); stage.addEventListener(MouseEvent.MOUSE_UP, seekStopDrag); }};If the song instance isn’t null— for example, it’s null before a song is chosen from the combo box—thenpause the song, in case it’s playing. Next, define a Rectangle instance (stored in the rect variable),which will be used to constrain dragging to the desired location.Rectangle instances are specified at a particular location (x and y) and at a particular width and height. Inthis case, we want the knob to be draggable only from the left side of the bar (seekBar.x, the firstparameter) to the right side (seekBar.width, the third parameter). Its vertical position is fine where it is(seekKnob.y, the second parameter) and shouldn’t vary from that, which means we set the rectangle to aheight of 0 (the fourth parameter). 729 www.zshareall.com CHAPTER 14 The MovieClip.startDrag() method, invoked on seekKnob, is fed two parameters: true, which snaps dragging to the symbol’s registration point, and rect, which confines dragging to the dimensions just described. Finally, a MouseEvent.MOUSE_UP event handler is associated with the stage, configured to trigger a custom seekStopDrag() function. Why is this association made with the stage, rather than with seekKnob? Because the user might just drag the mouse off the knob before releasing the mouse (MOUSE_UP). If the event handler were associated with seekKnob, then seekStopDrag() wouldn’t be triggered. But when it’s assigned to the stage, that pretty much means the mouse can be lifted anywhere, and the dragging routine will stop. Here’s the seekStopDrag() function. Type the following new ActionScript: function seekStopDrag(evt:MouseEvent):void { seekKnob.stopDrag(); playSong(song.length * (seekKnob.x - seekBar.x) / seekBar.width); stage.removeEventListener(MouseEvent.MOUSE_UP, seekStopDrag); };This book was purchased by flashfast1@gmail.com ...
Nội dung trích xuất từ tài liệu:
Foundation Flash CS5 For Designers- P16 BUILDING STUFFhugging the left edge of SeekBar. As it is, however, the numbers are easy. To coordinate its movementswith SeekBar, all SeekKnob has to do is know SeekBar‘s horizontal position (seekBar.x) and take intoconsideration SeekBar’s width (seekBar.width).To position the knob along the bar’s left edge, all you need to do set its MovieClip.x property to the bar’sMovieClip.x property. To slide it halfway across, set the knob’s x property to the x property of the bar,plus half of the bar’s width. To shove it all the way over, set its x property to bar’s, plus the full width of thebar. Keep this principle in mind as we work through the seek slider ActionScript.To begin, copy another one of the commented code block headers and paste it below the last bit ofActionScript (nextHandler(), from the Buttons section). Change the header’s caption to Seek slider,and then type in the following ActionScript, so that your code looks like this:////////////////////////////////////////// Seek slider////////////////////////////////////////// prepseekKnob.buttonMode = true;// eventsseekKnob.addEventListener(MouseEvent.MOUSE_DOWN, seekStartDrag);Like the Prev, Play/Pause, and Next movie clip “buttons,” the seekKnob instance needs to have itsbuttonMode property set to true. When the user clicks it, you want the user to be able to start draggingthat knob, so the MouseEvent.MOUSE_DOWN event is associated with a custom function you’re about towrite, called seekStartDrag(). That function is triggered when the user clicks the mouse (MOUSE_DOWN)on the seekKnob instance. Type the following new ActionScript:function seekStartDrag(evt:MouseEvent):void { if (song != null) { pauseSong(); rect = new Rectangle(seekBar.x, seekKnob.y, seekBar.width, 0); seekKnob.startDrag(true, rect); stage.addEventListener(MouseEvent.MOUSE_UP, seekStopDrag); }};If the song instance isn’t null— for example, it’s null before a song is chosen from the combo box—thenpause the song, in case it’s playing. Next, define a Rectangle instance (stored in the rect variable),which will be used to constrain dragging to the desired location.Rectangle instances are specified at a particular location (x and y) and at a particular width and height. Inthis case, we want the knob to be draggable only from the left side of the bar (seekBar.x, the firstparameter) to the right side (seekBar.width, the third parameter). Its vertical position is fine where it is(seekKnob.y, the second parameter) and shouldn’t vary from that, which means we set the rectangle to aheight of 0 (the fourth parameter). 729 www.zshareall.com CHAPTER 14 The MovieClip.startDrag() method, invoked on seekKnob, is fed two parameters: true, which snaps dragging to the symbol’s registration point, and rect, which confines dragging to the dimensions just described. Finally, a MouseEvent.MOUSE_UP event handler is associated with the stage, configured to trigger a custom seekStopDrag() function. Why is this association made with the stage, rather than with seekKnob? Because the user might just drag the mouse off the knob before releasing the mouse (MOUSE_UP). If the event handler were associated with seekKnob, then seekStopDrag() wouldn’t be triggered. But when it’s assigned to the stage, that pretty much means the mouse can be lifted anywhere, and the dragging routine will stop. Here’s the seekStopDrag() function. Type the following new ActionScript: function seekStopDrag(evt:MouseEvent):void { seekKnob.stopDrag(); playSong(song.length * (seekKnob.x - seekBar.x) / seekBar.width); stage.removeEventListener(MouseEvent.MOUSE_UP, seekStopDrag); };This book was purchased by flashfast1@gmail.com ...
Tìm kiếm theo từ khóa liên quan:
tài liệu Flash CS3 thiết kế web hướng dẫn sử dụng photoshop thiết kế layout kĩ năng lập trình FlashGợi ý tài liệu liên quan:
-
Báo cáo thực tập: Đề tài thiết kế Web
77 trang 552 2 0 -
Đề thi thực hành môn Thiết kế Web - Trường Cao đẳng nghề Vĩnh Phúc
3 trang 260 2 0 -
GIÁO TRÌNH LẬP TRÌNH WEB_PHẦN 2_BÀI 3
3 trang 102 0 0 -
MỘT SỐ ĐIỂM CẦN CHÚ Ý KHI THIẾT KẾ WEB
5 trang 101 0 0 -
Giáo trình Nhập môn thiết kế website
58 trang 72 0 0 -
Thiết kế dàn trang nâng cao trong khám phá Adobe Indesign
340 trang 71 1 0 -
Tài liệu giảng dạy Thiết kế giao diện Web - Trường CĐ Kinh tế - Kỹ thuật Vinatex TP. HCM
88 trang 70 0 0 -
112 trang 60 0 0
-
Hướng dân sử dụng Navicat để Create , Backup , Restore Database
7 trang 60 0 0 -
Giáo trình môn Kỹ thuật vi điều khiển: Thiết kế web và vi điều khiển - Chương 2
39 trang 55 0 0