Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. JavaScript
  4. Calling a function from within a function question

Calling a function from within a function question

Scheduled Pinned Locked Moved JavaScript
javascripthtmltoolsperformancehelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Calufrax12
    wrote on last edited by
    #1

    Hello. I am attempting to create a small app that rotates images, with buttons to stop, slow or speed up the animation, or to start/reset. The button functions work, but when they try to contact another function (setSpeed) or even use setTimeout or setInterval, those are ignored. Putting in other commands in those functions (e.g. window.alert("test") statements yields results, so I know it's doing something. Any help would be much appreciated...

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>Animation</title>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
    <script type="text/javascript">

    </script>
    </head>

    <body onload="startMe();">

    D T 2 Replies Last reply
    0
    • C Calufrax12

      Hello. I am attempting to create a small app that rotates images, with buttons to stop, slow or speed up the animation, or to start/reset. The button functions work, but when they try to contact another function (setSpeed) or even use setTimeout or setInterval, those are ignored. Putting in other commands in those functions (e.g. window.alert("test") statements yields results, so I know it's doing something. Any help would be much appreciated...

      <html xmlns="http://www.w3.org/1999/xhtml">
      <head>
      <title>Animation</title>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
      <script type="text/javascript">

      </script>
      </head>

      <body onload="startMe();">

      D Offline
      D Offline
      Dennis E White
      wrote on last edited by
      #2

      I am assuming that you are trying to change the image based on some interval that you can control via user input. The initial image is most likely coming up but not the other. The reason is because the second image has not been loaded. You can either write some code to load the image or you can "stack" the two images and control their visibility via a style/css setting that you adjust during your interval calls. Best of luck.

      you want something inspirational??

      1 Reply Last reply
      0
      • C Calufrax12

        Hello. I am attempting to create a small app that rotates images, with buttons to stop, slow or speed up the animation, or to start/reset. The button functions work, but when they try to contact another function (setSpeed) or even use setTimeout or setInterval, those are ignored. Putting in other commands in those functions (e.g. window.alert("test") statements yields results, so I know it's doing something. Any help would be much appreciated...

        <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
        <title>Animation</title>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
        <script type="text/javascript">

        </script>
        </head>

        <body onload="startMe();">

        T Offline
        T Offline
        thanh_bkhn
        wrote on last edited by
        #3

        Hi there, I think there is a problem when you call setSpeed(): You clear interval by calling

        clearInterval(myFx);

        This is the global myFx, but when you set a new interval, you return to a local variable

        var myFx = setInterval(doFx,y);

        If you remove the "var" in order to use the global myFx variable, the problem should be resolved.

        myFx = setInterval(doFx,y);

        C 1 Reply Last reply
        0
        • T thanh_bkhn

          Hi there, I think there is a problem when you call setSpeed(): You clear interval by calling

          clearInterval(myFx);

          This is the global myFx, but when you set a new interval, you return to a local variable

          var myFx = setInterval(doFx,y);

          If you remove the "var" in order to use the global myFx variable, the problem should be resolved.

          myFx = setInterval(doFx,y);

          C Offline
          C Offline
          Calufrax12
          wrote on last edited by
          #4

          Removing the redundant var fixed everything, I can't believe I hadn't noticed that... Thanks much!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups