In Flash, I have created an invisible button. I can ad some actionscript to make the button to go to another scene, even if it's on hover! (which isn't meant to be. Yet, how do I get it so that when it hovers, it goes to another scene immediately. Are there far better ways of doing this then using invisible buttons?
Thanks in advance.

P.S I am using Actionscript 2.0 - Yes, I know, I haven't made the transition yet :( If possible, I wouldn't mind knowing how it is done in Actionscript 3.0 :D

Dani AI

Generated

Short answer for Flash/AS2: attach a handler to the button instance, cancel accidental triggers with a tiny hover delay, and prefer frame labels instead of hard-coded frame numbers. ’s timeline snippet is fine as a quick test, but the pattern below is safer and easier to maintain.

// AS2 — instance-based handler + short hover delay
var HOVER_MS:Number = 250;
hotSpot.onRollOver = function() {
    if (this._hoverTimer) clearInterval(this._hoverTimer);
    this._hoverTimer = setInterval(this, "_doNavigate", HOVER_MS);
};
hotSpot.onRollOut = function() {
    if (this._hoverTimer) { clearInterval(this._hoverTimer); delete this._hoverTimer; }
};
hotSpot._doNavigate = function() {
    if (this._hoverTimer) { clearInterval(this._hoverTimer); delete this._hoverTimer; }
    _root.gotoAndPlay("targetLabel"); // use a frame label you create on the timeline
};

If you move to AS3, use event listeners + a Timer and navigate by frame label (AS3 does not accept the scene+frame style). Example:

// AS3 — Timer + mouse events; prefer frame labels over scene names
import flash.utils.Timer;
import flash.events.TimerEvent;
import flash.events.MouseEvent;

var hoverTimer:Timer = new Timer(250, 1);
hoverTimer.addEventListener(TimerEvent.TIMER_COMPLETE, gotoLabel);

hotSpot.buttonMode = true;
hotSpot.addEventListener(MouseEvent.MOUSE_OVER, function(e:MouseEvent):void { hoverTimer.reset(); hoverTimer.start(); });
hotSpot.addEventListener(MouseEvent.MOUSE_OUT,  function(e:MouseEvent):void { hoverTimer.reset(); });

function gotoLabel(e:TimerEvent):void {
    (root as MovieClip).gotoAndPlay("targetLabel");
}

Troubleshooting & UX notes: make sure the instance name is correct, the hit area covers the pixel region you expect, and the timeline label exists. Hover navigation can frustrate users (and breaks keyboard accessibility), so prefer a visible hover state or require a short hover duration as above. ’s HTML/JS onmouseover example applies to DOM images, not inside an SWF — use the AS2/AS3 approaches shown for Flash.

Recommended Answers

All 5 Replies

use javascript

on hover you can put events using javascript...

a bit close to your issue u can code like

on(rollOver){

      gotoAndPlay("sceneName", 24);

}

may b this cud help u...

you could go

<html>
<head>
<script type= "text/javascript">
function fdsa()
{
    imgimgimg.src= "egamiym.jpg"
    return 0;
}
</script>
<title>fdjskal</title>
<body>
<img src= "myimage.jpg" onmouseover= "fdsa()" id= "imgimgimg" />
</body>
</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.