Check if movieclip exists on stage

Community Beginner ,
Jan 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

Hello, I am trying to write some simple code that checks to see if an object exists on the stage. But I'm not really sure how this is supposed to work. If I check if it's on the stage i get a conversion error. If I try to do a simple if exists statement it always returns true. I just want to check if an object exists on every frame, and if it exists, pull it's coordinates.

 

I attached a small piece of sample code. This should be simple but actionscript makes it so difficult...

 

https://drive.google.com/file/d/1fFEMDH80YPql0su2UOtnRkWgd4DbpZCP/view?usp=sharing

Views

49

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
community guidelines
Adobe Community Professional ,
Jan 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

Hi.

 

You need to assign an instance name to your Movie Clip instance using the Properties panel.

image.png

 

Also, there's no need to export the Movie Clip to ActionScript if you're not gonna need to add it at runtime. And if you do need it to be exported for ActionScript, choose a different name for the class.

image.png

 

And to safely check if a instance exists on the display lists, just check for the instance itself and for the stage property.

 

if (yourInstance && yourInstance.stage)
    // do something

 

 

As this is a duplicated question, I'm going to block the other discussion:

https://community.adobe.com/t5/animate-discussions/scanning-an-object/m-p/12649090#M350338

 

I hope this helps.

 

Regards,

JC

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
community guidelines
Community Beginner ,
Jan 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

thank you, i was finally to get this working properly and pull the proper dimensions of the object.

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
community guidelines
Adobe Community Professional ,
Jan 12, 2022 Jan 12, 2022

Copy link to clipboard

Copied

LATEST

You're welcome.

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