Oct 13, 2007

Creating photorealistic waves in Flash.

Flash Tutorial

click on images to see their original size

PHOTOREALISTIC FLASH WAVES PREVIEW IS HERE!


Let’s start with taking a picture of sunset, like this one:




Save it as a sky.jpg

After that, open it in photoshop, and go to Edit – Transform > Flip vertical. Save this image as a “water”




Each of our two images is 406x172 px,.

Now, open Flash, and create a new document 400x330 px.




Press Ctrl+R (import), and import a sky.jpg file. Plase it in the upper part of our document, make sure it is selected, press F8 to make it movie clip, name it sky_mc.




Create new layer, press again Ctrl+R, import water.jpg file, place it under “sky” picture, also convert it to movie clip, and name it as a water_mc. Put the layer under the sky layer.




Create new layer, out of document draw a rectangle (400 px with) and paint it with a gradient from white to black. Make sure it is selected, press F8 to convert it to movie clip and name it as a gradient_mc.




Now click on each image, and check their names here:





After that, create a new layer, press F9, and in the window that appeared – paste this script.



var w = water_mc._width;
trace(w);
var h = water_mc._height;
ripple = new flash.display.BitmapData(w, h);
ripple3 = new flash.display.BitmapData(w, h / 2);
ripple2 = new flash.display.BitmapData(w, h / 4);
ripple1 = new flash.display.BitmapData(w, h / 4);
gradient = new flash.display.BitmapData(ripple.width, ripple.height);
gradient.draw(gradient_mc, new flash.geom.Matrix(1, 0, 0, 1, 0, 0));
gradient_mc._visible = false;
offset3 = new flash.geom.Point(0, 0);
offset2 = new flash.geom.Point(0, 0);
offset1 = new flash.geom.Point(0, 0);
speed1 = -0.300000;
speed2 = -0.600000;
speed3 = -1.200000;
pt = new flash.geom.Point(0, 0);
rect = new flash.geom.Rectangle(0, 0, ripple.width, ripple.height);
this.onEnterFrame = function ()
{
offset1.y = offset1.y + speed1;
offset2.y = offset2.y + speed2;
offset3.y = offset3.y + speed3;
ripple3.perlinNoise(0, 15, 1, seed, true, true, 1, true, [offset3]);
ripple2.perlinNoise(0, 10, 1, seed, true, true, 1, true, [offset2]);
ripple1.perlinNoise(0, 5, 1, seed, true, true, 1, true, [offset1]);
ripple.copyPixels(ripple1, r1rect, r1pt);
ripple.copyPixels(ripple2, r2rect, r2pt);
ripple.copyPixels(ripple3, r3rect, r3pt);
ripple.merge(gradient, rect, pt2, 127, 127, 127);
dMap = new flash.filters.DisplacementMapFilter(ripple, pt, null, 1, 100, 100, "WRAP");
water_mc.filters = [dMap];
};
r1rect = new flash.geom.Rectangle(0, 0, ripple1.width, ripple1.height);
r2rect = new flash.geom.Rectangle(0, 0, ripple2.width, ripple2.height);
r3rect = new flash.geom.Rectangle(0, 0, ripple3.width, ripple3.height);
r1pt = new flash.geom.Point(0, 0);
r2pt = new flash.geom.Point(0, ripple1.height);
r3pt = new flash.geom.Point(0, ripple1.height + ripple2.height);

That’s it!!!

PHOTOREALISTIC FLASH WAVES PREVIEW IS HERE!

You can download an original *.fla file with layers here.


Copyright © http://megatutorials.blogspot.com

AddThis Social Bookmark Button

31 comments:

Anonymous said...

thanks!

Anonymous said...

