AS2.0 wonderful bitmap effects of the waves

Related Tags:

  Elliptic parameter equation, animation programming is a very popular technology, can make a lot of practical effects, such as the effect of waves the banner, in this case with the movement of the mouse, as a banner bitmap wind waves. 



WIDTH="400" HEIGHT="300" PLAY="true" LOOP="false" MENU="true" QUALITY="high"


AllowScriptAccess="never" TYPE="application/x-shockwave-flash"


PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">

  Below we learn how to use this technology. 

  1.    On the relevant parameters 

  First produced this example to understand ellipse parameters of the equation used to his below for a simple algorithm analysis. 

  1.    Single mc (video clip) in the oval on the campaign approach 


  Figure 1 

  Mc said a black spots, radian said that the arc in mathematics from the x is Semiaxle, beginning with the anti-clockwise rotation of 2 π week, and through the arc of the ellipse parameters mc equation to calculate the coordinates, as shown in Figure 1, that specific Methods (Note: the * code by): mc._x = a * Math.cos (radian); 
  Mc._y = b * Math.sin (radian); 

  A, b are oval in the x, y coordinate axis containing distance, representatives oval the size of the increase can be realized radian mc coordinates changes in the oval on the mc campaign.    Elliptic the center coordinates (0,0).    Translation oval to the mc coordinates with the center coordinates (cen_x, cen_y), said that specific methods: 

  Mc._x = a * Math.cos (radian) cen_x; 
  Mc._y = b * Math.sin (radian) cen_y; 

  2, mc distributed in a number of ways of handling on the Ellipse 


  Figure 2 

  If it is more than in the Oval mc distribution, the situation would be different, as shown in Figure 2.    In a uniform distribution on the oval for example, a circle of p = 2 π, and there is num = 4 mc, mc arc as shown below: 

  Mc mc1 mc2 mc3 mc4 value of π radians / 2 π-π 3 / 0 or 2 π calculation of P / 4 P * 1 / 4 * 2 P / 4 * 3 P / 4 * 4 

  From the second line forms can be seen, the Spacing is 4 mc p / 4 = π / 2.    The third line is that these curvature is calculated as follows: on the pitch by a numerical value.    Replaced by num 4, instead of using a numerical variable j can be calculated num-mc value of the arc, and then the coordinates obtained mc.    As follows: 

  For (var j = 1; j <= num; j) ( 
  Var radian = p / j * num; / / The distance between the two mc boarded j arc that each mc 
  This [ "mc" j]. _x = A * Math.sin (radian); 
  This [ "mc" j]. _y = B * Math.cos (radian); / / through the arc of the coordinates of each mc 
  ) 

  If distributed in the half ellipse, or a certain pitch in the oval part of the distribution, as long as the two mc change the spacing arc. 

  3, mc attribute configuration 

  In order to comply with the law perspective, it is necessary to set up mc attributes: transparency and depth of Figure 2 mc1 the transparency of the smallest mc2 and mc4 followed mc3 most of the other attributes of the same changes in the law and transparency.    These are along the elliptical motion mc, mc So according to the real-time location to set mc attributes.    The simplest way is to use mc y coordinate it with the changes of the above characteristics.    Mc can also use the x coordinates, and the arc mc, mc from the center of the oval, however, must be converted.    Below x coordinate to mc example: 


  Figure 3, 4 

  Figure 3, cosine function calculated by the x coordinate of a positive there is a negative, and the transparency of mc impossible for the negative, so when x is negative, it is necessary to convert, or from anti-from absolute.    When mc located at the Bottom of the x-axis (π-2π), now know from Figure 4 y <0, x coordinates than a large, x = 2 * a-Math.abs (x).    List of before and after conversion are as follows: 
  Mc arc 0 - π / 2 π/2-π π-3π / 2 3 π/2-0 x coordinates a-0 0 - a-a-0 0-a Math.abs (x) a-0 0 -- a a-0 0-a-2 * a Math.abs (x) a-0 0-a a-2a 2a-a 

  X coordinate of this 0-2 in a constant cycle between conversion of the following: 
  X = (y <0)? 2 * a-Math.abs (x): Math.abs (x); 

  4.    Production category 

  Algorithm clearly and bring it into categories for later use.    Categories are as follows: 

  (Class Move 
  Private var p = 2 * Math.PI; / / 2 π in Mathematics 
  Private var c_x, c_y, c_a, c_b, nu, time: Number; 
  / / Followed by center coordinates (c_x, c_y) 
  Intercept (c_a, c_b), nu mc for the number of incremental time for Radian 
  Private var obj: MovieClip; / / constructor function 
  Public function Move (x, y, a, b, n, t: Number, o: MovieClip) ( 
  C_x = x; 
  C_y = y; 
  C_a = a; 
  C_b = b; 
  Nu = n; 
  Time = t; 
  Duplicate (o) / / Call reproduction function 
  ) 
  / / Set up by Radian and the initial increment 
  Public function get timer (): Number ( 
  Return time; 
  ) 
  Public function set timer (t: Number): Void ( 
  Time = t; 
  ) 
  / / Set up and be the center of elliptic coordinates x 
  Public function get cen_x (): Number ( 
  Return c_x; 
  ) 
  Public function set cen_x (x: Number): Void ( 
  C_x = x; 
  ) 
  / / Set up by elliptical and y coordinates of the center of 
  Public function get cen_y (): Number ( 
  Return c_y; 
  ) 
  Public function set cen_y (y: Number): Void ( 
  C_y = y; 
  ) 
  / / Get and set oval in the x axis intercept 
  Public function get cen_a (): Number ( 
  Return c_a; 
  ) 
  Public function set cen_a (a: Number): Void ( 
  C_a = a; 
  ) 
  / / Get and set oval in the y axis intercept 
  Public function get cen_b (): Number ( 
  Return c_b; 
  ) 
  Public function set cen_b (b: Number): Void ( 
  C_b = b; 
  ) 
  / / Get on the oval and set the number of mc 
  Public function get num (): Number ( 
  Return nu; 
  ) 
  Public function set num (n: Number): Void ( 
  Nu = n; 
  ) 
  / / Set up the x coordinate mc 
  Public function set_x (radian: Number): Number ( 
  Return Math.cos (radian) * c_a c_x; 
  ) 
  / / Y coordinate settings mc 
  Public function set_y (radian: Number): Number ( 
  Return Math.sin (radian) * c_b c_y; 
  ) 
  / / Copy, a num-mc, and uniform distribution 
  Public function duplicate (obj: MovieClip) ( 
  Var j: Number = 1 while (j <= num) ( 
  Obj.duplicateMovieClip ( "a" j, j); 
  _root [ "A" j]. N = p / j * num; 
  / / Mc each of the initial curvature 
  _root [ "A" j]. GotoAndStop (j) / / mc Skip to the corresponding frame 
  _root [ "A" j]. _x = Set_x (p / j * num); 
  _root [ "A" j]. _y = Set_y (p / num * j) / / calculate coordinates 
  J; 
  ) 
  ) 
  / / Mc campaign 
  Public function myMove (obj: MovieClip): Void ( 
  Obj._x = set_x (obj.n time); 
  Obj._y = set_y (obj.n time); / / mc each Radian Radian initial value equivalent to incremental increases 
  _xmouse Time time => c_x? Time 0.005: time-0.005; 
  / / Mouse Position determined in accordance with the direction of rotation, rotation speed of 0.005 
  ) 
  / / Coordinate conversion 
  Public function trans_x (obj: MovieClip): Number ( 
  Var x: Number = obj._x-c_x; 
  Var y: Number = obj._y-c_y; 
  / / Obtain the coordinates of mc 
  X = (y <0)? 2 * c_a-Math.abs (x): Math.abs (x) / / conversion 
  Return x; / / conversion value 
  ) 
  / / Set the transparency and depth mc 
  Public function set_alpha (obj: MovieClip): Void ( 
  Obj._alpha = trans_x (obj) / c_a * 40 20; / / 20-100 
  Obj.swapDepths (trans_x (obj ));// depth settings 
  ) 
  / / Mc set the direction of the x zoom 
  Public function set_xscale (obj: MovieClip): Void ( 
  Obj._xscale = trans_x (obj) / c_a * 100-100; / / -100 to 100 
  Obj.swapDepths (trans_x (obj)); 
  ) 
  ) 

  Move.as for preservation, should be emphasized that the type in the phrase: 
  _root [ "A" j]. GotoAndStop (j); 
  It is used for bitmap cut. 

  2.    Examples production methods 

  1, animation production Cover 

  A new film editing, film editing in the first tier of the establishment of the red rectangle and the second placed bitmap, a registered plans reign at the centre point.    In section and a rectangular bitmap Left alignment, in the last one, rectangular bitmap and the far right alignment, the first layer to create animation, and as a mask.    Figure 5 below.    Making good film clips of the scenes drag, called myMc examples. 

  2, the preparation process 

  New floor in the first frame, type: 

  Var myMove: Move = new Move (200, 150, 10, 2, 40, 3, myMc); 
  / / Examples myMove built, the center coordinates (200,150), 
  / / Intercept 10 and the number of 2,40 for mc, mc 3 for the initial increment 

  In myMc add: 
  OnClipEvent (mouseMove) ( 
  _parent.myMove.myMove (This); / / mc campaign 
  _parent.myMove.set_alpha (This); / / mc transparency 
  ) 

  And saving the file to the same directory Move.as test.    We can modify examples of the various parameters, and deepen the understanding of the process. 

  Other such applications: 3-D menus, text surround, bitmap effects of the cylinder-shaped oval, and other relevant courseware.    We can stretch of the imagination to add some of the properties and methods, to produce more results. 

  Enjoy: 



