I’m an old C programmer been away from programming for years. Now we have a project requiring Flash and I’ve been elected. Just installed CS4.
I have 16 panels in 4 sets of 4 that rotate left to right. (Big learning curve on that one - fading transitions in the right order…). Each panel must have a unique url when clicked. (16 urls).
I’ve looked through many solutions, most of which seem unduly complex. I think that the simplest short of going to onRelease() with AS2 (Later I have to add mouseover changes in the graphics) is something like this:
function handleLink( pEvent:MouseEvent ):void
{ switch(pEvent.target)
{ case btnLifestyleA1:
var request:URLRequest = new URLRequest(a1Link);
break;
case btnLifestyleA2:
var request:URLRequest = new URLRequest(a2Link);
break;
//etc …
default:
var request:URLRequest = new URLRequest(“http://www.defaulturl.com/”);
break;
}
if( pEvent.target == btnLifestyleA1 )
{ navigateToURL( request, “_blank”); }
}
var a1Link:String = “http://www.someurl.com/”;
btnLifestyleA1.addEventListener( MouseEvent.CLICK,handleLink );
var a2Link:String = “http://www.anotherurl.com/”;
btnLifestyleA2.addEventListener( MouseEvent.CLICK,handleLink );
//etc …
I haven’t found this solution out there. Is there a gotcha because the a#Link vars are accessed as global within the scope of handleLink? It doesn’t feel right, but it works fine and 16 global variables doesn’t seem too bad.
Is there a better way?