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

as3 collision with multiple movieclips with same instance name

Participant ,
Feb 12, 2023 Feb 12, 2023

Copy link to clipboard

Copied

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

Views

158

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

Copy link to clipboard

Copied

don't use the same instance name, ever.

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

Copy link to clipboard

Copied

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

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
Community Expert ,
Feb 12, 2023 Feb 12, 2023

Copy link to clipboard

Copied

LATEST

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

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