View Full Version : Dynamic mouse over display

12-05-2005, 05:07 PM
I have a project I'm working on for a public transit system and I need to be able to not only create the map, showing all the transit routes and stops, but upon mouse-over I need to display the name of the stop and a link to click for more info. like at http://www.ci.davis.ca.us/gis/unitrans/index.cfm.

Basically, there are a ton of stops and I was wondering if anyone knows a way that I can set up the site so that I'm re-using one circular button for all the stops that triggers the 'alt tag' looking box that holds the name of the stop and the link to click for more details, which will be different for each stop. Can I set two variables, one for the stop name and one for the link then have those triggered and changed in the onMouseOver command for each circle or have the button speak to a container that will hold the variables and spit out the variables values for each stop on mouseover? I have basic knowledge of Flash and little knowledge of how to use variables so a full explaination or a sample .fla would be very helpful. Thanks in advance!

12-06-2005, 07:18 PM
it looks like you figured it out i think...

12-06-2005, 09:23 PM
Well, in theory, I can imagine that I can set variables, but that's honlesly all I know. I have no idea how to work with variables but from what little I've read and working with programmers on php sites, I understand the general use of variables. So, i'm completely lost on where to begin, how to create the variables and how to make the variables change when the visitor rollsover the circular button. I get the theory but am completely lost on how to accomplish the task, or even where to begin.

12-06-2005, 10:06 PM
[maybe you should create arrays for (x, y) coordinates, stop name, and whatever else you need and then dynamically create everything from the arrays... this way you only need one circle and one alt tag to accomplish this.


stopsXPos_array = new Array();
stopsYPos_array = new Array();
stopsName_array = new Array();

stopsXPos_array[0] = 25;
stopsXPos_array[1] = 57;
stopsXPos_array[2] = 40;
stopsXPos_array[3] = 5;

stopsYPos_array[0] = 52;
stopsYPos_array[1] = 74;
stopsYPos_array[2] = 41;
stopsYPos_array[3] = 38;

stopsName_array[0] = "Hollywood/Highland";
stopsName_array[1] = "Cherry/Sweetzer";
stopsName_array[2] = "Glacier/Branham";
stopsName_array[3] = "Jarvis/10th";

function traceAllStops(n){
for (i=0; i<n; i++){
trace("stop "+i+" XPOS = "+stopsXPos_array[i]+" YPOS = "+stopsYPos_array[i]+" Stop Name = "+stopsName_array[i]);


when you call traceAllStops, call it as many times as you have stops. that way in the test window you can see if everything is lining up correctly.

the output window should look like this

stop 0 XPOS = 25 YPOS = 52 Stop Name = Hollywood/Highland
stop 1 XPOS = 57 YPOS = 74 Stop Name = Cherry/Sweetzer
stop 2 XPOS = 40 YPOS = 41 Stop Name = Glacier/Branham
stop 3 XPOS = 5 YPOS = 38 Stop Name = Jarvis/10th

once you have that, you can dynamically create the circle objects using those arrays.

if you need more help at that point ill show you how to dynamically create stuff.

it would probably be wise to make a database to store all this information, and use php to bring in the info to flash.

12-06-2005, 11:32 PM
Thanks, I think I get this, I will need help dynamically generating the buttons, can you help me with that, too, please? We will already have a db created for this site to pull in details for each stop so once I get this going I might be able to work with our programmer to integrate the two, thanks for the advice.

12-06-2005, 11:35 PM
oh, Also, I am placing this in a draggable mc and will need links attached to the circular buttons so html popups can appear onrelease, do you have any ideas on this as well? So far my buttons are conflicting with the draggable mc_that it's in. Here's an example of the kind of map I'm trying to create.

12-07-2005, 03:44 AM
this process is a LITTLE daunting at first, but after the first couple times you'll be glad you sweat through the first few times.

first create your circle movieclip that represents the stop. you dont want to actually put this on the stage. just create a new MC and keep it in the library.

inside this movieclip, make a layer titled "actions" and put this into it

var myTitle:String;

that code prepares a variable to give a value to later when we dynamically creat the stuff.

once you have created this object open your library and right click (control click on apple) and select "linkage" and select "Export for actionscript"... this will automatically select the "export in first frame" option... leave that, this is fine. now in the textbox give your object a name, something that works with code, meaning no spaces or weird characters !@#$%^&*() or keywords

lets assume that you called this object "myStop"

now that you have that... do this

NOTE: the arrays used in this part are the ones i used in my previous post, so look at those together.

stopCount = 0;

//think of this class as a way to initialize your movieclips individually
makeStopClass = function(){
//this puts the stop in the designated X and Y positions
this._x = stopsXPos_array[stopCount];
this._y = stopsYPos_array[stopCount];

//this one passes the stop name to the string variable inside the MC
this.myTitle = stopsName_array[stopCount];

makeStopClass = new MovieClip;
Object.registerClass("myStop", makeStopClass);

function makeStop(){
//this line of code have 3 parts.
//1. first the name in the library!
//2. then the new name (if the counter is 0, the name is myStop0)
//3. and then the depth to put it at.
_root.attachMovie("myStop", "myStop" add stopCount, stopCount);

//don't forget to increment the counter, otherwise
//it will keep on replacing the old stops!

//simple "for loop" to run the makeStop() function
function makeAllStops(myCount){
for (i=0; i<myCount; i++)

//now just call the function to make all the stops by how many stops you have
makeAllStops(50); //for 50 stops... remember you need the info inside the arrays though!

hope that helps.

12-07-2005, 03:51 AM
if you want to attach a url to when you click on these circles.

then open up your "myStop" MC and add this to the actions layer.

var myURL:String;

this.onPress = function(){

and then in the makeStopClass() function... oh yeah!! make sure all that stuff in my previos post is done in the root level of your movie.

anyway add this to it...

makeStopClass = function(){
//this puts the stop in the designated X and Y positions
this._x = stopsXPos_array[stopCount];
this._y = stopsYPos_array[stopCount];

//this one passes the stop name to the string variable inside the MC
this.myTitle = stopsName_array[stopCount];

//this one passes the URL to the object
this.myURL = stopsURL_array[stopCount];

of course this means that you have to create another array called "stopsURL_array" and put the appropriate information into it.

good luck! thats a toughie for a first time dynamically creating stuff. especially if you want to use php and mysql to import all the data. if you need help with THAT TOO then let me know

12-07-2005, 04:27 PM
Thank you SO much! I've contacted the programmer we're working with and I think we'll be able to figure this out together but I'll definately write back with any further questions. By the way, we are always looking for an experienced Flash developer, are you interested in contract work? If you are interested in trying out a project or two with us, or even help us finish this project by Dec. 16, email me at [email protected] Thanks again for your help!

12-07-2005, 06:21 PM
Alright I emailed you, so check your inbox.