• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

one function for all moviclips

Explorer ,
Dec 24, 2018 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

297

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
community guidelines
Community Expert ,
Dec 25, 2018 Dec 25, 2018

Copy link to clipboard

Copied

LATEST

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

}

}

Votes

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
community guidelines