1

I'm currently trying to work on a mod for a game and when I display the array all I see is [object Object]. I'm wanting to actually see the information inside of the array. I'm new to actionscript so I feel as if it's probably a simple issue that I'm overlooking.

I've tried everything below. I'm expecting it to return the actual stored information, ex: ids, item name, etc.

if(param1.keyCode == 89)
{
    GlobalFunc.SetText(this.debugMenu,String(this.m_TheirOffersData[0].toString()),false);
    GlobalFunc.PlayMenuSound(GlobalFunc.MENU_SOUND_OK);
}
if(param1.keyCode == 85)
{
    for(var id in this.m_TheirOffersData)
    {
        var value:Object = this.m_TheirOffersData[id];
        GlobalFunc.SetText(this.debugMenu,this.trProgress = this.trProgress + trace(id + " = " + value),false);
    }
    GlobalFunc.PlayMenuSound(GlobalFunc.MENU_SOUND_OK);
}
4
  • Enumerating dynamic properties in AS3 Objects is not simple. You would likely need to do some serious wok to enumerate stuff, an example is in this question stackoverflow.com/questions/3407713/… Commented Mar 12, 2024 at 5:38
  • LOL tried to change title to "How to display the information inside an Object" - BAM collision with a question for Java. While algorithms would probably be the same - find dynamic properties list, traverse it and parse values, the tools differ. BTW a hint would be to use as3corelib JSON encoder for your task, it already does the job of transforming a custom Object into a human-readable string. Commented Mar 12, 2024 at 5:46
  • I actually am looking at that function. I've tried so many different things and it's driving me absolutely crazy. I've been messing with AS for like 3 days and it's a nightmare compared to other languages to me. Commented Mar 12, 2024 at 6:05
  • If it is a generic object (a.k.a associative array of key=value pairs) then the simplest way to convert it to text is help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/… Commented Mar 12, 2024 at 9:12

1 Answer 1

2

Not sure if you're still looking for an answer here, but what is the structure of the Object you're trying to read? it might be easier to help.

Based on the info you've given, m_TheirOffersData seems like an array with generic, JSON-like objects. but you seem to be trying to access an id property on the array. Again, I don't know the data format you're expecting, but I would use a for loop to access each object, then a sub loop to get the properties of each object like so:

for (var i:int=0; i < m_TheirOffersData.length; i++) {
  current_offers_data:Object = m_TheirOffersData[i];

  // then we can get the object properties directly
  for (var object_key:Object in current_offers_data) {
    trace(object_key + " = " + current_offers_data[object_key];
  }
}

If you need any clarification, let me know :)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.