Using Actionscript to Draw Lines Dynamically
Số trang: 4
Loại file: pdf
Dung lượng: 22.92 KB
Lượt xem: 5
Lượt tải: 0
Xem trước 2 trang đầu tiên của tài liệu này:
Thông tin tài liệu:
Sử dụng Actionscript để Draw Lines động các Sử dụng ActionScript, bạn tự động có thể rút ra dòng trong một bộ phim vì nó đóng-một khả năng mà đi kèm với một số bản vẽ các phương pháp có sẵn cho các lớp Movie Clip. Sử dụng những phương pháp này vẽ
Nội dung trích xuất từ tài liệu:
Using Actionscript to Draw Lines Dynamically < Day Day Up >Using Actionscript to Draw Lines DynamicallyUsing ActionScript, you can dynamically draw lines in a movie as it plays—a capabilitythat comes with a number of drawing methods available to the Movie Clip class.Using these drawing methods, you can: • Draw a line from the current drawing position to a point you specify • Move the current drawing position without drawing • Specify the line style for a timeline • Fill a shape with a color • Fill a shape with a gradient • Curve a line between two points • Clear a timeline of drawn lines and gradientsIn this section, well show you how to draw lines, move the drawing position, set the linestyle, and clear a movie clip instance. In the next section, well briefly touch on using flatand gradient fills. Although we wont cover the curveTo() method (which allows you todynamically draw curved lines), you should understand enough about Flash drawingfundamentals by the end of the lesson that youll be able to implement it in your owndrawing applications.Using lineStyle()Before drawing any lines in a timeline, you must set the line style for that timeline. Flashuses this setting to determine line thickness, color, and alpha.Heres the syntax:path.lineStyle(thickness, color, alpha)thickness must be a value between 0 and 255 (with a thickness of 0 representing ahairline). color must be a hex color value. alpha represents the transparency level for aline, where 0 is transparent and 100 is opaque. Look at the following example:_root.myClip_mc.lineStyle(10, 0x009900, 100);This line of ActionScript sets the line style in myClip_mc so that all lines drawn will begreen and opaque, and have a thickness of 10.Using moveTo()All movie clip instances have a drawing position that indicates the coordinate at which aline would start—in other words, the beginning point of a line. (You use lineTo() to drawthe line, as described in the next section.) When a movie clip instance is created, thedrawing position is set as x = 0 and y = 0; however, you can move the drawing position atany time using moveTo(). When a line is drawn, the drawing position is updated to theendpoint of the drawn line.The following is the syntax for using moveTo():path.moveTo(x, y);All you need to do is specify the x and y positions of your drawing position. For example:_root.myClip_mc.lineStyle(10,0x009900,100);_root.myClip_mc.moveTo(100,100);This ActionScript sets the line style and then moves the drawing position.Using lineTo()The lineTo() drawing method of the Movie Clip class simply draws a line of thedestination timelines lineStyle format from the drawing position to the end positionspecified in the method.Following is the syntax for lineTo():myClip_mc.lineTo(x,y);The x and y parameters specify the end point of the line to be drawn.NOTEAfter the line is drawn, the moveTo() position is updated to the end point of the line.The following example shows how you would use the methods weve described to draw aline:_root.createEmptyMovieClip(canvas_mc,1);_root.canvas_mc.lineStyle(2,0x009900,100);_root.canvas_mc.moveTo(100,100);_root.canvas_mc.lineTo(200,150);This ActionScript draws a line between the points (100,100) and (200,150). < Day Day Up >
Nội dung trích xuất từ tài liệu:
Using Actionscript to Draw Lines Dynamically < Day Day Up >Using Actionscript to Draw Lines DynamicallyUsing ActionScript, you can dynamically draw lines in a movie as it plays—a capabilitythat comes with a number of drawing methods available to the Movie Clip class.Using these drawing methods, you can: • Draw a line from the current drawing position to a point you specify • Move the current drawing position without drawing • Specify the line style for a timeline • Fill a shape with a color • Fill a shape with a gradient • Curve a line between two points • Clear a timeline of drawn lines and gradientsIn this section, well show you how to draw lines, move the drawing position, set the linestyle, and clear a movie clip instance. In the next section, well briefly touch on using flatand gradient fills. Although we wont cover the curveTo() method (which allows you todynamically draw curved lines), you should understand enough about Flash drawingfundamentals by the end of the lesson that youll be able to implement it in your owndrawing applications.Using lineStyle()Before drawing any lines in a timeline, you must set the line style for that timeline. Flashuses this setting to determine line thickness, color, and alpha.Heres the syntax:path.lineStyle(thickness, color, alpha)thickness must be a value between 0 and 255 (with a thickness of 0 representing ahairline). color must be a hex color value. alpha represents the transparency level for aline, where 0 is transparent and 100 is opaque. Look at the following example:_root.myClip_mc.lineStyle(10, 0x009900, 100);This line of ActionScript sets the line style in myClip_mc so that all lines drawn will begreen and opaque, and have a thickness of 10.Using moveTo()All movie clip instances have a drawing position that indicates the coordinate at which aline would start—in other words, the beginning point of a line. (You use lineTo() to drawthe line, as described in the next section.) When a movie clip instance is created, thedrawing position is set as x = 0 and y = 0; however, you can move the drawing position atany time using moveTo(). When a line is drawn, the drawing position is updated to theendpoint of the drawn line.The following is the syntax for using moveTo():path.moveTo(x, y);All you need to do is specify the x and y positions of your drawing position. For example:_root.myClip_mc.lineStyle(10,0x009900,100);_root.myClip_mc.moveTo(100,100);This ActionScript sets the line style and then moves the drawing position.Using lineTo()The lineTo() drawing method of the Movie Clip class simply draws a line of thedestination timelines lineStyle format from the drawing position to the end positionspecified in the method.Following is the syntax for lineTo():myClip_mc.lineTo(x,y);The x and y parameters specify the end point of the line to be drawn.NOTEAfter the line is drawn, the moveTo() position is updated to the end point of the line.The following example shows how you would use the methods weve described to draw aline:_root.createEmptyMovieClip(canvas_mc,1);_root.canvas_mc.lineStyle(2,0x009900,100);_root.canvas_mc.moveTo(100,100);_root.canvas_mc.lineTo(200,150);This ActionScript draws a line between the points (100,100) and (200,150). < Day Day Up >
Tìm kiếm theo từ khóa liên quan:
máy tính mạng máy tính internet phần mềm ứng dụng lập trình SQL HTML sever web XMLGợi ý tài liệu liên quan:
-
Giáo án Tin học lớp 9 (Trọn bộ cả năm)
149 trang 263 0 0 -
Ngân hàng câu hỏi trắc nghiệm môn mạng máy tính
99 trang 251 1 0 -
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 2
102 trang 244 0 0 -
Bài giảng: Lịch sử phát triển hệ thống mạng
118 trang 244 0 0 -
47 trang 237 3 0
-
Đề cương chi tiết học phần Thiết kế và cài đặt mạng
3 trang 234 0 0 -
80 trang 216 0 0
-
122 trang 212 0 0
-
Giáo trình Hệ thống mạng máy tính CCNA (Tập 4): Phần 1
122 trang 210 0 0 -
Giáo trình môn học/mô đun: Mạng máy tính (Ngành/nghề: Quản trị mạng máy tính) - Phần 1
68 trang 201 0 0