Rollover and swapChildren Problems
Ok I have a Flash file with a square on one layer and on another layer right underneath is a map with an external link. My problem is that when you rollover the top square (it's a movie clip), it displays the map but the link does not work. I'm sure this is because I have it coded so that the movie clip is still there but not visible.
Here is the code for the rollover:
I've been experimenting with addChild and swapChildren properties, but I'm still new to Actionscript 3.0 and Im having problems.
Here is the code I was experimenting with, and I know this completely wrong:
Any help is greatly appreciated
here's a way to go about it, using your line of reasoning. there are of course, other ways and approches to this problem.
this way utilizes a movieclip's 'visible' property as opposed to its 'alpha' property. if the alpha is set to 0, it appears invisible to us, but it is really still there in the display list covering up objects underneath it, whereas setting it's property to 'visibile=false' reveals what is underneath it .
also- for the way i will describe, make sure that the clip/button on top is either exactly the same size and in exactly the same position as the clip that is underneath, or make sure that it is smaller, but contained within the borders of the clip underneath it: : think of an oreo cookie that you took the top part off. you see the white filling(bc_mc) on top of the bottom part(myBtn) of the cookie : - )
otherwise you will get unexpected RollOver/RollOut behaviour
for this example there are 2 movieclips, one instance named 'myBtn' which will function as your map.
it will be scripted to be a clickable link to an external site ( i set it to google.com )
the other moviclip is instance named 'bc_mc' and sits on top of 'myBtn'
to make matters clear and clean, i start off giving 'myBtn' buttonMode capabilities- this way when testing, we get extra visual information as to if it is being recognized or not.
then i set the initial visibility of 'myBtn' to false, and 'bc_mc' to true.
this is not necessary, but it keeps things clear : when one is visible, the other is not. we could then use this as Boolean info and simplify our code, but i will leave that to another discussion..
the rest of the code should be pretty readable, but i will explain it as such:
bc_mc is given a listener and function for RollOver( or MouseOver) which makes bc_mc invisible, and the map(myBtn) visible. within the scope of this function, it also gives myBtn a CLICK listener to lead to the function to make it link to google.com, and a RollOut/MouseOut listener on myBtn which will take you to the function to reverse the visibilities( myBtn to false, and bc_mc to true.
once again, this is just one approach, using as much as possible your code and logic. i hope that helps you to understand and utilize it. if you need the .fla posted, just let me know
Thank you so much, the code worked beautifully.