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

as3 collision with multiple movieclips with same instance name

Participant ,
Feb 12, 2023 Feb 12, 2023

I have to instances of the same movieclip with the same instance name but it only works for one. I don't want that. I've looked up many ways to do this but I'm a sort of begginer coder so I don't really get what it means or how to implement it into my code. I don't get how "for loops" and stuff work but I know it involves looping through all the instances but I just don't get it. Please explain a simple way to do this and why. Here's the code:

 

"

star.gotoAndStop("off")
stage.addEventListener(Event.ENTER_FRAME,loop)
function loop(event:Event)
{
star.x = mouseX
star.y = mouseY
if (rectangle.hitTestObject(star))
{
star.gotoAndStop("on")
}
else
{
star.gotoAndStop("off")
}
}

"

TOPICS
ActionScript , Code , Error
284
Translate
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 ,
Feb 12, 2023 Feb 12, 2023

don't use the same instance name, ever.

Translate
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
Participant ,
Feb 12, 2023 Feb 12, 2023

but what if i want to have a hundred of the same movieclip. i don't wanna have to name all of them individually

Translate
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 ,
Feb 12, 2023 Feb 12, 2023
LATEST

then name them using as3 or use parent.getChildAt()

Translate
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