전공/실무

[as3.0] 백넥과 팝업

하루는노력 2012. 12. 6. 20:04
728x90
반응형

/**********서브 팝업************/
var i:Number;
var popNum:Number = 3;//팝업 갯수
var subBtnNum:Number;//버튼 갯수

var nowHandler:MovieClip;//
var backNext:Boolean;//백넥스트
var nowCurrentFrame:Number;//현재
var nowTotalFrames:Number;//전체
var clickMe:String;//
var clickMeNum:Number;//

if( nowHandler == null ){//최초만
     trace("null");
     nowHandler = this["subItemBox"];
     nowHandler.visible = false;
     for( i=0; i<popNum; i++ ){
          nowHandler["txtBox"+i].visible = false;
     }
}
function subHandler( e:MouseEvent ):void{
    
     clickMe = e.currentTarget.name.substring(6);//숫자만
     clickMeNum = parseInt(clickMe)+1;//
     nowHandler.visible = true;
     nowHandler.gotoAndStop(clickMeNum);    
    
     nowHandler.txtBox = nowHandler["txtBox"+clickMe];
     nowHandler.txtBox.visible = true;
     nowHandler.txtBox.gotoAndStop(1);
    
     nowHandler.closeBtn.buttonMode = true;
     nowHandler.closeBtn.addEventListener(MouseEvent.CLICK, closeSubHandler);
    
     initHandler();//백넥초기화
}

function closeSubHandler( e:MouseEvent ):void{//닫기
     nowHandler.txtBox.visible = false;
     nowHandler.visible = false;
}

function initHandler(){//백넥초기화
     if( backNext ){//백넥스트 사용
          frameCount();//프레임 카운트         
          if( nowTotalFrames > 1 ){//
               nowHandler.numList.visible = true;
               nowHandler.numList.txt0.text = nowCurrentFrame;
               nowHandler.numList.txt1.text = nowTotalFrames;    
              
               backNextHandler();//버튼 핸들링
          }else{
               nowHandler.numList.visible = false;
          }
     }    
}

function frameCount(){//프레임 카운트
     nowCurrentFrame = nowHandler.txtBox.currentFrame;
     nowTotalFrames = nowHandler.txtBox.totalFrames;
}

function backNextHandler(){//버튼 핸들링
     nowHandler.numList.btn0.buttonMode = true;
     nowHandler.numList.btn1.buttonMode = true;
     nowHandler.numList.btn0.addEventListener(MouseEvent.CLICK, prevHandler);
     nowHandler.numList.btn1.addEventListener(MouseEvent.CLICK, nextHandler);
     if( nowCurrentFrame == 1 ){
          nowHandler.numList.btn0.enabled = false;
          nowHandler.numList.btn0.gotoAndStop(1);
          nowHandler.numList.btn1.enabled = true;
          nowHandler.numList.btn1.gotoAndStop(2);         
     }else if( nowCurrentFrame >= nowTotalFrames ){
          nowHandler.numList.btn0.enabled = true;
          nowHandler.numList.btn0.gotoAndStop(2);
          nowHandler.numList.btn1.enabled = false;
          nowHandler.numList.btn1.gotoAndStop(1);
     }else{
          nowHandler.numList.btn0.enabled = true;
          nowHandler.numList.btn0.gotoAndStop(2);
          nowHandler.numList.btn1.enabled = true;
          nowHandler.numList.btn1.gotoAndStop(2);
     }
}

function prevHandler(e:MouseEvent):void{//이전
     nowHandler.txtBox.prevFrame();
     initHandler();
}
function nextHandler(e:MouseEvent):void{//이후
     nowHandler.txtBox.nextFrame();
     initHandler();
}
/**********서브 팝업************/
/**********구현 Layer 서브 팝업************/
subBtnNum = 1;//버튼 갯수

backNext = true;//백넥사용유무
for( i=0; i<popNum; i++ ){
     this["subBtn"+i].buttonMode = true;
     this["subBtn"+i].addEventListener(MouseEvent.CLICK, subHandler);
}
this["subItemBox"].visible = false;
/**********구현 Layer 서브 팝업************/

반응형
LIST

'전공 > 실무' 카테고리의 다른 글

[flash] 객체지향 또는 as3.0  (0) 2012.12.06
[as3.0] Timer  (0) 2012.12.06
[as2.0&3.0]volume  (0) 2012.12.06
[as2.0&3.0]controlBar  (0) 2012.12.06
[as3.0]부모, 자식 객체  (0) 2012.12.06