PDA

View Full Version : AS3 ROLL_OUT Listener not firing



Imogene
January 16th, 2010, 09:50 PM
Hi all,
I have seen a few questions about this but no answers. I am loading an external image into a movieclip and the rollout works fine if I move the mouse slowly. If I scroll quickly across the stage, the rollover state stays and the rollout doesn't happen. Slowly rolling back over the movie clip doesn't fire the rollover, but does fire the rollout according to the traces.

container.getChildByName("dot").getChildByName("id").addEventListener(MouseEvent.ROLL_OUT, dotRollout);

Unfortunately, I don't have a small example of this. It is a piece of a rather large conversion from AS2 to AS3 and this is just about the last bug.

I could use a trick to track the listeners that are added and removed. Any ideas on this?

Am I creating the problem by adding and removing the listeners everytime a hover or src image gets loaded?

I should mention that it is failing in Flash player 10 since one post called it a player bug. No great info there.

Thanks in advance,
Imogene

snickelfritz
January 16th, 2010, 11:12 PM
Assign the listener to the container.
If there are multiple objects in the container, use MOUSE_OVER instead of ROLL_OVER.
Mouse Events will propagate to all mouseEnabled objects.

Imogene
January 21st, 2010, 11:05 PM
I have wittled down a piece of code and as far as I can tell from the debug, the loader info doesn't seem to be available for the variable assignment to tempDot_mc and temp_ip if I am rolling in and out quickly. The swf loads a src image and then swaps the image on rollover, swaps back on rollout.
I have the listeners on the container named outer.

I also tried using event.COMPLETE on the loader with no success.

Have been fighting this for days so I am really hoping someone can see a fix in this.
Thanks,
Imogene

public function loadDot(ip,dotContainer,path:String, what)
{
var loader:Loader;
loader = new Loader();
loader.load(new URLRequest(path));
var wrapper:MovieClip = new MovieClip;
var outer:MovieClip = new MovieClip;
loader.contentLoaderInfo.addEventListener(Event.IN IT,loadInit);
wrapper.addChild(loader);
outer.addChild(wrapper).name = ip;
dotContainer.addChild(outer).name = ip;
dotContainer.getChildByName(ip).type = "point";

return loader;
}

public function loadInit(event:Event)
{
var aligner:Object = new Object;
var loader:Loader = Loader(event.target.loader);
var info:LoaderInfo = LoaderInfo(loader.contentLoaderInfo);

var tempDot_mc = loader.parent.parent.name;
var temp_ip = loader.parent.name;
aligner = findAlignment(temp_ip, _dots,"src_alignment",info.width, info.height);

dotContainer.getChildByName(tempDot_mc).width = aligner.newwidth ;
dotContainer.getChildByName(tempDot_mc).height = aligner.newheight;
dotContainer.getChildByName(tempDot_mc).x = ...
dotContainer.getChildByName(tempDot_mc).y = ...

loader.contentLoaderInfo.removeEventListener(Event .INIT,loadInit);
}

Imogene
January 22nd, 2010, 02:22 PM
Maybe it would help to mention the error I am getting.
Error#1009: Cannot access a property or method of a null object reference.

And this only happens if I scroll quickly across.

I also just tried adding a separate loader variable for the hover, thinking that maybe the rollover and rollout events info were somehow getting confused.

Any ideas?

Thanks,
Imogene

[MuG]
January 25th, 2010, 08:00 AM
From what you've shown here, you've passed "dotContainer" to your function "loadDot". "loadDot" can use it but it won't be available to your function "loadInit".

Also getChildByName parameter should be a string : dotContainer.getChildByName("tempDot_mc").width ...