MLT

[xat.com] lib.as

MLT
Nov 11th, 2013
452
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var tc = 0;
  2.  
  3. function Animate(tick, points)
  4. // return interpolation
  5. // points is arrray, eg 0,30, 3,50, 6,30, 9,50, 12,30
  6. // tick, value, tick value etc
  7. {
  8.    
  9.     for(var n = 2; n<points.length; n+=2)
  10.     {
  11.         if(tick <= points[n]) // found ?
  12.         {
  13.             var r =
  14.                 (points[n+1] - points[n-1]) /
  15.                 (points[n] - points[n-2]) *
  16.                 (tick - points[n-2]) +
  17.                 points[n-1];
  18.             return r;
  19.         }
  20.     }
  21.     tc = 0; // reset tick, mark end
  22.     return points[points.length-1]; // if finished - last value
  23. }
  24.  
  25. function xInt(arg):Number
  26. // guaranteed to return a number
  27. {
  28.     var r:Number = parseInt(String(arg));
  29.  
  30.     if (isNaN(r)) return 0;// return 0 if NaN
  31.  
  32.     return r;
  33. }
  34.  
  35. function AttachMovie(mc, sym, Settings=undefined)
  36.         {
  37.                 var classRef:Class = getDefinitionByName(sym) as Class;
  38.                 var Ret = new classRef();
  39.                 if(Settings)
  40.                 {
  41.                     if(Settings['x']) Ret.x = Settings['x'];
  42.                     if(Settings['y']) Ret.y = Settings['y'];
  43.                     if(Settings['scaleX']) Ret.scaleX = Settings['scaleX'];
  44.                     if(Settings['scaleY']) Ret.scaleY = Settings['scaleY'];
  45.                     if(Settings['width']) Ret.width = Settings['width'];
  46.                     if(Settings['height']) Ret.height = Settings['height'];
  47.                 }
  48.                 mc.addChild(Ret);          
  49.                 return Ret;
  50.         }
Advertisement