Posted
Filed under Action Script

[Flash] /attachment/1097207770.swf



stop();
//환경 설저
var line_count:Number =3 ; //선 개수 총 3일 경우 점 6개 성성됨 aa0 ~ aa5;
var id:Number=0;
var temp:MovieClip=null;
var lineptr:MovieClip=null;


for(var i:Number=0; i<line_count; i++){
 this["aa"+ i].loc=-1;
 
 this["aa"+ i].onRelease=function(){
  create_line_object(this);
 }
 //group 설정
 this["aa"+ i].ngroup=i;
 
 //대상 group 설정
 this["aa"+ ((line_count)+i)].loc=-1;
 this["aa"+ ((line_count)+i)].ngroup = i;
 this["aa"+ ((line_count)+i)].onRelease=function(){
  line_to_line(this);
 }
}

function line_to_line(mc:MovieClip){
 if(temp.Status=="on" &&  temp.ngroup == mc.ngroup){
  trace("동일그룹");
  //이벤트 처리
 
 }else{
  trace("서로다른그룹");
  //이벤트 처리
 
 // remove_object(temp);
 // remove_ojbect(lineptr);
 }
 
 if(mc.loc==-1 &&  temp.Status=="on" &&  temp.ngroup == mc.ngroup ){
   
   this["aa"+temp.anum].loc = mc._name.substr(2,3);
   
   mc.loc = this["aa"+temp.anum]._name.substr(2,3);
   
   Mouse.show();
   lineptr=null;
   temp.onMouseMove=null;
   temp.null;
   temp.Status="off";
  }//inner if end
 
  if(is_line_draw_complate()==true){
   if(_check()==true){
    trace("complate");
    mx.behaviors.DepthControl.bringToFront(answer_0);
    answer_0.gotoAndPlay(2);
   }else{
    trace("try_again");
    mx.behaviors.DepthControl.bringToFront(answer_x);
    answer_x.gotoAndPlay(2);
   }
 
   //이벤트 풀어버리기
   for(var i:Number=0; i<line_count; i++){
    this["aa"+ i].onRelease=this["aa"+ ((line_count)+i)].onRelease=false;
   }
  }//inner if end
 }


function create_line_object(mc:MovieClip){
 if(temp.Status=="on"){
 
 }else{
  if(mc.loc==-1){
   duplicate_object(mc);
  }
 }
}


function remove_object(mc:MovieClip){
 trace("객체 삭제:"+mc);
 mc.onMouseMove=null;
 removeMovieClip(mc._name);
 Mouse.show();
}


function duplicate_object(mc:MovieClip){
 temp = mc.duplicateMovieClip("mc"+id,++id);
 temp.ngroup = mc.ngroup;
 temp.Status = "on";
 temp.anum = Number(mc._name.substr(2,3));
 Mouse.hide();
 
 temp.onMouseMove = function() {
  this._x = this._parent._xmouse;
  this._y = this._parent._ymouse;
 // lineptr.moveTo(_xmouse - Number(lineptr._x) ,_ymouse-Number(lineptr._y)); //y좌표
  lineptr.clear();
  lineptr=null;
  crate_line();
  lineptr.lineTo(_xmouse - Number(lineptr._x) ,_ymouse-Number(lineptr._y)); //x좌표;
  lineptr.moveTo(0,0);
 };
}


//라인생성
function crate_line(){
 trace("temp:"+temp.anum);
 this.Mouse.show();
 lineptr=this.createEmptyMovieClip("line_mc", ++id);
 lineptr.lineStyle(5, 0xff00ff, 50, true, "normal", "square", "miter", 1);
 lineptr._currentx = lineptr._x=this["aa"+temp.anum]._x;
 lineptr._currenty =lineptr._y=this["aa"+temp.anum]._y;
}


//정답 체크

function _check():Boolean{
 var retval:Boolean=false;
 for(var i:Number=0; i<line_count; i++){
  trace("target_group:" + this["aa"+this["aa"+i].loc].ngroup );
  if(this["aa"+this["aa"+i].loc].ngroup == this["aa"+i].ngroup){
   retval = true;
  }else{
   retval = false;
   break;
  }
 }
 return retval;
}

function is_line_draw_complate():Boolean{
 var retval:Boolean=false;
 for(var i:Number=0; i<line_count; i++){
  if(this["aa"+i].loc!=-1){
   retval = true;
  }else{
   retval = false;
   break;
  }
 }
 return retval;
}

2009/10/01 11:34 2009/10/01 11:34