Gốc > Kiến thức tin học > Học AS3 >
TẠO MOUSE CURSOR
vào Flash nhấn Ctrl+F8 tạo một movie mới với tên là mycursor sau đó tạo một movie để làm cursor
ra Scene 1 nhấn Ctrl+L mở Library kéo thả movie bạn vừa tạo xong vào
trong panel Property đặt tên là mycursor trong phần Instance Name
PASS CODE SAU VÀO FRAME 1
Ctrl+Enter để test thử
/------------------------------/
CHỮ CHẠY THEO MOUSE
Tạo đoạn text chạy theo mouse
Mở FlashMX->Ctrl+F8->chọn checkbox food network trong Name đánh mc.character->click button Advanced (nếu có sẳn button Basic thì làm bước kế tiếp)->chọn checkbox Export for ActionScript trong Indentifier đánh character ->click OK -> trong movie mc.character tạo DynamicText với Instances Name là field -> ra Scene 1 chọn frame1 click chuột phải chon Action Copy/past các đoạn mã sau
THAY ĐỔI MÀU NỀN NGẪU NHIÊN
Mở FlashMX chọn frame1 nhấp F9(hoặc click chuột phải chon Action )Copy/past các đoạn mã
Lê Trọng Nghĩa @ 13:13 22/07/2011
Số lượt xem: 2028
Một số code Actionscript trong Flash
TẠO MOUSE CURSOR
vào Flash nhấn Ctrl+F8 tạo một movie mới với tên là mycursor sau đó tạo một movie để làm cursor
ra Scene 1 nhấn Ctrl+L mở Library kéo thả movie bạn vừa tạo xong vào
trong panel Property đặt tên là mycursor trong phần Instance Name
PASS CODE SAU VÀO FRAME 1
| QUOTE |
//star code _root.onEnterFrame = function() { Mouse.hide();//an mouse mycursor._x = _root._xmouse; mycursor._y = _root._ymouse; } //end code |
Ctrl+Enter để test thử
/------------------------------/
CHỮ CHẠY THEO MOUSE
Tạo đoạn text chạy theo mouse
Mở FlashMX->Ctrl+F8->chọn checkbox food network trong Name đánh mc.character->click button Advanced (nếu có sẳn button Basic thì làm bước kế tiếp)->chọn checkbox Export for ActionScript trong Indentifier đánh character ->click OK -> trong movie mc.character tạo DynamicText với Instances Name là field -> ra Scene 1 chọn frame1 click chuột phải chon Action Copy/past các đoạn mã sau
| QUOTE |
//star code function transition(chars) { // Delete the old characters if // the effect has been run before... if (i != undefined) { for (j=0; j<i; j++) { _root["char"+j].removeMovieClip(); } } // Create a text field per character... for (i=0; i<chars.length; i++) { // create an empty clip... name = "char"+i; this.attachMovie("character", name, depthCount); // write the character into the clip textfield... this[name].field.text = chars.substr(i, 1); // add event handler for animation... if (i == 0) { this[name].onEnterFrame = follower; } else { this[name].onEnterFrame = mover; this[name].before = "char"+(i-1); } // update depth... depthCount++; } } function follower() { this._x = _xmouse+20 this._y = _ymouse; } function mover() { this.targetX = _root[this.before]._x; this.targetY = _root[this.before]._y; this._x -= -10+(this._x-this.targetX)/inertia; this._y -= (this._y-this.targetY)/inertia; } _root.onMouseDown = function() { transition("you have clicked the mouse"; }; depthCount = 100; inertia = 1.5; mystr="you have not clicked yet";//your text here transition(mystr); //end code |
THAY ĐỔI MÀU NỀN NGẪU NHIÊN
Mở FlashMX chọn frame1 nhấp F9(hoặc click chuột phải chon Action )Copy/past các đoạn mã
| QUOTE |
//star here redSpeed1 = .1; greenSpeed1 = .07; blueSpeed1 = .04; redSpeed2 = .09; greenSpeed2 = .06; blueSpeed2 = .03; rotSpeed = .01; onEnterFrame = function () { redAngle1 += redSpeed1; greenAngle1 += greenSpeed1; blueAngle1 += blueSpeed1; redAngle2 += redSpeed2; greenAngle2 += greenSpeed2; blueAngle2 += blueSpeed2; red1 = Math.sin(redAngle1)*127+128; green1 = Math.sin(greenAngle1)*127+128; blue1 = Math.sin(blueAngle1)*127+128; red2 = Math.sin(redAngle2)*127+128; green2 = Math.sin(greenAngle2)*127+128; blue2 = Math.sin(blueAngle2)*127+128; col1 = red1 << 16 | green1 << 8 | blue1; col2 = red2 << 16 | green2 << 8 | blue2; rot = Math.sin(rotAngle += rotSpeed)*Math.PI; colors = [col1, col2]; alphas = [100, 100]; ratios = [0, 255]; matrix = {matrixType:"box", x:0, y:0, h:400, w:550, r:rot}; clear(); beginGradientFill("linear", colors, alphas, ratios, matrix); lineTo(550, 0); lineTo(550, 400); lineTo(0, 400); lineTo(0, 0); endFill(); }; //end code |
xedaptinhyeu- 09-16-2004
HIỆU ỨNG CRILCLE
tạo các vong tròn rất đẹp mắt
Mở FlashMX->Ctrl+F8->chọn checkbox Graphic trong Name đánh mc->click button Advanced (nếu có sẳn button Basic thì làm bước kế tiếp)->chọn checkbox Export for ActionScript trong Indentifier đánh mc->click OK -> trong Graphic mc tạo một hình tròn có W=H=100 (hinh tron không có tô màu bên trong)-> ra Scene 1 chọn frame1 click chuột phải chon Action Copy/past các đoạn mã sau
tạo các vong tròn rất đẹp mắt
Mở FlashMX->Ctrl+F8->chọn checkbox Graphic trong Name đánh mc->click button Advanced (nếu có sẳn button Basic thì làm bước kế tiếp)->chọn checkbox Export for ActionScript trong Indentifier đánh mc->click OK -> trong Graphic mc tạo một hình tròn có W=H=100 (hinh tron không có tô màu bên trong)-> ra Scene 1 chọn frame1 click chuột phải chon Action Copy/past các đoạn mã sau
| QUOTE |
//star code c = 10; this.createEmptyMovieClip("blank_mc", 1); blank_mc.onEnterFrame = function() { // step 1: Where's the mouse pointer right now? currx = _root._xmouse; curry = _root._ymouse; // step 2: If it's not in the same location is was last time if (!(prevx == currx && prevy == curry)) { // step 3: Create a new instance of "mc" _root.attachMovie("mc", "mc"+c, c); // step 4: Place the instance at the mouse pointer's position and set size of new instance with (_root["mc"+c]) { _x = currx; _y = curry; _width = 0; _height = 0; } // step 5: Create an enter frame action for each new duplicated mc this._parent["mc"+this._parent.c].onEnterFrame = function() { // Set variable to count the number of frames played this.i++; // Increase circle by (x) pixels this._width += 1.4; this._height += 1.4; // Decrease alpha by (x) amount this._alpha -= 100/60; // If frame reaches 60, remove mc if (this.i>=60) { this.removeMovieClip(); } }; // step 6: Increase the c used for instance names _root.c++; } // step 7: Store where the mouse was, so we can compare that info // to the position in the next program cycle prevx = currx; prevy = curry; }; //end code |
Lê Trọng Nghĩa @ 13:13 22/07/2011
Số lượt xem: 2028
Số lượt thích:
0 người
 
Các ý kiến mới nhất