Flash CS3: Reflex create an effect on any MovieClip

Wednesday, June 4, 2008

Exploiting a significant feature of Actionscript 3.0 (see Actionscript 3.0: everything with the new operator) I created a class ReflexMe able to generate a "reflection" on any MovieClip in this library.

Loading Flash Player ...

The source is part of the package undolibrary - GoogleCode on this - but if you want you can download the single file ReflexMe.as.

Continue reading ... "

Related Post

Effects on Bitmap with perlinNoise ()

Monday, June 2, 2008

The class BitmapData allows you to easily apply effects useful for many purposes. We have seen how to create a "fog tv" with a few lines of code (Flash CS3: creating fog effect TV in 1 second). Now we design a more effective "spectacular" which, as we shall see later, can achieve interesting effects of graphs, as shown in below: varying the parameters to observe the different effects, clicking with the mouse on the generated this can be moved.

Loading Flash Player ...

On this occasion I also added a new component simple (Check) in Undolibrary! Then update your SVN repository. The source is available here: MapEffect.zip

Continue reading ... "

Related Post

Saving images in Flash CS3

Monday, March 31, 2008

With Flash CS3 using Bitmap is so improved that you just want to create a small Paint. We have already seen how a small Paint (see Create a Paint in Flash CS3 Painter: simple application for drawing in Flash CS3 Pro) capable of supporting a "cancel" - erase function, thanks to a particular use of layer Shape and Bitmap We say now that Flash (unlike Flex) does not allow them encoding (type JPG or PNG) will automatically save images Bitmap. But you can work around the obstacle using a server-side scripting and the ability to send data to Flash in POST. Continue reading ... "

Related Post

Flash CS3: creating fog effect TV in 1 second

Thursday, March 27, 2008

Flash CS3 is not the end of surprise. Here's how to create the classic fog effect of television in a second with 10 lines of code.

Loading Flash Player ...

Actionscript:
  1. . Bitmap ; import flash. display. Bitmap;
  2. . BitmapData ; import flash. display. BitmapData;
  3. / /
  4. BitmapData ( 320 , 256 ) ; var bmpd: BitmapData = new BitmapData (320, 256);
  5. Bitmap ( bmpd ) ; var bmp: = new Bitmap Bitmap (bmpd);
  6. / /
  7. ; addChild (bmp);
  8. / /
  9. Event. ENTER_FRAME , bmp. addEventListener (Event. ENTER_FRAME,
  10. e :Event ) : void { function (e: Event): void (
  11. Math . random ( ) * 1000 , 0 , 200 , 7 , true ) ; bmpd. noise (Math. random () * 1000, 0, 200, 7, true);
  12. )
  13. );

Related Post

Painting Flash CS3: real time erase tool

Monday 11 February, 2008

Starting the codes provided in Create a Paint in Flash CS3, and implementing small changes, we can significantly improve the tool to "erase". Adding a Shape not visible, you can use it as a "plan" to run the draw() merger mode "erase". As shown in the example below, having designed something, hold down the Ctrl key and the effect of "cancellation" is now in real time.

Loading Flash Player ...

The code is as follows - source:

