I have an application.html, which, in its head tag does
something like this:
window.user = new User();
in my User constructor, I have this:
this.firstName = "";
The user object uses createRootWindow to open up a login box,
uses ajax to authenticate, and if it is successful, fires an event
back to the user object with some of the data returned from the
server. In the function fired on that event, it does:
this.firstName = result.FIRSTNAME;
If I alert this.firstName in that function, the value has
successfully been changed to the one returned from the server.
If I then try to alert user.firstName from the original
application.html, it is still blank. How does one get around this?
On an unrelated note, I know TextEvent can be used to fire an
event and add a string to it as event.text. Which event can be used
to add an object to it that can be accessed by the event listener?
For the first issue, you might be running into the fact that
context of the dispatching object, not the object in which the
handler is defined. One way around this is to collect the value of
this in another variable and use that variable in the event
var that = this;
function handler( event )
that.foo = "bar";
For events, there are a few event objects that contain arrays
that you could repurpose by stuffing your object into an array. In
the long run, it would probably be better to create your own event
object in ActionScript, compile it into a SWF and load that in your
HTML app. That way the next programmer to come along is more likely
to understand what is going on.