A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS 3.0 Trouble. Can't link to a _self page, only _blank.

  1. #1
    Junior Member
    Join Date
    Sep 2009
    Posts
    7

    AS 3.0 Trouble. Can't link to a _self page, only _blank.

    How would I make this open in the same window instead of a blank popup window?

    //Navigate to some URL
    var urlRequest:URLRequest = new URLRequest("http://www.blah.com/links.php");
    navigateToURL(urlRequest);
    }

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    navigateToURL should open over the same frame the swf is loaded into unless you specify a target - if you're getting weird behavior with no target specified it's probably coming from elsewhere.
    Please use [php] or [code] tags, and mark your threads resolved 8)

  3. #3
    Junior Member
    Join Date
    Sep 2009
    Posts
    7

    Here's the rest of the code

    Would this help?

    //Import TweenMax
    import gs.*;

    //This array will contain all the rectangles
    var rectangles:Array = new Array();

    //Loop through the items in this movie clip
    for (var i:uint = 0; i < this.numChildren; i++) {

    //Get an object
    var object:* = this.getChildAt(i);

    //Check to see if the object is a MenuRectangle
    if (object is MenuRectangle) {

    //Save the rectangle's coordinates (we need these later on)
    object.origX = object.x;
    object.origY = object.y;

    //Add the rectangle to the rectangles array
    rectangles.push(object);
    }
    }


    //Add mouse listeners for the mouse area
    mouseArea.addEventListener(MouseEvent.MOUSE_OVER, mouseOverHandler);
    mouseArea.addEventListener(MouseEvent.MOUSE_OUT, mouseOutHandler);
    mouseArea.addEventListener(MouseEvent.CLICK, itemClicked);

    //This function is called when the cursor is over the mouse area
    function mouseOverHandler(e:Event):void {

    //Loop through the rectangle array
    for (var i:uint = 0; i < rectangles.length; i++) {

    //Assign the rectangle to a local variable
    var rectangle:MenuRectangle = rectangles[i] as MenuRectangle;

    //Calculate random target coordinates for the rectangle
    var randomX:Number = rectangle.x + 10 * Math.cos(Math.random() * Math.PI * 2);
    var randomY:Number = rectangle.y + 10 * Math.sin(Math.random() * Math.PI * 2);

    //Animate the rectangle to the random coordinates
    TweenMax.to(rectangle, 0.4, {x: randomX, y: randomY, alpha: 0.6, tint: Math.random() * 0xffffff});

    }

    //Add an ENTER_FRAME listener for the shake effect
    addEventListener(Event.ENTER_FRAME, shake);
    }

    //This function is called when the cursor moves out of the mouse area
    function mouseOutHandler(e:Event):void {

    //Loop through the rectangle array
    for (var i:uint = 0; i < rectangles.length; i++) {

    //Assign the rectangle to a local variable
    var rectangle:MenuRectangle = rectangles[i] as MenuRectangle;

    //Tween the rectangle to the original position
    TweenMax.to(rectangle, 0.4, {x: rectangle.origX, y: rectangle.origY, rotation: 0, alpha: 0.3, tint: 0xff8800});
    }

    //Remove the ENTER_FRAME listener (we don't want to shake the rectangle anymore)
    removeEventListener(Event.ENTER_FRAME, shake);
    }

    //This function is called when the mouse area is clicked
    function itemClicked(e:Event):void {

    //Navigate to some URL
    var urlRequest:URLRequest = new URLRequest("http://www.blah.com/links.php");
    navigateToURL(urlRequest);
    }


    function shake(e:Event):void {

    //Loop through the rectangles array
    for (var i:uint = 0; i < rectangles.length; i++) {

    //Assign the rectangle to a local variable
    var rectangle:MenuRectangle = rectangles[i] as MenuRectangle;

    //Rotate the rectangle a random amount (from -4 to 4)
    rectangle.rotation += Math.random() * 8 - 4;

    //Assign a new random position (from -4 to 4)
    rectangle.x+=Math.random()*8-4;
    rectangle.y+=Math.random()*8-4;
    }
    }

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    That code looks fine - try testing from within a web page off of the server - this sounds like the sandbox is doing something odd to me.
    Please use [php] or [code] tags, and mark your threads resolved 8)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center