무비클립을 부모객체의 센터 정렬 합니다.
_mc.centerClip();

MovieClip.prototype.centerClip = function (){
   this._y = this._parent._height / 2 - (this._height / 2);
   this._x = this._parent._width / 2 - (this._width / 2);
};
Posted by 두리미
duplicate나 attach된 무비클립의 하위속성을 포함한 대상을 삭제해줍니다.
사용법은..
_mc.killAll();


MovieClip.prototype.killAll = function ()
{
    for (var a in this)
   {
      if(typeof(this[a]) == 'movieclip')
      {
         this[a].killAll();
           removeMovieClip(this[a]);
      }
      delete(this[a]);
    }
}

'My Job > Flash/Flex' 카테고리의 다른 글

[AS] String.prototype.stripTag  (0) 2008/07/22
[AS] MovieClip.prototype.centerClip  (0) 2008/07/22
[AS] MovieClip.prototype.killAll  (0) 2008/07/22
[AS] MovieClip.prototype.shakeIt  (0) 2008/07/22
[AS] MovieClip.prototype.setTooltip  (0) 2008/07/22
[AS] Color.prototype.setRGB2  (0) 2008/07/22
Posted by 두리미


무비클립을 흔들리게 합니다. 흔들리는 범위나 각도는 수치로 조정할 수 있습니다.



MovieClip.prototype.shakeIt = function(){
   // **
   // **********   INITIALIZING & STORING CLIP PARAMETERS **********

   // INI Rectangle Size X, Y
   this.recScale = 1;      // ENCREASING SIZINGS OF RECTANGLE BORDER
   this.shakeRotation = 5; // ENCREASING ROTATION
   this.shakeScale = 2;    // ENCREASING SHAKER XPOS & YPOS
   this.shakeAlpha = 1;    // ENCREASING APHA PROPERTY
  
   // Storing of needed MC Properties
   this.storedName = this._name;
   this.storedXpos = this._x;
   this.storedYpos = this._y;
   this.storedRotation = this._rotation;
   this.storedAlpha = this._alpha;
   this.rectangle = [this.storedXpos-this.recScale,this.storedXpos+this.recScale,this.storedYpos-this.recScale,this.storedYpos+this.recScale,this.storedRotation-this.shakeRotation,this.storedRotation+this.shakeRotation];
   // E O Storing of needed MC Properties
                                    // TEST FUNCTION
                                    store = function (storedYpos){
                                       trace(storedYpos)
                                    }
                                    //store(this.rectangle[0])
                                    // E O TEST FUNCTION
  
   // **********   E O INITIALIZING & STORING CLIP PARAMETERS **********
  
   // **
   // **********   @ goAndShake (SHAKE FUNCTION)   **********
   goAndShake = function (){
      // CALCULATE AVERAGE OF NEW MC PROPERTIES
      averageX = this._x-random(this.shakeScale)+ (+random(this.shakeScale));
      averageY = this._y-random(this.shakeScale)+ (+random(this.shakeScale));
      averageRotation = this._rotation-random(this.shakeScale)+ (+random(this.shakeScale));
      this._alpha = 100 - random(this.shakeAlpha);
      // E O CALCULATE AVERAGE OF NEW MC PROPERTIES
     
      // CONDITION --> IS MC BORDER CLIPPING ?
      if(this._x < this.rectangle[0] || this._x > this.rectangle[1] ){
         this._x = this.storedXpos;
      }else{
         this._x =  averageX;
      }
      if(this._y < this.rectangle[2] || this._y > this.rectangle[3]){
         this._y = this.storedYpos;
      }else{
         this._y = averageY;
      }
      if(this._rotation < this.rectangle[4] || this._rotation > this.rectangle[5]){
         this._rotation = this.storedRotation;
      }else{
         this._rotation = averageRotation;
      }
   }
   // **
   // **********   E O goAndShake (SHAKE FUNCTION)   **********
   this.onEnterFrame = goAndShake;
}

MovieClip.prototype.shakeStop = function (){
   this.onEnterFrame = null;
   this._name = this.storedName ;
   this._x = this.storedXpos;
   this._y = this.storedYpos;
   this._rotation = this.storedRotation;
   this._alpha = this.storedAlpha;
}

// 사용법

_mc.onRollOver = function(){
 this.shakeIt();
}
_mc.onRollOut = function(){
 this.shakeStop();
}


'My Job > Flash/Flex' 카테고리의 다른 글

[AS] MovieClip.prototype.centerClip  (0) 2008/07/22
[AS] MovieClip.prototype.killAll  (0) 2008/07/22
[AS] MovieClip.prototype.shakeIt  (0) 2008/07/22
[AS] MovieClip.prototype.setTooltip  (0) 2008/07/22
[AS] Color.prototype.setRGB2  (0) 2008/07/22
[AS] Array.prototype.randomOrder  (0) 2008/07/22
Posted by 두리미
무비클립에 툴팁을 셋팅합니다.



MovieClip.prototype.setTooltip = function(theText, timer, text_color, bg_color, border_color)
{
   if (timer == undefined)
   {
      timer = 500;
   }
   var addMsg = function (theMsg, col, bg_color, border_color, level)
   {
      var x = _root._xmouse
      var y = _root._ymouse     
      var f = new TextFormat();
      f.font = "Verdana";
      f.size = 11;
      f.color = col != undefined ? col : 0x000000;
      _level0.createTextField('tooltip', 123456, x, y, 150, 20);
      with (_level0.tooltip)
      {
         setNewTextFormat(f);
         text = theMsg;
         selectable = false;
         autoSize = true;
         background = true;
         border = true;
         borderColor = border_color != undefined ? border_color : 0x000000;
         backgroundColor = bg_color != undefined ? bg_color : 0xFFFFEE;
         _y -= _height;
      }
      clearInterval(level.q_t);
   };
   this.q_t = setInterval(addMsg, timer, theText, text_color, bg_color, border_color, this);
};
//   --------------------
//   unset the tooltip
//   --------------------
MovieClip.prototype.unsetTooltip = function()
{
   _level0.tooltip.removeTextField();
   clearInterval(this.q_t);
};


//
 
사용법..

_mc.onRollOver = function(){
 this.setTooltip("무비클립에 간단하게 툴팁을 추가합니다.", 500, 0x000000, 0xFFFFEE, 0x000000);
}
_mc.onRollOut = function(){
 this.unsetTooltip();
}

Posted by 두리미
이전버튼 1 이전버튼