A Flash Developer Resource Site

Results 1 to 20 of 26

Thread: A problem with event dispatcher

Threaded View

  1. #1
    Senior Member
    Join Date
    May 2010
    Location
    Russia: Western Siberia
    Posts
    268

    Question A problem with event dispatcher

    Hi all!
    I got a weird problem with event dispatcher . I'm programming a little tank game (Check the attachment). The main class for tank is game.serovkonstantin.tanks.Tank.as and there are also 2 subclasses for now: Abrams and T90 which extend Tank. In my game.serovkonstantin folder I have a custom event (TankEvent), and the only event type inside of it which is TANK_INACTIVE.

    I've added an event listener for MouseEvent.CLICK to each of the tank instances (inside Tank.as) which works just fine. When I add any of the tank instance onto the stage and click it, it traces the tank's name just like I wanted whether it's Abrams or T-90 depending on what tank I clicked. But the problem is that when I click a tank I also want it to dispatch my TankEvent.TANK_INACTIVE. The main stage has a listener for this event, so I expected it to catch the event and trace some phrase, but nothing happens I don't know whether it doesn't dispatch my event or doesn't catch it.

    ========
    if you're interested why I need to dispatch this event, well, I suppose it will help my game know what tank to move when I click somewhere on the stage, and what tank(s) should be inactive, event it they all of the same type. I mean if I click one of the tanks it accepts all the controls while the other should be inactive (I hope it's not too confusing )


    If someone can show me another way to do so, I'd really appreciate it
    Attached Files Attached Files
    Last edited by caseyryan; 06-20-2010 at 02:39 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center