Am I doing this wrong,
I get duplicate variable definition warnings...
the variable is internal to the function
it's in a if/else so it's shouldn't be mixing itself up.
Should I be renaming the internal temp variable to myEvent1, myEvent2..then dispatching it...like that in the if/else
or creating another function and calling the dispatch function from there?
why not move the 'var myEvent' onto the top of the if (remove it from both the if and else blocks).
You're right--that normally shouldn't be an issue. However, ActionScript does something called "variable hoisting" which automatically "pulls up" all variable declarations within a function's statement blocks to function-local. This means that something like an if block or an else block (or a loop, for that matter) does not (really) introduce a new scope, so that's why the two declarations that *look like* they're in different scopes actually conflict, resulting in your warning.