Thứ Bảy, 27 tháng 11, 2010

Flash Mask Effect






Click here to see another example. Tutorial is on the video section of the forum.

Part1: Getting the images and editing it in Photoshop.
First find a image that you want to add the effect to, I found the image I used in this tutorial from freephotosbank.com. Click here to copy the image I used, after copying the image and paste it into Photoshop. Duplicate the image 2 times, click on the layer you duplicated and click Filter Blur -> Gaussian -> Blur... as shown below.

After that the window below will come up, change the Radius to 6.5 pixels and click ok.

If you want to give you image any kind of effect you can do it. I added a stroke to the images using blending options. After you are satisfied with your images you have to export both the blurred image and the original. we will do this one at a time, Hide all the layers except the one you want to export

after that click File -> Save for Web... save the image as JPEG. Repeat this for the blurred image.

Part2: Importing the images into Flash and working with it.
Create a new Document using the settings shown below. The dimensions will depend on your image size you are using.

Next import the Blurred image first into flash File -> Import -> Import to Stage.

Change the X and Y positions to 5 as shown below.

Create a new layer, and import the Original Image. Use the same position as above. Your layers setup should look like the screenshot below.

Part3: Creating the Icon that follows the icon.

Next insert a New Layer and name it border, as shown below.

Click on Frame 1 of the Border layer. Click on the Rectangular Tool using the settings below.

Create a small square.

Next insert a New Layer and name it Mask, as shown below. Make sure the layer position is the same as mine in the image.

Click to select the Mask Layer using the Rectangular Tool with the settings below.

Create a Rectangle in side the border, as shown below.

Part4: Adding the code to allow the mouse to follow your courser.
First we need to convert the images on the mask and border layers to a movie clip. Make sure the Mask layer is selected right click on the Blue square and select Convert to Symbol

The window below will come up select Movie Clip and click ok.

After that click windows-> properties -> properties

Change the Instance Name to px1 as shown above. Repeat step 4 for the border layer. In this case change the Instance Name to px2.

Click on the first frame, of the border layer and open up the Action window. with the action window open copy and paste this code into the First Frame.

speed = .9;
setInterval(CursorMovement, 40);
function CursorMovement() {
px2._x = speed*(px2._x-_xmouse)+_xmouse;
px2._y = speed*(px2._y-_ymouse)+_ymouse;
}

With that click on the first frame, of the Mask layer and add the code below.

speed = .9;
setInterval(CursorMovement, 40);
function CursorMovement() {
px1._x = speed*(px1._x-_xmouse)+_xmouse;
px1._y = speed*(px1._y-_ymouse)+_ymouse;
}

At this point your layers should look like the image below.

Part5: Adding the Mask Effect.
Right click on the Mask Layer and click Mask.

Now go test your movie.

Finished:
Well that is it. Hope it is what you expected. If you have, any questions or comments feel free to e-mail me or leave a message on the forum. If you are having a hard time with the tutorial email, me and I will try to help. I also created a video tutorial for this example. The file is a 9 MB flash file. I have the link up on the video section on the forums. Users have to register to view the file, click here to register and view the file.

----------------------------------------------------------------------------------------------

Tut cho ứng dụng Mask trong flash








- Đầu tiên, bạn khởi động chương trình Flash (tôi sẽ hướng dẫn bạn sử dụng bằng Macromedia Flash Professional 2004), chọn File > New... để tạo một file mới trong vùng làm việc.
- Import vào flash 1 picture mà bạn muốn làm hiệu ứng. Ở đây tôi dùng picture này làm ví du.



- Nhấn Ctr+L để mở thư viện, trong cửa sổ thư viện kéo picture(mới import vào) vào trong vùng làm việc.


- Để chỉnh picture nằm giữa vùng làm việc, ta có thể nhấn Ctr+Alt+2 và Ctr+Alt+5.
- Click phải chuột vào picture chọn Covert to Symbol(hoặc nhấn F8), đặt tên và hiệu chỉnh như hình bên dưới, cuối cùng chọn OK.



