views:

19

answers:

2

Hey all,

I have a class called Mouse (tracking button states in a game). I want that class to be able to show and hide the mouse cursor. Whenever I try to use flash.ui.Mouse.show() or flash.ui.Mouse.hide() I get the error: "Access of undefined property flash.".

I can't import flash.ui.Mouse for obvious reasons.

Is there a way to make this work? What's the point of packages if they don't resolve these collisions?

+1  A: 

You have to import flash.ui.Mouse, and use the fully qualified class name in your code (flash.ui.Mouse.)

sharvey
I did not know that you had to import something even if you use its fully qualified name. That is very different form most languages.Works a charm, thanks!
Scott
If you need access to both Mouse classes, yours and the default, you'll need to use the fully qualified name for both of them too.
Sandro
Thanks Sandro -- the whole point is to never have to use anything but my own class, though. So that shouldn't be a problem.
Scott
A: 

You could use this. I'm not sure of the reasoning, but it works.

import flash.utils.getDefinitionByName; // Goes in import section, obviously.

getDefinitionByName("flash.ui.Mouse").hide();
Sandro
This work, but you get no compile time type checking, and the run-time definition resolving is more expensive.
sharvey
Maybe that's the price you have to pay for naming a class Mouse :) jk.
Sandro