Signification of the "dirty" variable ?
Hi all,
could someone try to explain what this "dirty" variable is for ? It's a member of TileGrid.as and used quite a lot but i don't really get what it is for.
Thanks :)
Fabien
could someone try to explain what this "dirty" variable is for ? It's a member of TileGrid.as and used quite a lot but i don't really get what it is for.
Thanks :)
Fabien
1
person has this question
I have this question, too!
Tell me when someone answers.
The more people who ask this question, the more it gets noticed.
The more people who ask this question, the more it gets noticed.
Create a customer community for your own organization
Plans starting at $19/month
-
Inappropriate?The main reason it is used it to call stage.invalidate() which triggers an Event.RENDER event. This is so that updates only happen once per frame. Event.RENDER is dispatched for all sprites that are be listening for it, so the dirty flag is used to keep track of whether the TileGrid should update or not. If another class called stage.invalidate, then dirty will be false and the TileGrid shouldn't update.
The reason we only want to update once per frame is, for example, when tweening the matrix values on TileGrid (tx, ty, a, b, c, d) we don't want to request and positioning tiles 6 times so we use Event.RENDER to ensure it's the end of the frame.
This works pretty well, I think, although it does cause some issues with events that are dispatched from the Event.RENDER handler. Nothing too bad, but that's why there's a MapEvent.RENDERED event that things like MarkerClip use to make sure the map is done moving before they update.
1 person says
this answers the question
Loading Profile...



EMPLOYEE