home *** CD-ROM | disk | FTP | other *** search
/ Champak 108 / jogo-disk-108.iso / Games / jeans_bags_makeover.swf / scripts / CSnow_.as
Text File  |  2010-05-15  |  3KB  |  130 lines

  1. function CSnow()
  2. {
  3.    this.Init();
  4. }
  5. CSnow.prototype = new MovieClip();
  6. CSnow.prototype.Init = function()
  7. {
  8.    var _loc1_ = this;
  9.    if(_loc1_._width < 100)
  10.    {
  11.       _loc1_._width = 100;
  12.    }
  13.    if(_loc1_._height < 100)
  14.    {
  15.       _loc1_._height = 100;
  16.    }
  17.    _loc1_.m_nRight = _loc1_._width;
  18.    _loc1_.m_nBottom = _loc1_._height;
  19.    _loc1_.ins_Mask._width = _loc1_._width;
  20.    _loc1_.ins_Mask._height = _loc1_._height;
  21.    _loc1_._xscale = 100;
  22.    _loc1_._yscale = 100;
  23.    _loc1_.setMask(_loc1_.ins_Mask);
  24.    _loc1_.ConfirmValue();
  25.    _loc1_.CreateSnow();
  26. };
  27. CSnow.prototype.ConfirmValue = function()
  28. {
  29.    var _loc1_ = this;
  30.    if(_loc1_.m_nSnowSpeed <= 0)
  31.    {
  32.       _loc1_.m_nSnowSpeed = 5;
  33.    }
  34.    if(_loc1_.m_nSnowSpeed > 100)
  35.    {
  36.       _loc1_.m_nSnowSpeed = 100;
  37.    }
  38.    if(_loc1_.m_nLeftWind > 10)
  39.    {
  40.       _loc1_.m_nLeftWind = 10;
  41.    }
  42.    if(_loc1_.m_nRightWind > 10)
  43.    {
  44.       _loc1_.m_nRightWind = 10;
  45.    }
  46. };
  47. CSnow.prototype.CreateSnow = function()
  48. {
  49.    this.attachMovie(this.m_strSnowMovie,"Snow_Test",1);
  50.    if(this.Snow_Test == undefined)
  51.    {
  52.       this.m_strSnowMovie = "DefaultSnow";
  53.    }
  54.    this.Snow_Test.removeMovieClip();
  55.    i = 1;
  56.    while(i < this.m_nSnowMax)
  57.    {
  58.       this.attachMovie(this.m_strSnowMovie,"Snow" + i,i);
  59.       eval("this.Snow" + i)._x = -1;
  60.       eval("this.Snow" + i).onEnterFrame = this.SnowOnEnterFrame;
  61.       i++;
  62.    }
  63. };
  64. CSnow.prototype.SetSnow = function(snowMax)
  65. {
  66.    if(this.m_nSnowMax > snowMax)
  67.    {
  68.       i = snowMax;
  69.       while(i < this.m_nSnowMax)
  70.       {
  71.          eval("this.Snow" + i).removeMovieClip();
  72.          i++;
  73.       }
  74.    }
  75.    else
  76.    {
  77.       i = this.m_nSnowMax;
  78.       while(i < snowMax)
  79.       {
  80.          this.attachMovie(this.m_strSnowMovie,"Snow" + i,i);
  81.          eval("this.Snow" + i)._x = -1;
  82.          eval("this.Snow" + i).onEnterFrame = this.SnowOnEnterFrame;
  83.          i++;
  84.       }
  85.    }
  86.    this.m_nSnowMax = snowMax;
  87. };
  88. CSnow.prototype.SetSpeed = function(Speed)
  89. {
  90.    this.m_nSnowSpeed = Speed;
  91.    this.ConfirmValue();
  92. };
  93. CSnow.prototype.SetLeftWind = function(leftWind)
  94. {
  95.    this.m_nLeftWind = leftWind;
  96.    this.ConfirmValue();
  97. };
  98. CSnow.prototype.SetRightWind = function(rightWind)
  99. {
  100.    this.m_nRightWind = rightWind;
  101.    this.ConfirmValue();
  102. };
  103. CSnow.prototype.SnowOnEnterFrame = function()
  104. {
  105.    var _loc1_ = this;
  106.    if(_loc1_._x <= 0 or _loc1_._x > _loc1_._parent.m_nRight or _loc1_._y > _loc1_._parent.m_nBottom)
  107.    {
  108.       _loc1_._parent.ResetSnowEntty(_loc1_);
  109.    }
  110.    else
  111.    {
  112.       _loc1_._x += _loc1_.t_nSpeedX;
  113.       _loc1_._y += _loc1_.t_nSpeedY;
  114.    }
  115. };
  116. CSnow.prototype.ResetSnowEntty = function(obj)
  117. {
  118.    var _loc1_ = obj;
  119.    var _loc2_ = this;
  120.    var _loc3_ = random(120) - 10;
  121.    _loc1_._xscale = _loc3_;
  122.    _loc1_._yscale = _loc3_;
  123.    _loc1_._x = random(_loc2_.m_nRight) + 1;
  124.    _loc1_._y = random(_loc2_.m_nBottom) + 1;
  125.    _loc1_.t_nSpeedX = _loc2_.m_nRightWind + random(_loc2_.m_nRightWind) - (_loc2_.m_nLeftWind + random(_loc2_.m_nLeftWind));
  126.    _loc1_.t_nSpeedY = 2 + _loc2_.m_nSnowSpeed * _loc3_ * 0.01;
  127.    _loc1_.gotoAndPlay(1);
  128. };
  129. Object.registerClass("CSnow_",CSnow);
  130.