Copy link to clipboard
Copied
I am using Animate as a Quick HTML editor that displays data from remote feeds. I am having issues with the Scope. My Code below:
Also I am using a external JS library for all of my gets and posts. This example I am using. https://code.jquery.com/jquery-3.3.1.min.js
var tl = this
//Slide1 and Slide2 are Key Frames on the same timeline. Slide1 = Frame 1 and Slide2 = Frame 2
$.get( "https://give.benevolentenabler.com/api/custom/totals/1", function( data ) {
if(data.raised.length > 0){
tl.theTime.text = "$" + data.raised;
tl.stop(); <-----Does Nothing. Keeps Playing.
}
else{
//"Do Something Else Like"
tl.gotoandstop('Slide2'); <-----Does Nothing. Keeps Playing.
}
})
I know i have to me missing something super simple.
Hi.
Also, please notice that should be gotoAndStop and not gotoandstop.
Regards,
JC
Copy link to clipboard
Copied
The usual stuff... have you alert'd or console.log'd inside your code to ensure that tl is actually set? Have you opened the developer console and checked for errors?
Copy link to clipboard
Copied
Yes. I have used Alerts. It is getting data it needs. Below works.
var tl = this
$.get( "https://give.benevolentenabler.com/api/custom/totals/1", function( data ) {
//alert(data.raised);
tl.theTime.text = "$" + data.raised;
})
tl.stop();
Copy link to clipboard
Copied
Hi.
Also, please notice that should be gotoAndStop and not gotoandstop.
Regards,
JC
Copy link to clipboard
Copied
I fixed the naming issues and it still ignores my if and else statements and continues to Slide to.
var tl = this
$.get( "https://give.benevolentenabler.com/api/custom/totals/1", function( data ) {
//alert(data.raised);
tl.theTime.text = "$" + data.raised;
alert(data.raised.length);
if(data.raised.length > 0){ <------This if statement is true and it does not stop the timeline. It continues to Frame 2.
tl.theTime.text = "$" + data.raised;
tl.stop();
}
else{ <------Do not think this is doing anything.
//"Do Something Else Like"
tl.gotoAndPlay('Slide2')
}
})
Find more inspiration, events, and resources on the new Adobe Community
Explore Now