Link:INB Home|INB English| INB русский язык|INB العربية|INB Türkiye|INB فارسی|INB Español|INB Français|INB Português|INB Deutsch|INB 國語|INB 中文|INB 日本语|INB 한국어|INB ภาษาไทย|INB tiếng Việt||[FL]Flash Tutorial Move the Mouse to Reveal the Poster
INB English forum
Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, come and join us Permanent name: inb-english.forumotion.com
INB English forum
Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, come and join us Permanent name: inb-english.forumotion.com
INB English forum

Welcome to (Industry & Native boffin) The industrial age here is full of fighting spirit, you and I both through this network space with Native biological spirit boffin came to the mad labs. home INBforum.com, Permanent name: inb-english.forumotion.com


You are not connected. Please login or register

《《《《《《《上一页INBforum   Go down

上一页INBforum》》》》》》》View previous topic View next topic Go down  Message [Page 1 of 1]

1[FL]Flash Tutorial Move the Mouse to Reveal the Poster Empty [FL]Flash Tutorial Move the Mouse to Reveal the Poster Wed Sep 22, 2010 10:26 am

Admin

Admin
Admin
1. This tutorial is a variation of our previous tutorial entitled “Revealing an Image with a Grid Effect Animation”, so first go check it to get the main explanations as we’ll go quickly here.
2. Create a new flash file (Actionscript 3.0) and set its dimensions to the dimensions of your poster.
Open the actions panel.
3. Paste the following code. It’s the same as the previous tutorial except for the highlighted lines. The difference here is the way we position the elements so that the tween scale animation on each piece will start from the center of the piece.
Also we add a MOUSE_OVER event listener to each piece of the poster.view source

print?


01import com.greensock.*;

02

03const COLUMNS:uint=10;

04const ROWS:uint=10;

05

06var imagesGrid : Array = new Array();

07

08var imageLoader:Loader = new Loader();

09imageLoader.load(new URLRequest("theamerican.jpg"));

10imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

11

12function onImageLoaded(e:Event):void {

13

14 var originalBitmapData:BitmapData = e.target.content.bitmapData;

15

16 var imageWidth : Number = originalBitmapData.width / COLUMNS;

17 var imageHeight : Number = originalBitmapData.height / ROWS;

18

19 for (var i = 0; i < COLUMNS; i++) {

20

21 for (var j = 0; j < ROWS; j++) {

22

23 var imageHolder:MovieClip = new MovieClip();

24

25 var image:Bitmap = new Bitmap();

26 image.bitmapData=new BitmapData(imageWidth,imageHeight);

27 image.bitmapData.copyPixels(

28 originalBitmapData,

29 new Rectangle(i * imageWidth, j * imageHeight,imageWidth, imageHeight),

30 new Point(0,0));

31

32 imageHolder.addChild(image);

33

34 image.x = -imageWidth / 2;

35 image.y = -imageHeight / 2;

36

37 imageHolder.x= i*imageWidth + imageWidth/2;

38 imageHolder.y= j*imageHeight + imageHeight/2;

39

40 imageHolder.alpha=0;

41 imageHolder.addEventListener(MouseEvent.MOUSE_OVER, overHandler);

42

43 imagesGrid.push(imageHolder);

44 addChild(imageHolder);

45 }

46 }

47}



4. The overHandler() function gets the piece of the poster which has triggered the event and uses the Tweenlite engine to animate its alpha and scales properties. Then we prevent the piece that has been revealed from receiving mouse messages and remove its event listener.view source

print?


1function overHandler(e:MouseEvent):void {

2 var imageGrid = e.target as MovieClip;

3 imageGrid.scaleX = imageGrid.scaleY = 0;

4 TweenLite.to(imageGrid, .5, {alpha: 1,scaleX:1,scaleY:1});

5 imageGrid.mouseEnabled = false;

6 imageGrid.removeEventListener(MouseEvent.MOUSE_OVER, overHandler);

7}



5. Here’s the final code. Test your movie to see it in action.view source

print?


01import com.greensock.*;

02

03const COLUMNS:uint=10;

04const ROWS:uint=10;

05

06var imagesGrid : Array = new Array();

07

08var imageLoader:Loader = new Loader();

09imageLoader.load(new URLRequest("theamerican.jpg"));

10imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);

11

12function onImageLoaded(e:Event):void {

13

14 var originalBitmapData:BitmapData = e.target.content.bitmapData;

15

16 var imageWidth : Number = originalBitmapData.width / COLUMNS;

17 var imageHeight : Number = originalBitmapData.height / ROWS;

18

19 for (var i = 0; i < COLUMNS; i++) {

20

21 for (var j = 0; j < ROWS; j++) {

22

23 var imageHolder:MovieClip = new MovieClip();

24

25 var image:Bitmap = new Bitmap();

26 image.bitmapData=new BitmapData(imageWidth,imageHeight);

27 image.bitmapData.copyPixels(

28 originalBitmapData,

29 new Rectangle(i * imageWidth, j * imageHeight,imageWidth, imageHeight),

30 new Point(0,0));

31

32 imageHolder.addChild(image);

33

34 image.x = -imageWidth / 2;

35 image.y = -imageHeight / 2;

36

37 imageHolder.x= i*imageWidth + imageWidth/2;

38 imageHolder.y= j*imageHeight + imageHeight/2;

39

40 imageHolder.alpha=0;

41 imageHolder.addEventListener(MouseEvent.MOUSE_OVER, overHandler);

42

43 imagesGrid.push(imageHolder);

44 addChild(imageHolder);

45 }

46 }

47}

48

49function overHandler(e:MouseEvent):void {

50 var imageGrid = e.target as MovieClip;

51 imageGrid.scaleX = imageGrid.scaleY = 0;

52 TweenLite.to(imageGrid, .5, {alpha: 1,scaleX:1,scaleY:1});

53 imageGrid.mouseEnabled = false;

54 imageGrid.removeEventListener(MouseEvent.MOUSE_OVER, overHandler);

55}
]

http://eng.inbforum.com

上一页INBforum   Go down

上一页INBforumView previous topic View next topic Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum

Copyright ©2009-2016 LTD Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.

IT:SINGLESERVGoogle谷歌翻译TranslateFORUMSOFTLAYERGoogle谷歌广告联盟AdSenseAsia

 

Create a forum on Forumotion | ©phpBB | Free forum support | Report an abuse | Forumotion.com