Skip to main content
Known Participant
January 12, 2022
Question

Check if movieclip exists on stage

  • January 12, 2022
  • 1 reply
  • 495 views

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

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 12, 2022

    Hi.

     

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

     

    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.

     

    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

    Known Participant
    January 12, 2022

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

    JoãoCésar17023019
    Community Expert
    Community Expert
    January 12, 2022

    You're welcome.