A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: new URLRequest not working

Hybrid View

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    3

    new URLRequest not working

    Hi all, I've scoured around looking for a solution to this problem, but I cannot ascertain why the code for one set of navigation buttons I've created works, but similar code does not. The code is rather lengthy, but I've pulled out the salient components to see if the Interwebs could help.

    I'm new, so I'm not even sure I'm framing the question properly (read: be gentle), but I'd really appreciate the help.

    Here's the script that IS working:

    Listener code:

    Code:
    cswordbutton.addEventListener(MouseEvent.CLICK,fetchcswordassets);
    And the function code that goes with it:

    Code:
    function fetchcswordassets(e:MouseEvent):void{
      var url:String = "knowntomeURL";
      var request:URLRequest = new URLRequest(url);
      try {
        navigateToURL(request, '_blank');
      } catch (e:Error) {
        trace("Error occurred!");
      }
    }
    And here's a snippet of code that isn't working:

    Listener Code:

    Code:
    commwordbutton.addEventListener(MouseEvent.CLICK,fetchcommwordassets);
    Function Code:

    Code:
    function fetchcommwordassets(e:MouseEvent):void{
      var url:String = "knowntomeURL2";
      var request:URLRequest = new URLRequest(url);
      try {
        navigateToURL(request, '_blank');
      } catch (e:Error) {
        trace("Error occurred!");
      }
    }
    Other (potentially useful) clues:

    1) All of the actions are in a separate layer in the first frame;
    2) There is only one scene;
    3) I've given the same button a different instance name in many cases, to coincide with different expectations (URLs).

    Can anyone lend a hand to a complete *******?

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    what is happening ? Are you getting errors from the debugger ? Is that trace firing off from your try method ? Have you tried putting just a trace in the event handler for the button to see if its making it to , fetchcommwordassets() ? Have you tried renaming you vars , like request -> request2 , url -> url2 ? More info please.

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    AttackRabbit - no, I'm not getting any errors in the debugger, and I've never worked with traces before. I'll try renaming the variables and see if that helps. The buttons simply do not do anything.

    If you could shed any light on tracers for me, that'd be cool, but I'll poke around more too.

    Thanks.

  4. #4
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    A trace is what you have in your error handle statement.

    Code:
    trace("error occured");
    its just a global method in flash , that tells the application to output to a debug window. If you are testing in the flash ide , you should see traces in your ouput window. If you are testing through a localhost or on a remote server , you would need to use something like flash tracer , or a different debugger , like demonster , to see output. But at any rate , what exactly does happen when you click your button ? Does nothing at all happen ?

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    3
    Thanks Attack, I've solved the problem. What happened was I put all of the event listeners in the first frame of the movie, but the buttons did not exist on the timeline yet. When I put the event listeners in the frame matching the instances of the buttons, all worked great.

    Thanks again, I'm learning this stuff --- slowly.

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