Highlighted

one function for all moviclips

Community Beginner ,
Dec 24, 2018

Copy link to clipboard

Copied

hii plz help .. i make drag and drop game and i won't  make one function(hitsa7an) to all the elements (juse,cheesy,batter,avocado)

how i make it ??

-----------------------------------------------------------------------------------

juse.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

juse.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

 

 

cheesy.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

cheesy.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

batter.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

batter.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

avocado.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

avocado.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

 

function  startdraging(e:MouseEvent):void{

  e.currentTarget.startDrag();

  }

 

  function stopdraging (e:MouseEvent):void{

  e.currentTarget.stopDrag();

  }

addEventListener(Event.ENTER_FRAME,hitsa7an);

function hitsa7an (e:Event):void{

  if(avocado.hitTestObject(sa7an)){

  nonoM.gotoAndStop(2);

  }else {  nonoM.gotoAndStop(1);   }

  }

Views

183

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

one function for all moviclips

Community Beginner ,
Dec 24, 2018

Copy link to clipboard

Copied

hii plz help .. i make drag and drop game and i won't  make one function(hitsa7an) to all the elements (juse,cheesy,batter,avocado)

how i make it ??

-----------------------------------------------------------------------------------

juse.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

juse.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

 

 

cheesy.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

cheesy.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

batter.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

batter.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

avocado.addEventListener(MouseEvent.MOUSE_DOWN,startdraging) ;

avocado.addEventListener(MouseEvent.MOUSE_UP,stopdraging) ;

 

 

function  startdraging(e:MouseEvent):void{

  e.currentTarget.startDrag();

  }

 

  function stopdraging (e:MouseEvent):void{

  e.currentTarget.stopDrag();

  }

addEventListener(Event.ENTER_FRAME,hitsa7an);

function hitsa7an (e:Event):void{

  if(avocado.hitTestObject(sa7an)){

  nonoM.gotoAndStop(2);

  }else {  nonoM.gotoAndStop(1);   }

  }

Views

184

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 24, 2018 0
kglad LATEST
Adobe Community Professional ,
Dec 25, 2018

Copy link to clipboard

Copied

it's not clear what you're trying to do but typically when an object's dropped, you would check and then do something with the dropped object (instead of using an enterframe loop):

  function stopdraging (e:MouseEvent):void{

  e.currentTarget.stopDrag();

checkDroppedF(MovieClip(e.currentTarget));  // assuming you're using movieclips

  }

function checkDroppedF(mc:MovieClip):void{

if(mc.hitTestObject(mc.target)){

// do whatever

} else {

// do whatever else

}

}

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 25, 2018 0