adding event listener (go to url)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • anagiga
    New Member
    • Apr 2010
    • 3

    #1

    adding event listener (go to url)

    I am developing a page in html. I have a div which is playing a flash video. After the flash video stops, I want to take the user to a different url in the same window.
    I tried this function but it doesn't work:
    Code:
    <script type="text/javascript">
    
    function onVideoStopped(evt:VideoEvent):void
    {
        var url:URLRequest = new URLRequest("http://google.com");
        navigateToURL(url, "_self");
    }
    </script>
    Any suggestions???
    THANKS!!!!!
    Last edited by Dormilich; Apr 21 '10, 01:55 AM. Reason: Please use [code] tags when posting code
  • anagiga
    New Member
    • Apr 2010
    • 3

    #2
    I will next time, do you have any suggestions on how to fix the code?
    Thanks!

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #3
      I don’t know, what code it is, but it is not JavaScript.

      JavaScript is a loosely typed language, so the stuff with the colon (which I suspect as type hinting) should throw errors.

      even without that, there are problems
      Code:
      <script type="text/javascript">
      function onVideoStopped(VideoEvent)
      {
      // URLRequest is not defined
      // any new call "new URLRequest()" will use the local variable and thus fail (in most cases)
          var URLRequest = new URLRequest("http://google.com");
      // navigateToUrl() is not defined
      // url is not defined
          navigateToURL(url, "_self");
      }
      </script>
      event listeners are defined using the addEventListene r() method (at least where DOM is concerned).

      onVideoStopped is not a HTML event.

      but I don’t know, how the flash implementation of JavaScript works, so you better ask in the Flash Forum.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        do you have any suggestions on how to fix the code?
        not with 'standard' JavaScript (JavaScript used in HTML)

        Comment

        • anagiga
          New Member
          • Apr 2010
          • 3

          #5
          I am a new developer, so I am just beginning to learn javascript. I come from a flash background. I want to write a function in javascript if possible, not in actionscript. I need to add an event listener to a video after it has played. Can I do that in javascript?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            the problem will be to tell, when the video finished playing, since playing a video is nothing HTML is concerned about. you would need the video object dispatching an event, to do something with JavaScript.

            Comment

            Working...