Hi, Glen,

Sounds pretty wacky to me.
I'm going to ask a dumb question just to be sure...

In the code snippet, the event handler is inside the Sprite subclass itself?
In other words, I wanted to make sure that your reference to "stage" is
indeed the property of the event source, i.e. would this be functionally
equivalent:

Sprite(e.target).stage.addEventListener(MouseEvent.MOUSE_UP,
_stageMouseUpHandler, false, 0, true);
Just trying to cover all the bases.

-jonathan


On Tue, Mar 9, 2010 at 6:39 AM, Glen Pike <[email protected]> wrote:

> Hi,
>
>  More of a strange encounter that I would like to share / get some input on
> than something I need to fix this one...
>
>   I have recently encountered an issue where I am getting null for the
> stage property of a Sprite subclass in it's event handler for
> ADDED_TO_STAGE.  I have managed to work-around the problem, but have not
> addressed the core issue I think.
>
>   My app has states for operation and uses an XML socket to communicate.
>   States are: NORMAL, ADMIN and ERROR.  ERROR means the XML socket has
> disconnected, the other two states just have different levels of access
> control.  Each state has a corresponding AppScreen subclass, some containing
> lots of the above Sprites.
>
>   I can go into my ADMIN state from the ERROR state, but when the Admin
> screen was added to the stage it tried to send something via the XML socket
> class which sent an Error event to the App and resulted in the application
> switchin back to the ERROR state.  The Admin screen contained lots of the
> Sprite subclasses with the ADDED_TO_STAGE handler, but it seems that stage
> property of the Sprite subclass was actually null'd between the calling of
> the event and the accessing of the "stage" property and I end up with an
> exception in my Sprite subclass, e.g.
>
>   protected function _addedToStageHandler(e:Event):void {
>         //This would throw an exception because the stage is null at this
> point?
>         ///... some setup code, then:
>          stage.addEventListener(MouseEvent.MOUSE_UP, _stageMouseUpHandler,
> false, 0, true);
>       }
>  So any ideas why this would happen?  Is it because I am calling send on
> the socket which is an OS level thing and outside the normal Flash Player
> thread of execution, or am I fantasizing here?  I have worked around the
> problem which does flag an error when commands are sent to the disconnected
> socket (I still catch the exception, but listen for the error in a different
> place).
>
> Thanks for any insights.
>
> Glen
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
-jonathan howe
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to