WIDTH="400" HEIGHT="300" PLAY="true" LOOP="false" MENU="true" QUALITY="high"


AllowScriptAccess="never" TYPE="application/x-shockwave-flash"


PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">

WIDTH="400" HEIGHT="300" PLAY="true" LOOP="false" MENU="true" QUALITY="high"


AllowScriptAccess="never" TYPE="application/x-shockwave-flash"


PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">

  ZJS35 site: http://zjs35.edujh.cn 
  Source File Download 






Related articles:

"Novices" series produced analytical process
  Recently, the Shenzhen digital era Limited launched FLASH series of animated shorts - "novices" in the Flash empire crawling Da Bang Bang had become a popular works, this humorous cartoon series has received favorable comments, for the major film production personnel Flash Taotao a...
Xu Jun / web2.0
  Abstract: A program like cook, the same stress for sale.    Spring Festival Party increasingly worse, because it is deviated from their own television programmes to justice, the only basket case.    Any programs need constant innovation, innovation, I hope to have the con...
HTML4.0 and XHTML1.0 genuine What are the differences?
  Documentation must be good scheduling    XHTML XML is an application, some of the SGML-based HTML 4 perfectly legitimate in XHTML habits must change.    Good layout of the Well-formedness [XML] introduced a new concept.    In essence, this means that there must...
Produced by the removal of flash Enter the txt file tools
  I see phone support txt e-books, novels often do, but in the text of the round at the cell phone was not wasted screen.    So do a small version of the removal tool at the round, Hei hei, and this Shuang more.    Method of Use: open this gadget, the browser will automati...
Common DIV + CSS page layout production of technical skills
  CSS layout commonly used method: float: none | left | right    Value:    None:  default values.    Object does not float    Left:  text flows to the right targets    Right:  text flows to the left of target    It is how to wo...