Using the Drawing Methods

Sử dụng phương pháp Vẽ Trong bài tập này, bạn sẽ sử dụng các phương pháp vẽ của lớp Movie Clip để bắt đầu một ứng dụng bản vẽ đơn giản. 1. Mở trong thư mục Lesson15/Assets. Các chính thời gian bao gồm năm lớp, được đặt tên theo nội dung của họ. | Using the Drawing Methods In this exercise you ll use the drawing methods of the Movie Clip class to start a simple drawing application. 1. Open in the Lesson15 Assets folder. The main timeline includes five layers named according to their contents. The Background layer contains the project s main graphics. The Canvas layer contains a movie clip instance canvas_mc which will be used to define an allowable area in which to draw. The Icon layer contains the movie clip instance with an insect just to the left of the stage. This instance is named icon_mc in a later exercise we ll duplicate it to provide the user with several icons to drag onto canvas_mc to draw over. The Windows layer contains two instances window1_mc and window2_mc which appear to the right of canvas_mc and will be addressed in a later exercise. Finally the Actions layer will be used to store most of the ActionScript used in the final version of this project. The main focus of this exercise is creating ActionScript that will enable you to draw on the canvas. You will use clip events in concert with the hitTest method to determine whether the mouse button is pressed while the mouse pointer is over the canvas_mc instance you will then use the onMouseMove clip event to draw. Every time the onMouseMove event is fired the mouse s positions are recorded and a line is drawn between its last and current position resulting in a drawing. 2. With the Actions panel open select Frame 1 of the Actions layer on the main timeline and add the following script 3. 4. var down Boolean false 5. This line of script creates a variable named down that will be used to store the current state of the mouse. Using the onMouseDown and onMouseUp events this variable s value is set to true or false pressed down or not . When down is true the application will draw lines every time the mouse moves. When down is false no lines are drawn. 3. Add the following onMouseDown clip event at the end of the current script 4. 5. .

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.