How do I find the "ID" for objects like "Text" , "Sprite" , etc?

0 favourites
  • 7 posts
From the Asset Store
Change delay, create new lines, "backspace" the text
  • Hey guys,

    How do I find the "ID" for objects like "Text" , "Sprite" , etc?

    For example, in "Form controls" category, like "Button", "Textbox", etc there is in properties "ID (optional)"... so my question is:

    Can i find their IDs names?

    Or there is any other way to create/find this?

    I ask because i want to control them via javascript outside construct.

    Thanks in advance,


  • You set the ID manually for each such object in layout editor. I don't think you can change or retrieve it with events.

  • What do you mean? I don't see any ID setting on layout or layer properties.

    If you mean just to give names to layout or each layer, i test this, no working.

    To understand more, I use a ".js" file and write this:


    So with a button object i test, works fine.

    But can't made the same thing with objects like text, sprite, etc.

    Imagine to control color, opacity, even replace images in sprites via javascript.

    Make sense? Can work what i need or not?

    Or need to edit plugins for personal purpose and add id code inside?

    I don't know, just thoughts..


  • Oh, I'm terribly sorry, I read your question wrong. I thought you wanted to find this ID for form control objects.

    I'm not sure this is possible for other object types. Maybe you can work around this using C2 callback function. You can call this function from your JS, pass the object type in a parameter, and then in C2 function you pick objects of that type and do something with them (change opacity or whatever). Something like this:

    In JS:
    c2_callFunction('UpdateOpacity', ['sprites']);
    In C2:
    Function "UpdateOpacity" 
     Function parameter 0 ="sprites" -> AllSpritesFamily set opacity to 50
  • Ok i try your sample, i get the point, i change opacity from construct.

    I need to change the opacity from js not from construct. I want to have opacity in construct 100 for example.. and the value to change each time from js.

    What need to write on js code you give me?

    c2_callFunction('UpdateOpacity', ['sprites']);


  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I am not good at JS. I believe you can send multiple parameters, like this:

    c2_callFunction('UpdateOpacity', ['sprites', new_opacity]);

    And then in C2 you access these values from Function.Param(0), Function.Param(1) etc.

  • I understand. I will do some tests. Thanks again for your help.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)