Học Actionscript 3.0 - p 18

Navigation Bar Revisited 5 6 7 8 9 10 11 12 public class NavigationBar extends MovieClip { private var _navData:Array; public function NavigationBar(navData:Array) { _navData = navData; build(); } In the next code segment, the build() method uses a for loop to add each button to the navigation bar. The loop first creates an instance of the MenuButtonMain class, passing the name of the button as a string for the button’s label. This string comes from the button array passed into the constructor from the document class, and can be seen in line 9 of the prior class. Next, the button is positioned horizontally by starting with a 20-pixel offset, and then multiplying the width. | Navigation Bar Revisited 5 public class NavigationBar extends MovieClip 6 7 private var _navData Array 8 9 public function NavigationBar navData Array 10 _navData navData 11 build 12 In the next code segment the build method uses a for loop to add each button to the navigation bar. The loop first creates an instance of the MenuButtonMain class passing the name of the button as a string for the button s label. This string comes from the button array passed into the constructor from the document class and can be seen in line 9 of the prior class. Next the button is positioned horizontally by starting with a 20-pixel offset and then multiplying the width of the button plus a 2-pixel space for each button. That is the first button starts at 20 pixels because i begins as 0 and no further offset is added. The second button starts at 20 and then 1 button width 2 is added and so on. A fixed y location is also used and each button is added to the display list. Finally the aforementioned horizontal bar from the FLA library is added to the bottom of the menu buttons lines 22 through 25 . Two things are important here. First the line is typed as MovieClip to give you a bit more flexibility. We haven t yet created a dedicated class for this object and it s a movie clip in the FLA. Second as a display object this line movie clip can be a target of mouse events. Because it has no active role in the navigation bar we disable it from interacting with the mouse by setting its mouseEnabled property to false. 13 private function build void 14 for var i uint i i 15 var menuBtn MenuButtonMain 16 new MenuButtonMain _navData i 17 20 i 2 18 75 19 addChild menuBtn 20 21 22 var hline MovieClip new HLineThick 23 100 24 false 25 addChild hline 26 27 28 MenuButtonMain Finally we present the MenuButtonMain class which creates the button for each menu added to the navigation bar. In addition to the previously explained .

Bấm vào đây để xem trước nội dung
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.