Reputation: 2501
I am trying to turn a movie clip into a button once the graphic catches your mouse as shown here:
http://www.kirupa.com/developer/mx/followease.htm
So, when the circle catches up to your mouse you have the option to click on that circle and go to a specified URL. Is this possible, if so how?
==============================
These notes are from the various responses thus far. I am still getting errors and cannot get the clip to function properly. Here is the exact code that I am applying to the movie clip (mc):
onClipEvent (load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent (enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.MouseEvent;
// assuming the movie clip is called mc
mc.onRelease = function() {
getURL("http://www.google.com");
}
Any further suggestions are much appreciated and thanks for those who have contributed thus far.
Upvotes: 1
Views: 5413
Reputation: 1094
onClipEvent(enterframe)
has unmatched }
try pasting this on the movie clip~
onClipEvent(load) {
_x = 0;
_y = 0;
speed = 5;
}
onClipEvent(enterFrame) {
endX = _root._xmouse;
endY = _root._ymouse;
_x += (endX-_x)/speed;
_y += (endY-_y)/speed;
}
onClipEvent(mouseUp) {
getUrl("http://www.google.com");
}
Upvotes: 2
Reputation: 1181
Following up on the solution provided by @Chris but in an AS2-context
in the code sample, mc is a link to the circle movie clip that is following the mouse
mc.onRelease = function() {
getURL("http://www.google.com");
}
Upvotes: 0
Reputation: 1094
you can simply add a click handler to your movie clip and use flash.net.navigateToURL to go to a specified URL.
import flash.net.navigateToURL;
import flash.net.URLRequest;
import flash.events.MouseEvent;
// assuming the movie clip is called mc
mc.addEventListener(MouseEvent.CLICK, onClick);
var url: String = "http://www.google.com"
function onClick(event: MouseEvent): void {
navigateToURL(new URLRequest(url))
}
Upvotes: 1