Actionscript:
  1. . MouseEvent ; import flash. events. MouseEvent;
  2. . BitmapData ; import flash. display. BitmapData;
  3. . Bitmap ; import flash. display. Bitmap;
  4. . GradientType ; import flash. display. GradientType;
  5. / /
  6. . Matrix ; import flash. Geom. Matrix;
  7. / /
  8. = false ; var md: Boolean = false;
  9. / /
  10. Sprite ( ) ; var event_spr: Sprite = new Sprite ();
  11. ; addChild (event_spr);
  12. / /
  13. = event_spr. stage . stageWidth ; var area_width: Number = event_spr. stage. stageWidth;
  14. = event_spr. stage . stageHeight - 32 ; var area_height: Number = event_spr. stage. stageHeight - 32;
  15. / /
  16. = GradientType. LINEAR ; var fillType: String = GradientType. LINEAR;
  17. = [ 0xFF0000, 0x00FF00, 0x0000ff ] ; var colors: Array = [0xFF0000, 0x00FF00, 0x0000ff];
  18. = [ 1 , 1 , 1 ] ; var alphas: Array = [1, 1, 1];
  19. = [ 0 , 128 , 255 ] ; var ratios: Array = [0, 128, 255];
  20. = SpreadMethod. PAD ; var spreadMethod: String = SpreadMethod. PAD;
  21. Matrix ( ) ; var matrix: Matrix = new Matrix ();
  22. area_width, area_height, 1 , 0 , 0 ) ; matrix. createGradientBox (area_width, area_height, 1, 0, 0);
  23. / /
  24. event_spr. graphics ) { with (event_spr. graphics) (
  25. fillType,colors,alphas,ratios,matrix,spreadMethod ) ; beginGradientFill (fillType, colors, alphas, ratios, matrix, spreadMethod);
  26. , 0 ,area_width, area_height ) ; drawRect (0, 0, area_width, area_height);
  27. ; endFill ();
  28. )
  29. / / Paint event
  30. MouseEvent. MOUSE_DOWN , _onMouseDown ) ; event_spr. addEventListener (MouseEvent. MOUSE_DOWN, _onMouseDown);
  31. MouseEvent. MOUSE_MOVE , _onMouseMove ) ; event_spr. addEventListener (MouseEvent. MOUSE_MOVE, _onMouseMove);
  32. MouseEvent. MOUSE_UP , _onMouseUp ) ; event_spr. addEventListener (MouseEvent. MOUSE_UP, _onMouseUp);
  33. MouseEvent. MOUSE_OUT , _onMouseUp ) ; event_spr. addEventListener (MouseEvent. MOUSE_OUT, _onMouseUp);
  34. / /
  35. BitmapData ( event_spr. width ,event_spr. height , true , 0 ) ; var bmpd: BitmapData = new BitmapData (event_spr. width, event_spr. height, true, 0);
  36. Bitmap ( bmpd ) ; var bmp: = new Bitmap Bitmap (bmpd);
  37. ; addChild (bmp);
  38. / /
  39. / / Temporary shape
  40. Shape ( ) ; var draw_shape: Shape = new Shape ();
  41. ; addChild (draw_shape);
  42. / /
  43. / / Shape, not visible, used for the "abolition"
  44. Shape ( ) ; var erase_shape: Shape = new Shape ();
  45. / /
  46. e :MouseEvent ) : void { _onMouseDown function (e: MouseEvent): void (
  47. ) ; debug ( "_onMouseDown");
  48. ( 10 , 0xffffff, 1 ) ; draw_shape. graphics. LineStyle (10, 0xffffff, 1);
  49. ( 20 , 0xffffff, 1 ) ; erase_shape. graphics. LineStyle (20, 0xffffff, 1);
  50. ( e . localX , e . localY ) ; draw_shape. graphics. moveTo (e. localX, and. localY);
  51. ( e . localX , e . localY ) ; erase_shape. graphics. moveTo (e. localX, and. localY);
  52. md = true;
  53. )
  54. / /
  55. e :MouseEvent ) : void { _onMouseUp function (e: MouseEvent): void (
  56. md = false;
  57. ( draw_shape ) ; bmp. BitmapData. draw (draw_shape);
  58. ( ) ; draw_shape. graphics. clear ();
  59. ( ) ; erase_shape. graphics. clear ();
  60. )
  61. / /
  62. e :MouseEvent ) : void { _onMouseMove function (e: MouseEvent): void (
  63. ) ; debug ( "_onMouseMove");
  64. md && ! e . ctrlKey ) { if (md & &! and. ctrlKey) (
  65. ( e . localX , e . localY ) ; draw_shape. graphics. lineTo (e. localX, and. localY);
  66. ( md && e . ctrlKey ) { ) Else if (e & & md. CtrlKey) (
  67. ( e . localX , e . localY ) ; erase_shape. graphics. lineTo (e. localX, and. localY);
  68. ( erase_shape, null , null , "erase" ) ; bmp. BitmapData. draw (erase_shape, null, null, "erase");
  69. )
  70. )
  71. / /
  72. v: String ) : void { debug function (v: String): void (
  73. = new Date ( ) ; var d: Date = new Date ();
  74. d. getMinutes ( ) + ":" +d. getSeconds ( ) + ":" +d. getMilliseconds ( ) + ": " +v ) ; trace (d. getMinutes () + ":" + d. getSeconds () + ":" + d. getMilliseconds () + ":" + v);
  75. )

We have added a new Shape, erase_shape not visible (it was not carried out any addChild()

Actionscript:
  1. ...
  2. / / Shape, not visible, used for the "abolition"
  3. Shape ( ) ; var erase_shape: Shape = new Shape ();

The piece of code that attempts to draw was introduced for the control key and, when pressed, is precisely the question Shape erase_shape and copied on Bitmap:

Actionscript:
  1. ....
  2. . lineTo ( e . localX , e . localY ) ; erase_shape. graphics. lineTo (e. localX, and. localY);
  3. ( erase_shape, null , null , "erase" ) ; bmp. BitmapData. draw (erase_shape, null, null, "erase");

Related Post

Create a Paint in Flash CS3

Sunday 10 February, 2008

As explained in Flash Actionscript contest: erase tool is not possible to "erase" a particular area Sprite one, or Shape MovieClip which have been drawn lines or rectangles using the pointer graphics. There is, in fact, the only method clear() which, however, take effect on the area of our subject. The solution to the problem lies in the possibility of using objects Bitmap and BitmapData. We'll see how we can directly access and manipulate data Bitmap in order to "erase" the traits with a real instrument "cancel".

Will present two different methods for achieving the "delete". The first "painting" (clear) data directly into BitmapData, using the method fillRect() can also be used setPixel() example. The second method, the one I prefer, uses the methods of mergers (blendMode).

First of all we see what kind of organization is minimally necessary to achieve a simple Painter in Flash. The outline presented below applies to both proposals of the "delete":

schema-bitmap

I created three layers: the first, MovieClip or Sprite, and works as a background event handler (MouseDown, MouseMove and MouseUp). The second, Bitmap, is our main layer, which actually contain graphics designed and which will also feature "cancel". The third and final layer, the Shape, solves two issues: first, which allows you to directly use the functions available from the graphics pointer (as lineStyle drawRect() etc. ...). Also increases the performance during the tracking chart, as explained in detail below. Continue reading ... "

Related Post