4 Replies Latest reply on Aug 10, 2009 8:43 AM by nikos101

    Get object by id

    nikos101 Level 2

      If I have an object that is not a child of anything in my application, how do I get it with just its id name?

        • 1. Re: Get object by id

          I don t know, if that s the best solution, but you can try this:


          Make a reference in your Main Application YourApp:


          public var myObject:Object;



          If you create your Object, use your Object from the Main Aplication

          YourApp(ComponentYouCreateYourObject.parentApplication).myObject = new Object();



          Actually, you shouldn't need the id anymore, because you are able to acces the object with this cast:





          1 person found this helpful
          • 2. Re: Get object by id
            nikos101 Level 2

            Well the trouble is that I need to use the id parameter as I have a pool of objects and I don't want to repeate code. Basically someone clicks on a button and that particular button passed the id of the object I need as a string to a function

            • 3. Re: Get object by id
              Gregory Lafrance Level 6

              I don't fully understand the problem, but if the issue is accessing a variable using a string, you may try this:




              If this post answers your question or helps, please mark it as such.

              • 4. Re: Get object by id
                nikos101 Level 2

                wow it was that easy, thanks mate