• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

FLASH MX 2004 action script question

New Here ,
Sep 17, 2009 Sep 17, 2009

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

TOPICS
ActionScript , How to

Views

1.3K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Sep 19, 2009 Sep 19, 2009

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

...

Votes

Translate

Translate
LEGEND ,
Sep 17, 2009 Sep 17, 2009

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;

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 17, 2009 Sep 17, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 17, 2009 Sep 17, 2009

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2009 Sep 19, 2009

Copy link to clipboard

Copied

I still need help, this problem is little more complicated;
I can manage making the red dot visible and invisible by triggering roll over and roll out on a button.
The problem is, I have a navbar which is line of flags made to a movie clip, with 5 invisible buttons. These buttons are configured to do three different actions; get URL, trigger a light effect and a movement effect.
Now I need this invisible button to trigger my red dot also so that when mouse is over a certain flag a red dot appears on a map on the correct location.
I have the red dot on a new layer. It has instance name "redDot" and on the very first frame of this red button layer, I have action script that says: redDot._visible = false;
This works as it should and the dot is invisible when the movie has loaded.
I need to make this invisible button to trigger the visibility of my red dot, and I have tried to add the code:
on (rollOver) {
redDot._visible = true;
}
on (rollOut) {
redDot._visible = false;
}
to this invisible button, but it dosent work, furthermore it affects the other functions of the button/movie clip, which were working fine before.
Here is the code attached to this invisible button so far:
on (release) {
getURL(/:url1);
}
on (rollOver) {
gotoAndPlay(2);
}
on (rollOut) {
gotoAndPlay("sec");
}


I have the URL:s on an external text file.
So my question is; where do I add the action script to make it visible when moving the mouse over this invisible button? To my understanding, it should go in the same place as the other code that is working, but I'm doing something wrong...
I tried to do this:
on (release) {
getURL(/:url1);
}
on (rollOver) {
gotoAndPlay(2)
        redDot._visible = true;
}
on (rollOut) {
gotoAndPlay("sec")
redDot._visible = false;
}
But it is wrong, I also tried like this:
on (release) {
getURL(/:url1);
}
on (rollOver) {
gotoAndPlay(2);
}
on (rollOut) {
gotoAndPlay("sec");
}
on (rollOver) {
redDot._visible = true;
}
on (rollOut) {
redDot._visible = false;
}
But it makes the other functions that worked to stop working.
I also tried to give the invisible button an instance name and do it like this:

invisible.on (rollOver) {

        redDot._visible = true;
}
invisible.on (rollOut) {

redDot._visible = false;
}

And put them in the actions layer of button movie clip but nothing works.
Flash is really giving me a headache now...
To conclude, I made a simple test button, put it on the scene somewhere and and attached the rollOver and rollOut codes, targeting the "redDot" and it works fine, the button didn't need a instance name to work. I don't understand why I can't make it to work with the invisible button where it should be.
I hope this clarifies the point and I can get some help with this and sorry for bothering again with this problem.
Oh and I use old Flash MX 2004.
Thanks
Kim

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2009 Sep 19, 2009

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2009 Sep 19, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 19, 2009 Sep 19, 2009

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 20, 2009 Sep 20, 2009

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...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Sep 20, 2009 Sep 20, 2009

Copy link to clipboard

Copied

LATEST

You're welcome

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines