Copy link to clipboard
Copied
Hi!
I need to create an script for a basic function; when mouse goes over a moveclip, that works also link, I want it to trigger an invisible red dot on a nerby map. I have created a movieclip and named it "red", it's a 1 sec clip with nothing in the beginning and a red dot in the end. I want this dot to trigger and show only when mouse goes over this specific link, otherwise it must be invisible.
I know this is pretty basic stuff and I have done this before few years back but I have forgotten how to do it and need help now.
Any help would be very much appreciated 🙂
Kim
When you mention you don't understand why the button code is where it is, it gives the impression you didn't design this file. MAybe what you should do is redesign the button coding in a way that is familiar to you. The way the coding is done there is the old way and it is not a recommended way.... partly because it hides the code from clear view.
If you give the buttons instance names, you can assign mouse event functions to them on the timeline rather than on the buttons themselves...
btn1.onR
...Copy link to clipboard
Copied
There is a minor complication in that your red dot animates, and it isn't clear what you intend for that animation versus making the dot visible or not.
To control the visibility of the dot you need to give the dot an instance name.... let's say you name it redDot (understanding it's not the name it has in the library, but its instance name). Then you simply set its _visible property to true or false as needed.
redDot._visible = true;
redDot._visible = false;
Now as for the playing of it, you'll need to explain the intentions there because there's a lot that could be explained to cover all possible scenarios, and I'f rather focus on intentions.
As for making the movieclip react to the mouse to trigger things, you will also want to give that an instance name, say dotMC, and assign it the rollover code...
dotMC.onRollOver = function(){
redDot._visible = true;
}
dotMC.onRollOut = function(){
redDot._visible = false;
}
Copy link to clipboard
Copied
Thanks a lot Ned!
I'm totally confused with Flash again... I used to do small things 5 years ago, but now I just do things wrong all the time.
My reason for the red dot is to make it visible on a map, when people hover the mouse over a link, so that they can see the location of the link.
I have my movie clip and I named it "red", its just few frames long and I have a "stop" function on it, so that it dosent twinkle once triggered. I have dragged on the correct location on the map from the library, but the problem is, I can't make it invisible. How do I go about naming the instance as you said? I open "red" and click on the first frame and give it a new name and put the script you advised there, but it dosent work.
Sorry for this beginners level problem, I should really study flash more, but I only have to do couple minor things now and try to save time and energy 🙂
I also have to put a text to appear under this same link, that activates when mouse over, the address is displayed in this text. I suppose I have to do it the same way... I tried but could not get anything to show.
Kim
Copy link to clipboard
Copied
To give it an instance name, you place the movie on the stage and in the properties panel you fill in the box that says instance name with the name you want to use to refer to this instance when using code. The code I showed you would go in an actions layer on the same timeline where you place the dot movieclip.
I have already given you what you need to be able to make it visible or not, both with and without the rollover.
As far as you having the red dot as a movieclip that really isn't necessary. If it will only be visible or not, then you only need to have the red dot in one frame and control the visibility of the movieclip that houses it.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
If those buttons are in a movieclip, and the redDot is not in that movieclip, but on the same timeline as that movieclip, then to command the redDot from inside that movieclip you need to refer to the _parent timeline. So your code may have to be....
_parent.redDot._visible = true; // etc
If that doesn't work, then you probably need to explain a little more about where these objects exist relative to each other.
Copy link to clipboard
Copied
It didn't work, so I try to explain how things are:
There is a layer named "navbar" where a movie clip named "navbar" is. Navbar is made of 5 flags in a line and over each flag is an invisible button; nav1, nav2 and so on. These buttons are movieclips in which are certain functions like text, little movement and glare. Inside this nav1 movieclip is an invisible button with this code:
on (release) {
getURL(/:url1);
}
on (rollOver) {
gotoAndPlay(2);
}
on (rollOut) {
gotoAndPlay("sec");
}
It is here that I have tried to put the visibility control of the red dot without success.
What I don't understand about this invisible button, is that the actionscript dosen't seem to be on a keyframe, it appears only when I open the movieclip (nav1) from library and click on the blue shape that represents the invisible button on the stage. If I click on the keyframe in the layer where this invisible button is, there is no actionscript...
However, all works fine and the only problem is to control now the invisibility of this darn red dot.
Furthermore there is a layer named "red" on the timeline also, it is here that the red dot is added from library and given instant name "redDot". I added the dot to the very beginning of the timeline and actionscript: redDot._visible = false; is written here and it works as it should - the dot is invisible when the movie loads
.
There are also other layers where a logo is animated on the timeline and more stuff like background etc.
As i said previously, if I create a new layer and add a simple button somewhere on the stage, then add actionscript to control the visibility of "redDot" it works! But the same thing dosen't work from anywhere inside navbar. I have tried to put it in every imaginable spot inside the nav1 movieclip but the red dot remains invisible.
I am happy to tell more if something important is still missing and I appreciate your help very much.
Kim
Copy link to clipboard
Copied
When you mention you don't understand why the button code is where it is, it gives the impression you didn't design this file. MAybe what you should do is redesign the button coding in a way that is familiar to you. The way the coding is done there is the old way and it is not a recommended way.... partly because it hides the code from clear view.
If you give the buttons instance names, you can assign mouse event functions to them on the timeline rather than on the buttons themselves...
btn1.onRelease = function() {
getURL(/:url1);
}
btn1.onRollOver = function() {
gotoAndPlay(2);
}
btn1.onRollOut = function()
gotoAndPlay("sec");
}
Since you say you had a button on the main timeline that was able to control the dot properly, what you might do is gradually move that button into the navBar to the same loaction as the other buttons, and with each step you adjust the code to retain the red dot control. Each timeline you move into would mean adding a _parent reference to target the red dot, for instance...
redDot._visible = true; // on the same timeline as the red dot
_parent.redDot._visible = true; // inside a movieclip that is on the same timeline as the red dot
_parent._parent.redDot._visible = true; // inside a movieclip that is inside that movieclip that is on the same timeline as the red dot
Copy link to clipboard
Copied
Thanks again Ned for your help 🙂
I was finally able to target the red dot by this code: _root.redDot._visible = true;
You were right also that I have not designed that movie alone, it is mostly my design, but the navigation part was designed elsewhere, that is why I had trouble with it.
Flash is difficult...
Copy link to clipboard
Copied
You're welcome