Struggle with Javascript
September 28, 2021
Struggle with Javascript
September 28, 2021
Newbie 1 posts
Followers: 0 people

Hi all,

I am a newbie on Javascript. Got inspired by Greg Stager during last week’s Adobe EL World 2021. And now I want more 🙂 !!

In my project I control an object via Javascript: I can rotate that object while pressing buttons. It’s like a compass pin: per click it rotates 9 degrees. No problem.

What I want is that these degrees are shown in Cp. Neither a problem since  I declared a Cp-variable that contains the value of the rotation in degrees after each button press.

But now I want to know the contents of that Cp-variable string on “character level”. That string can contain 1 character (like 9 degrees), two (like 45 degrees) or at a max 3 characters (like 351 degrees). Stated differently: I want to know if the string contains 3, 2 or 1 characters + what is the contents of the 1st, 2nd and 3rd character.

I tried to do that with the Javascript command charAt(). But there’s no output in Cp, nor an error message. I tested my solution in a free Javascript editor website: no error.

Objective:

I want the degrees being projected as digital numbers (0-9), which are separate pictures of digits. For each position (max 3) I planned to use an object with 10 states (10 small pictures of digits from 0 to 9). So in total 3 objects of the samen kind. When I know what number is on each spot in the string, then I can change the object state to that specific number.

I assume the “non responding Javascript” in Cp has something to do with the fact that the Cp-Variable string length is not constant: it grows from 1 character -> 2 characters -> 3 characters max. But my Js knowledge and definitely my Js skills are poor…

Who wants to help me??

Thanks in advance!!!Play

All Comments
Sort by:  Most Recent
Nov 23, 2021
Nov 23, 2021

great question, thank you for posting!

Like
()
Oct 16, 2021
Oct 16, 2021

In general, you should only use JS when it cannot be done in Captivate.

Like
()
(2)
Nov 3, 2021
Nov 3, 2021
>
cferran1
's comment

I agree

Like
()
Nov 3, 2021
Nov 3, 2021
>
cferran1
's comment

It seems a couple of you are in agreement with this statement.

I would ask you to provide some reasons for why you believe this to be true.

Like
()
Oct 2, 2021
Oct 2, 2021

I should really learn Java. Seems fun!

Like
(2)