wow! nice! but why doesnt the code work with other sizes? i created an excact copy but skyscraper sizes and it didnt work :(

Sorin David said...

nice job. but what if sky_mc and water_mc don't have the same hight?!

Anonymous said...

i dont see any effect when i play it.
it shows me 400 in the output popup window.

Anonymous said...

Did not work for me.

Efendi said...

brilliant !

haxan said...

An awesome tutorial. Really love it.

Anonymous said...

Its fun. fantastic-Rishi

Anonymous said...

come back and explain the code. then most peoples problems might be solved. great result tho!

Zeit said...

you really should explain the code...

muthu said...

It is really amazing looking cool great job

ramzaghi said...

it was awesome but there appeared a 406.5 warning in the output popup window :)

ramzaghi said...

it was awesome but there appeared a 406.5 warning in the output popup window :)

ramzaghi said...

it was awesome but there appeared a 406.5 warning in the output popup window :)

ramzaghi said...

it was awesome but there appeared a 406.5 warning in the output popup window :)

ramzaghi said...

it was awesome but there appeared a 406.5 warning in the output popup window :)

ramzaghi said...

it was awesome but there appeared a 406.5 warning in the output popup window :)

Anonymous said...

i dont see any effect when i play it.
it shows me 406 in the output popup window.

Saliya said...

Awesome!!!!!! I failed the first time . i tried again and it worked! Cool As!!! But 406 kept coming in the output.

Mike said...

Hello,

I am contacting you on behalf of www.flashcomponents.net . I've read one of your tutorials and I like the way you write. Our site is continuously growing and we recently added a tutorial section. We kindly ask for your approval to allow us to publish your tutorials on our site, mentioning you as the author.
Of course, we are inviting you to do it yourself, but either way, it would be our pleasure to publish them.

Kind regards,
Mike | Flash Components Team
Mail: flashcomponents@hotmail.com

Calliope said...

It is a smart nice effect indeed! However

1) I see people commenting without the writer ever replying to them, is he there,has he forgotten about his tutorial?!

2)at least two more standard sizes would make the tutorial more efficient. Or maybe tell us how to change the AS code for that?

3)no commenting in AS whatsoever, how are we to understand it's sections without puzzling ourselves?

Anonymous said...

To solve that Problem, which makes Flash Movie do not run like Sample, you have to create a new project in Actionscript 2.0, not Actionscript 3.0, at the beginning of your Work.

Have fun!

Anonymous said...

This looks nice but can this be made in AS3 as well?

electric ufo said...

to answer some of your questions:

resizing it depends on your gradient and matrix. the matrix can resize it, but for an easy way, just make the gradient square wider than your document.

do this for the shape of the square and not the movieclip.



also, when you get an 'error message' its actually because of the second line that says "trace(w);". this line does not affect your document, it just give you the output of your width. you can erase it completely.

finally, no this does not work for AS3

MantasMMM said...

It gives some serious cpu usage if used in larger movies and higher frame rate. Can anyone explain how to optimize it at least for 35frames/sec?

Nice tutorial, but code could be explained. I wasn;t able to make any difference on CPU load except by lowering frame rate.

瑞成 said...

铜米机
碳雕
炭雕
活性炭
活性炭雕
空气净化产品
好想你枣
北京好想你枣
轴承
进口轴承
FAG轴承
NTN轴承
NSK轴承
SKF轴承
网站建设
网站推广
googel左侧优化
googel左侧推广
搜索引擎优化
仓壁振动器
给料机
分子蒸馏
短程蒸馏
薄膜蒸发器
导热油
真空泵油
胎毛笔
手足印
婴儿纪念品
婴幼儿纪念品
园林机械
草坪机
油锯
小型收割机
收割机
割灌机
割草机
电动喷雾器
地钻
采茶机
婚纱
北京婚纱
婚纱礼服
北京婚纱店
个性婚纱
礼服
北京礼服
礼服定制
礼服出租
飘人|飘人2008|云淡风清
罗茨鼓风机
三叶罗茨鼓风机
罗茨风机
章丘罗茨鼓风机
鼓风机
三叶罗茨风机
章丘鼓风机
章丘三叶罗茨风机
铣刀
意大利留学
留学意大利
钢管舞
钢管舞培训
北京钢管舞
爵士舞
北京音皇国际
泳池设备
桑拿设备
印刷厂

