2012-01-17 5 views
0

이 사실을 알고 있어야한다고 생각합니다. 음 ... 어떤 도움을 바랍니다. 그래서 이미지 슬라이더 Class를 만들고 마스크의 위치까지 잘 작동합니다. My Home Class에서 이미지 슬라이더 Class의 인스턴스를 만들고 그에 맞게 배치합니다. 슬라이더 Class의 이미지는 0, 0의 위치와 마스크에 사용하는 모양입니다. 다음은 마스크 배치가 stage.x = 0, stage.y = 0이 아니라 슬라이더의 클래스 x : 0, x : 0입니다. 슬라이더 인스턴스가 올바른 위치에 있지만 인스턴스의 마스크가 보이지 않는 이유는 무엇입니까? 어떤 도움Adobe Flash AS3 마스크 배치

주셔서 감사합니다이 내 홈페이지 클래스

private function buildSlider() : void { 
    slider = new Slider(arrSilde); 
    slider.x = btnWidth + 15; 
    addChild(slider); 
    } 

에 그리고 이것은 슬라이더 클래스

private var t : Timer; 
    private var counter : int; 

    private var slideArr : Array; 
    private var currentSlide : HomeSliderPageObj; 
    private var oldSlide : HomeSliderPageObj; 

    private var masker : Shape; 


    public function Slider(_arr : Array) { 
    super(); 
    slideArr = _arr; 

    currentSlide = _arr[counter]; 
    buldSlider(); 

    addChild(currentSlide.image); 

    t = new Timer(2000); 
    t.addEventListener(TimerEvent.TIMER, changeSlide); 
    t.start(); 
    } 


    private function buldSlider() : void { 
    masker = new Shape; 
    masker.graphics.lineStyle(); 
    masker.graphics.beginFill(0x000000, 1); 
    masker.graphics.drawRect(0,0, currentSlide.image.width, currentSlide.image.height); 
    masker.graphics.endFill(); 
    masker.x = currentSlide.image.x; 
    masker.y = currentSlide.image.y; 
    this.mask = masker; 
    } 


    private function changeSlide (event : TimerEvent) : void { 
    if (counter >= slideArr.length){ counter = 0; } 
    else { ++counter; } 

    oldSlide = currentSlide as HomeSliderPageObj; 
    addChild(oldSlide.image); 

    removeChild(currentSlide.image); 
    currentSlide = slideArr[counter]; 
    currentSlide.image.x = currentSlide.image.width; 
    addChild(currentSlide.image); 

    TweenMax.to(oldSlide.image, .5, {x:oldSlide.image.width*(-1), onComplete:clean}); 
    TweenMax.to(currentSlide.image, .5, {x:0}); 
    } 


    private function clean() : void { 
    removeChild(oldSlide.image); 
    oldSlide = null; 
    } 
+0

여기서 마커 개체를 addChild()합니까? 나는 당신의 코드 어디서나 그것을 볼 수 없다. 그리고 : 당신은 masker.x와 masker.y를 추적하려 했습니까? –

+0

정말 고맙습니다. –

답변

0

이 작동하는지 확인합니다.

currentSlide = _arr[counter]; 
    buldSlider(); //this creates the mask shape 

    addChild(currentSlide); //this add the image movieclip 
    currentSlide.mask = masker; //this sets the masking 

private function buldSlider() : void { 
    masker = new Shape; 
    masker.graphics.lineStyle(); 
    masker.graphics.beginFill(0x000000, 1); 
    masker.graphics.drawRect(0,0, currentSlide.image.width, currentSlide.image.height); 
    masker.graphics.endFill(); 
    masker.x = currentSlide.image.x; 
    masker.y = currentSlide.image.y; 
    addChild(masker); 
    } 
+0

표시 목록에 마스킹을 추가하는 것을 잊어 버렸습니다. 감사합니다. –