Học Actionscript 3.0 - p 11

The Sum of Its Parts and is required in this case because you may pass different data types into the function: DisplayObject or DisplayObjectContainer (a display object that can contain children). The second parameter is used by the function itself, and its value will ultimately indent each level of child objects, formatting the output to show the hierarchical relationships in the file. Here is a sample output of a file that contains two movie clips. We’ll walk through another example after we discuss the code. root1 [object MainTimeline] myMovieClip [object MovieClip] myMovieClip [object MovieClip] N OT E You can also omit a data type to prevent the compiler from testing. | The Sum of Its Parts and is required in this case because you may pass different data types into the function DisplayObject or DisplayObjectContainer a display object that can contain children . The second parameter is used by the function itself and its value will ultimately indent each level of child objects formatting the output to show the hierarchical relationships in the file. Here is a sample output of a file that contains two movie clips. We ll walk through another example after we discuss the code. rootl object MainTimeline myMovieClip object MovieClip myMovieClip object MovieClip Note that the second parameter of the showChildren function has a default value of 0 so you don t have to pass anything into the function for this parameter to work. Line 19 shows the syntax for calling the function and passes in the stage for analysis but no second argument. Therefore the default value of the argument will be used. In this example the function will trace the contents of all children of the stage. Lines 2 through 8 of the function define a for loop which will loop until there are no more children in the display object passed to the function. The number of loops is determined by the aforementioned numChildren property. Each time through the loop line 3 populates the obj variable with the next child in the display list using the getChildAt method. This determines the child object at the display list index indicated by the loop counter i . The first time through the loop when i is 0 the first child will be returned equivalent to getChildAt 0 . The second time when i is 1 the second child will be returned and so on. Once a display object reference is obtained line 4 traces the object name and the reference itself as arguments 2 and 3 of the trace statement. The latter is handy because the type of object will also be displayed. For example if the object is a movie clip called logo the output will say logo object MovieClip . But line 4 also does something else. The .

Không thể tạo bản xem trước, hãy bấm tải xuống
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.