[카테고리:] Flash

  • [as] playMovie, 무비클립 제어 함수

    /*
    * playMovie
    * 무비클립 재생 및 역재생하기
    * @mc : 재생할 무비클립
    * @frame : 이동할 프레임 번호
    */
    playMovie = function(mc:MovieClip, frame:Number):Void{
            delete mc.onEnterFrame;
    
            if(frame == undefined){
                    mc.play();
            }else{
                    var ff:Number = 1;
                    var cf:Number = mc._currentframe;
                    var tf:Number = mc._totalframes;
    
                    frame = Math.max(Math.min(frame, tf), ff);
    
                    if(frame < cf){
                            mc.onEnterFrame = function(Void):Void{
                                    this.prevFrame();
                                    if(this._currentframe <= frame){
                                            delete this.onEnterFrame;
                                    }
                            }// onEnterFrame
                    }else if(frame > cf){
                            mc.onEnterFrame = function(Void):Void{
                                    this.nextFrame();
                                    if(this._currentframe >= frame){
                                            delete this.onEnterFrame;
                                    }
                            }// onEnterFrame
                    }
            }
    }// playMovie
    
    
  • [JS, AS3] 한글이 들어간 문자열 길이 구하기

    function getStringLength(str){
        return(str.length+(escape(str)+"%u").match(/%u/g).length-1);
    }
  • [AS] 문자열 바꾸기

    XML에서 CDATA를 사용하여 텍스트를 가져올 때 줄바꿈 및 기호를 원래대로 표현하기 위한 함수.

    replaceText = function(str:String):String{
            str = str.split("\r\n").join("\r");
            str = str.split(""").join("\"");
            str = str.split("'").join("'");
            str = str.split("<").join("<");
            str = str.split(">").join(">");
            str = str.split("&").join("&");
    
            return str;
    }
  • 동적으로 로드한 이미지 Allow smoothing 컨트롤 하기…

    Dcaland.com을 만들면서 사용한 메소드를 하나 올릴까 합니다. 플래시 8 버전에서는 이미지를 외부로 부터 로드를 할 경우에 default로 Allow smoothing(매끄럽게)이 false 값을 가지게 되는데 Allow smoothing이 false일 경우에는 에니메이션(좌표,로테이션등) 할때 이미지가 지글거리는 문제가 있죠. 라이브러리에 등록된 이미지는 속성에서 수동으로 채킹을 해서 사용하면 된다지만 외부에서 동적으로 불러온 이미지를 움직일 때는 문제가 있죠. 아래 메소드는 그 문제를 해결해 주는 메소드입니다. http://www.kaourantin.net/ 에 기술된 내용을 간단하게 수정해서 사용하고 있습니다.

    import flash.display.*;
    
    private function loadImg (target : MovieClip, url : String) : Void 
    { 
      var bmc : MovieClip = target.createEmptyMovieClip ("bmc", target.getNextHighestDepth ()); 
      var listener : Object = new Object (); 
      listener.tmc = target; 
      listener.onLoadInit = function (mc : MovieClip) 
      { 
        mc._visible = false; 
        var bitmap : BitmapData = new BitmapData (mc._width, mc._height, true); 
        this.tmc.attachBitmap (bitmap, this.tmc.getNextHighestDepth () , "auto", true); 
        bitmap.draw (mc); 
      }; 
      var loader : MovieClipLoader = new MovieClipLoader (); 
      loader.addListener (listener); 
      loader.loadClip (url, bmc); 
    }

    BitmapData 를 사용하기 위해서 import flash.display.*; 임포트 시켜서 사용하세요
    입맛에 맞게 수정해서 사용하세요 어떻게 보면 약간의 꼼수가 있는거 같지만 8.5 나오기 전까지는 작지만 유용한 메소드가 될듯 싶습니다.

    출처: http://blog.naver.com/usaaha/120027435534

  • 7.2. Convolution matrix

    7.2. Convolution matrix

    You can find this filter via the image menu under Filters->Generic->Convolution Matrix

    Here is a mathematician’s domain. Most of filters are using convolution matrix. With the Convolution Matrix filter, if the fancy takes you, you can build a custom filter.

    What is a convolution matrix? It’s possible to get a rough idea of it without using mathematical tools that only a few ones know. Convolution is the treatment of a matrix by another one which is called “kernel”.

    The Convolution Matrix filter uses a first matrix which is the Image to be treated. The image is a bi-dimensional collection of pixels in rectangular coordinates. The used kernel depends on the effect you want.

    http://docs.gimp.org/en/plug-in-convmatrix.html