Types of Loops

Các loại vòng lặp ActionScript có thể tận dụng ba loại vòng lặp, tất cả đều thực hiện một hành động (hoặc thiết lập các hành động) trong khi một điều kiện cụ thể là sự thật. trong khi Loop Cú pháp để tạo ra loại hình này phổ biến của vòng lặp như sau: trong khi (someNumber | Types of Loops ActionScript can take advantage of three loop types all of which perform an action or set of actions while a specific condition is true. while Loop The syntax for creating this common type of loop is as follows while someNumber 10 perform these actions The expression someNumber 10 is the condition that determines the number of iterations passes through the statement that the loop will perform. With each iteration the actions inside the loop are executed. The logic that determines how the condition is evaluated and how the loop is exited is discussed shortly in the section Writing and Understanding Loop Conditions. Here s an example of the while loop while 0 3 This script moves the myClip_mc movie clip instance along the y axis until its position is greater than 0. for Loop The for loop is a compact all-in-one looping solution for loops that rely on incrementing or decrementing a variable. The for loop lets you initialize a loop variable set the loop condition and increment or decrement that variable all in one line of ActionScript. The for loop is typically used to perform an action or set of actions based on the value of an incremental variable walking an array for example or applying actions to a list of movie clips. Here s the syntax of the for loop for var someNumber Number 0 someNumber 10 someNumber perform these actions The three elements separated by semicolons within the parentheses are used to specify the number of iterations the loop will perform. In this example the variable someNumber is created and assigned an initial value of 0. The script states next that as long as someNumber is less than 10 the loop executes the actions contained in the loop. The last element in the parentheses specifies that someNumber will be incremented by 1 with each loop iteration eventually causing someNumber to have a value of 10 which means that the loop will cease after nine iterations. The for loop is structured to be used .

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.