北京现代 said...

shanghai hotel

guangzhou hotel

shenzhen hotel

beijing hotel

guangzhou hotel

Shenzhen hotel

shanghai hotel

beijing hotel

回转支承

转盘轴承

slewing ring

slewing bearing

slewing bearings

herehereo said...

球鞋
nikedao
nikedao.com
NIKE
ADIDAS
PUMA
妮可鞋岛
NIKE运动鞋
NIKE跑鞋
妮可岛
运动鞋
ADIDAS
板鞋
妮可鞋岛
妮可岛
阿迪达斯
妮可鞋岛
NIKE
ADIDAS
ADIDAS运动鞋
ADIDAS
阿迪达斯
运动鞋
运动鞋
板鞋
运动鞋
跑鞋
耐克
球鞋
休闲鞋
男女鞋
男女鞋
品牌
休闲鞋
耐克

Anonymous said...

i dont see any effect when i play it.
it shows me 406 in the output popup window.

Buzz said...

I mean great effect but come on, at least explain a bit the code, your just saying copy and paste this code and thats it, what kind of tutorial is this, its more of a demo not tutorial.

sexy said...

情趣用品,情趣用品,情趣用品,情趣用品,情趣用品,情趣,情趣,情趣,情趣,情趣,按摩棒,跳蛋,充氣娃娃,情境坊歡愉用品,情趣用品,情人節禮物,情惑用品性易購

免費A片,AV女優,美女視訊,情色交友,免費AV,色情網站,辣妹視訊,美女交友,色情影片,成人影片,成人網站,A片,H漫,18成人,成人圖片,成人漫畫,情色網,日本A片,免費A片下載,性愛

A片,色情,成人,做愛,情色文學,A片下載,色情遊戲,色情影片,色情聊天室,情色電影,免費視訊,免費視訊聊天,免費視訊聊天室,一葉情貼圖片區,情色,情色視訊,免費成人影片,視訊交友,視訊聊天,視訊聊天室,言情小說,愛情小說,AIO,AV片,A漫,av dvd,聊天室,自拍,情色論壇,視訊美女,AV成人網,色情A片,SEX

情趣用品,A片,免費A片,AV女優,美女視訊,情色交友,色情網站,免費AV,辣妹視訊,美女交友,色情影片,成人網站,H漫,18成人,成人圖片,成人漫畫,成人影片,情色網



情趣用品,A片,免費A片,日本A片,A片下載,線上A片,成人電影,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,微風成人區,成人文章,成人影城,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,臺灣情色網,色情,情色電影,色情遊戲,嘟嘟情人色網,麗的色遊戲,情色論壇,色情網站,一葉情貼圖片區,做愛,性愛,美女視訊,辣妹視訊,視訊聊天室,視訊交友網,免費視訊聊天,美女交友,做愛影片

av,情趣用品,a片,成人電影,微風成人,嘟嘟成人網,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,成人文章,成人影城,愛情公寓,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,色情,寄情築園小遊戲,情色電影,aio,av女優,AV,免費A片,日本a片,美女視訊,辣妹視訊,聊天室,美女交友,成人光碟

情趣用品.A片,情色,情色貼圖,色情聊天室,情色視訊,情色文學,色情小說,情色小說,色情,寄情築園小遊戲,情色電影,色情遊戲,色情網站,聊天室,ut聊天室,豆豆聊天室,美女視訊,辣妹視訊,視訊聊天室,視訊交友網,免費視訊聊天,免費A片,日本a片,a片下載,線上a片,av女優,av,成人電影,成人,成人貼圖,成人交友,成人圖片,18成人,成人小說,成人圖片區,成人文章,成人影城,成人網站,自拍,尋夢園聊天室