Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
Ava

Error in Dreamweaver

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

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

Hi,

 

Thanks for your feedback. I really appreciate it a lot.

 

Best,

 

Ava

Share this post


Link to post
Share on other sites

Dreamweaver is using JsLint to check the potential errors within your javascript if your "TweenLite" or "TweenMax" syntax has errors you should put this lines to define it globally.

JavaScript

/* global TweenMax */
/* global TweenLite */

You can look here for more information!

http://www.jslint.com/help.html

  • Like 2

Share this post


Link to post
Share on other sites

Hi,

 

Thank you WarenGonzaga for your feedback.

This was really helpful.

 

Best,

Ava

Share this post


Link to post
Share on other sites

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

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. 


  • Recently Browsing   0 members

    No registered users viewing this page.

×