Flex/AS3 can be extremely frustrating, as well as being very powerful. I’ve spent a couple of days creating a generic class for communicating with PHP, catching the response and sending it back to the calling object. I’d got fed up with having multiple, almost identical, event catching functions all over the place.
So, having done that (not without a struggle) and having received back nicely formatted XML data ready for populating the datagrid on the main MXML page I then found I couldn’t (or didn’t know how to) assign that data to the dataProvider property of the datagrid. Flex was telling me that the object didn’t exist. This is fair enough as it makes sense given the object oriented nature of AS3 but I knew there had to be a way around it. I hit the web and found a few places where the question had been asked, only to find that the arses that responded to the question simply said “you shouldn’t do it that way” or gave a vague explanation when, in fact, a one liner would have done it. Don’t we coders have enough challenges when creating code without unhelpful “support” from our fellows?
Anyway, here it is. To reference an MXML object from any object (assuming you’ve given it an id)
Application.application.nameofobject.property/method
In my case it was:
Application.application.dgorglist.dataProvider=theXMLList;
So, in this case, Application.application takes the place of _root in AS2 applications when referring to properties.
Use Facebook to Comment on this Post



.gif)