FORUMS: list search recent posts

AS3 MouseOver action "dies" after 2 passes

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Glenn Cashmore
AS3 MouseOver action "dies" after 2 passes
on Dec 4, 2008 at 7:34:24 pm

FIRST PROBLEM
I am using FLASH at University of Colorado @ Boulder. I am doing a basic mouse-over action with action script (see below) It works just fine for one or two passes of the mouse and then the roll over "dies" and will no longer produce the effect unless I refresh the page. Then it works again for one or two passes... etc etc

I have provided the script I'm using below. I have tried to trouble shoot myself by reducing file sizes of the associated photos, combining thumbnails and mouse-over photos in the same layer, anything I can think of that might be bogging down the software.

Our school equipment is brand new Dell machines with Intel Core Duos, Firefox, Vista... but I have the same problem on school brand new iMacs.

There are 5 photo thumbnails arranged on a single frame in the same scene. The action is to show a larger version of the same photo on mouse-over.

Are there other things I can change that may be causing this?

SECOND PROBLEM: I can't get the HTTP link associated with "glenn Cashmore" text in the upper left corner to link to the web. I get a configuration error for my Flash plug-in. I go to the config panel and give permission to Flash for EVERY option and it still won't connect. Still error. Could this be associated with a firewall at the university. I don't know what else to trouble shoot.

Attach Code

Collage1ROLL.visible = false;


Collage1THUMBMOVIE.addEventListener(MouseEvent.MOUSE_OVER, function(event:Event) {
fadeInClip(Collage1ROLL);
});
Collage1THUMBMOVIE.addEventListener(MouseEvent.MOUSE_OUT, function(event:Event) {
fadeOutClip(Collage1ROLL);
});



function fadeOutClip(clip, speed = 10) {
if (clip.fadeTimer > 0) {
clearInterval(clip.fadeTimer);
}
clip.fadeTimer = setInterval(function() {
clip.alpha -= 0.05;
if (clip.alpha <= 0) {
clearInterval(clip.fadeTimer);
}
}, speed);
}

function fadeInClip(clip, speed = 10) {
if (!clip.visible) {
clip.alpha = 0;
clip.visible = true;
}
if (clip.fadeTimer > 0) {
clearInterval(clip.fadeTimer);
}
clip.fadeTimer = setInterval(function() {
clip.alpha += 0.05;
if (clip.alpha >= 1) {
clearInterval(clip.fadeTimer);
}
}, speed);
}


Return to posts index

Pieter Helsen
Re: AS3 MouseOver action "dies" after 2 passes
on Dec 4, 2008 at 8:24:32 pm

clear/setInterval is not correct AS3 syntax. Use the Timer() class instead.

Also, as a best practice, don't create functions inside listeners or the setInterval methods. Use function names instead. Like so:

addEventListener(MouseEvent.MOUSE_DOWN, downHandler);

function downHandler(evt:MouseEvent):void {
// Do stuff here
}

This produces much cleaner code and it doesn't confuse the hell out of me ;)

I don't see any http:// URL request, so I don't know what's going wrong with that. However, correct AS3 syntax would be this:


var urlStr:String = "http://www.mysite.com";
var urlReq:URLRequest = new URLRequest(urlStr);

navigateToURL(urlReq, "_blank");


Kind regards,
Pieter

General notice: from now on, I would like to ask everyone to put [AS2] or [AS3] (corresponding to the version of actionscript you are using on your project) in front of their post titles when the question is actionscript related! Please help us help you faster. Thank you.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]