-Click vào Picture (lúc này đã được chuyển thành graphic symbol “girl_gr”, sau này tui sẽ ko gọi là picture nữa mà gọi trực tiếp là “girl_gr”), vào Properties -> color -> Alpha=99%.



- Cuối cùng đổi tên Layer1 thành Layer "bg"

Bước 2: Tạo Movie clip

- Nhấn Ctr+F8 để tạo 1 movie, đặt tên là "ripple_mc", nhấn OK



- Trong vùng làm việc của movie clip , trên Layer1 -> click frame thứ nhất -> vào thư viện kéo Graphic Symbol “girl_gr” (vừa mới tạo ở trên) vào vùng làm việc .
-Tiếp tục click chọn “girl_gr” , vào Properties chọn Alpha = 0%



-Tại frame thứ 5 trên Layer1, nhấn F6.
-Cũng tại frame thứ 5 , click chọn “girl_gr “, vào Properties chọn Alpha=99%.
- Trên thanh Timeline, tại frame thứ nhất, click phải chuột, chọn Create Motion Tween



- Tiếp tục nhấn F6 tại frame thứ 15, thứ 20..
- Tại frame thứ 20, click chọn "girl_gr", vào properties -> color -> Alpha=0%
- Trên thanh Timeline, tại frame thứ 15, click phải chuột , chọn Create Motion Tween
kết quả như sau:



- Tạo thêm 1 Layer mới trong movie clip(là Layer2).
- Tại Frame thứ nhất trên Layer2, vẽ một hình chữ nhật(nhớ bỏ khung viền), chiều rộng = chiều rộng của "girl_gr", chiều cao ta nên cho nhỏ thôi vì càng nhỏ thì hiệu ứng càng mịn.
- Đặt hình chữ nhật vào giữa "girl_gr"(vì picture là do 2 image ghép lại, ở đây tui muốn làm hiệu ứng cho image bên dưới, nên tui phải đặt hình chữ nhật = phía trên của image bên dưới => vì thế hình chữ nhật sẽ nằm chính giữa)



-Trên Layer2, nhấn F6 tại frame thứ 20. Cũng tại frame thứ 20 ta kéo hình chữ nhật về phía dưới cùng của "girl_gr" và giảm bớt chiều cao hình chữ nhật.



- Trở lại frame thứ nhất trên Layer2, vào properties -> Tween -> Shape



- Cuối cùng vào Layer2, click phải chuột chọn Mask



BƯỚC CUỐI CÙNG

- Quay trở lại vùng làm việc chính(Scene 1)
- Insert 1 Layer mới đặt tên là Layer"ripple1", Layer này nằm trên Layer"bg".
- Tại frame thứ nhất trên Layer"ripple1", kéo movie clip "ripple_mc" vào trong vùng làm việc, chỉnh movie này nằm giữa "girl_gr" (giống như ta chỉnh hình chữ nhật ở trên) và cuối cùng nhấn F5 tại frame thứ 20.



-Tương tự, tui Insert thêm một Layer mới đặt tên là Layer"ripple2", layer này nằm trên Layer"ripple1". tại frame thứ 4 , keo movie clip "ripple_mc" vào trong vùng việc, chỉnh movie này nằm trùng với movie của layer"ripple1" và cuối cùng tại frame thứ 24 nhấn F5.

-Tương tự tạo thêm Layer"ripple3", kéo "ripple_mc" tại frame thứ 7 và nhấn F5 tại frame thứ 33.

-Tương tự layer"ripple4", tại frame thứ 10 và frame thứ 36.

- Cuối cùng nhấn F5 tại frame thứ 36 cho Layer"bg".




Phù...phù thế là xong, các bạn nhấn tổ hợp Ctr+Enter xem kết quả như thế nào nhé.

Bản demo xem tại đây.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | 100 Web Hosting