I got this banner, which plays for about 4 seconds and then loads an array (2 images at a time (out of 6)) at random.
I want to go to a website when clicking. But I'm not sure how to add the url request to my array. I created an empty square (movieclip called mouseover) which covers my whole banner. But nothing happens when I click, and I don't get any errors.
var imageArr:Array = [
["11.jpg", "12.jpg"],
["21.jpg", "22.jpg"],
["31.jpg", "32.jpg"]
];
var colorContainer:Loader = new Loader();
var bwContainer:Loader = new Loader();
var randNum:int = Math.round(Math.random()*2);
colorContainer.load(new URLRequest(imageArr[randNum][1]));
bwContainer.contentLoaderInfo.addEventListener(Event.COMPLETE, bwComplete);
bwContainer.load(new URLRequest(imageArr[randNum][0]));
function bwComplete(event:Event):void
{
bwContainer.content.mask = arrow_mc;
}
// MOUSE
Mouse.hide();
stage.addEventListener(MouseEvent.MOUSE_MOVE, followMouse);
function followMouse(evt:MouseEvent):void {
var dx:int = arrow_mc.x - mouseX;
var dy:int = arrow_mc.y - mouseY;
// EASE ON MOUSE
arrow_mc.x -= dx / 5;
arrow_mc.y -= dy /5;
}
// GO TO LINK - doesn't work
mouseover.addEventListener(MouseEvent.CLICK,ClickToGoToWebPage);
function ClickToGoToWebPage(event:MouseEvent):void {
navigateToURL(new URLRequest("http://www.copenhagen.dk"), "_blank");
}
Edit: After the 4 seconds, I got this code at the last frame:
stop();
addChild(colorContainer);
addChild(bwContainer);
If I am interpretting your design and problem correctly, using addChild places objects at the top of the display list, which would have them sitting over the mouseover. After adding the two image containers you should add the mouseover so that it sits above them.
stop();
addChild(colorContainer);
addChild(bwContainer);
addChild(mouseover);
North America
Europe, Middle East and Africa
Asia Pacific