Jump to content
Search Community

Error in Dreamweaver

Ava test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

Hi,

 

I have used this script to animate a loop. The end animation look fine and everything seems to work.

But when i open the JS file with Adobe Dreameweaver I get many complaints (missing semicolon,
’text2’ is not defined, and missing ’used strict’ statement). Do I need to be worried?

 

Best,

Ava

 

window.onload = function () {
    var tl = new TimelineMax({repeat:-1});

    loop = 0;
    loopMax = 3;


     tl.to(text1, 1.2, {top:0,opacity:1,ease:Power4.easeOut})
    .to(text1, 1.2, {delay:.6,top:600,ease:Power4.easeIn})
    .to(text1, 0, {top:-600,ease:Power4.easeOut})

    .to(text2, 1.2, {top:0,opacity:1,ease:Power4.easeOut})

    .from(text3, 1, {top:0, opacity:0,scale:0,ease:Bounce.easeOut})
    .call(loopCheck)
    .to(text3, 0.5, {delay:1.2,opacity:0,scale:0,ease:Power4.easeOut})
    .to(text2, 1.2, {top:600,ease:Power4.easeIn})

tl.timeScale(1)

function loopCheck() {
  console.log("loopCheck")
     loop++;
     if (loop < loopMax) {
        console.log("play again")
        tl.play();
     } else{
       console.log("done")
       tl.pause();
     }

}
}
 

post-46218-0-49174000-1472025111_thumb.jpg

Link to comment
Share on other sites

Hi Ava,

 

Welcome to the Greensock forums!

 

While your code would work, Dreamweaver is just advising you that there could potentially be problems. A lot of these you will learn as you progress through your learning of Javascript. 

 

Tools like http://jshint.com/ and http://eslint.org/ will help with writing better quality Javascript.

 

Below is an example of what would clear those errors, I've defined your variables, and hoisted the loopCheck function to before it gets called.

window.onload = function () {
    var tl = new TimelineMax({ repeat: -1 });
    var loop = 0;
    var loopMax = 3;

    var text1 = document.getElementById('text1');
    var text2 = document.getElementById('text2');
    var text3 = document.getElementById('text3');

    function loopCheck() {
      console.log('loopCheck')
      loop++;
      if (loop < loopMax) {
        console.log('play again')
        tl.play();
      } else{
        console.log('done')
        tl.pause();
      }
    }

    tl.to(text1, 1.2, {top:0,opacity:1,ease:Power4.easeOut})
      .to(text1, 1.2, {delay:.6,top:600,ease:Power4.easeIn})
      .to(text1, 0, {top:-600,ease:Power4.easeOut})
      .to(text2, 1.2, {top:0,opacity:1,ease:Power4.easeOut})
      .from(text3, 1, {top:0, opacity:0,scale:0,ease:Bounce.easeOut})
      .call(loopCheck)
      .to(text3, 0.5, {delay:1.2,opacity:0,scale:0,ease:Power4.easeOut})
      .to(text2, 1.2, {top:600,ease:Power4.easeIn});

    tl.timeScale(1);
}
  • Like 3
Link to comment
Share on other sites

  • 3 weeks later...
  • 2 weeks later...
  • 3 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...