What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.
What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.
We suggest you install the latest version of one of these browsers:
Of course, you just need to include a variable to hold the unit. Something like:
public class UnitEvent extends Event
// The unit responsible for this event
public var unit:Unit;
public function UnitEvent(type:String, unit:Unit)
this.unit = unit;
> *Originally posted by **[Arloistale](/forums/4/topics/322500?page=1#posts-6787384):***
> would I be able to somehow store the Unit that the UnitEvent belongs to when I dispatch it?
If the Unit itself dispatches the event, it’ll be the target of it.
Okay, what if I have two data that I need to take care of in the UnitEvent. The first is completely related to the UnitEvent: the unit itself. The second is a rectangle. When the unit enters the rectangle relative to the stage, I need the event to dispatch. Since the rectangle is unrelated to Units, is it bad practice to store it in the UnitEvent? Should I keep track of it some other way?
It’s not unrelated, if the interaction between them matters. You need to make sure that the event’s in a sensible package and that they really should be related, but there’s nothing wrong with having both of them in the event if they need to be together.
What disturbs me though is that they won’t always need to be together. The UnitEvent also describes events like if the unit dies or possibly other actions unrelated to rectangles. So if the event type won’t always be about a rectangle, then having a rectangle variable in the unit event would be extra information, which I don’t think is efficient.
> *Originally posted by **[Arloistale](/forums/4/topics/322500?page=1#posts-6788543):***
> Is this a common practice? I might not be looking in the right place, but I don’t see any examples of other events that use variables other than the type.
Just to note, most events use variables like this. See [MouseEvent](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/MouseEvent.html#propertySummary) for example; it has properties for the mouse position, whether the button is clicked etc.