• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Use javascript in the exported html file to edit a variable in the javascript canvas file.

New Here ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Hi,
 
This is my first post here. I hope someone can help?
 
I am familiar with Javascript and Animate. 
 
I have an animate file that I have exported (it is a canvas) and I would like to write some javascript within the html file that can change something in the javascript file.
 
Specifically:

I want to edit the reference to "l3" below to "l1" or "l2" on the fly from javascript within my html file.


// stage content:
(lib.fileName = function(mode,startPosition,loop) {
this.initialize(mode,startPosition,loop,{});

// timeline functions:
this.frame_30 = function() {
exportRoot.text.line.gotoAndStop(0);
exportRoot.text.textBlueBG.gotoAndStop("l3");
exportRoot.text.textWhiteBG.gotoAndStop("l3");


}


Any tips or refences to documentations would be great.

 

Thank you.


 

Views

136

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

Why are you publishing as separate HTML and JS files? There's practically never any reason not to publish with them merged into a single HTML file.

 

Well anyway, once everything's loaded there's no concept of separate files since everything occupies the same browser namespace. So just replace your hard-coded strings with something like exportRoot.myLabel (exportRoot is a global reference to the root timeline) and make sure it's initialized to a default value somewhere. Then you can change it at will in any other code.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 12, 2020 Aug 12, 2020

Copy link to clipboard

Copied

LATEST

Thank you for your help.

 

I have just replaced my "l3" "l2" "and "l1" references with a variable outside the abode animate code and it works great.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines