Skip navigation
Currently Being Moderated

Adding url request to array

Sep 6, 2012 1:11 AM

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);

 
Replies
  • Currently Being Moderated
    Sep 6, 2012 4:22 AM   in reply to grimkarklud

    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);

     
    |
    Mark as:
  • Currently Being Moderated
    Sep 6, 2012 4:40 AM   in reply to grimkarklud

    You're welcome

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points