'COLOR'에 해당되는 글 1건

  1. 2008/07/22 [AS] Color.prototype.setRGB2
Color.setRGB를 확장하여, 기본컬러값 대신 R,G,B 코드, 8진수, html색상코드 입력으로 셋팅할수있게 합니다.


Color.prototype.setRGB2 = function()
{
   if(arguments[1] != undefined && arguments[2] != undefined)
   {
      return this.setRGB(arguments[0]<<16|arguments[1]<<8|arguments[2]);
   } else {
      var l = arguments[0].length
      var a = arguments[0].substring(l,l - 6)
      return this.setRGB(parseInt(a,16))
   }
}


//   -------------
//   usage
//   -------------

//   example 1
c = new Color(_root);
c.setRGB2(255,0,0) // <-- RED

//   example 2
c = new Color(_root);
c.setRGB2("0xFFCC00") // <-- ORANGE

//   example 3
c = new Color(_root);
c.setRGB2("#FF3300")   // <-- RED AGAIN
Posted by 두리미
이전버튼 1 이전버튼