I am using Adobe Animate to export a website and it gives me this folder:
My main file is this HelloWorld.html. The other HelloWorld.js gets generated by Animate and here is where all of my html objects get autogenerated (labels, buttons, etc).
Once I run it I get this
All I know is every time I make a design change to my website this HelloWorld.js file gets overwritten. Which is fine, I suppose. But, I do need access to these elements. All I am given to work with is the .html file:
<!DOCTYPE html>
<!--
NOTES:
1. All tokens are represented by '$' sign in the template.
2. You can write your code only wherever mentioned.
3. All occurrences of existing tokens will be replaced by their appropriate values.
4. Blank lines will be removed automatically.
5. Remove unnecessary comments before creating your template.
-->
<html>
<head>
<meta charset="UTF-8">
<meta name="authoring-tool" content="Adobe_Animate_CC">
<title>HelloWorld</title>
<!-- write your code here -->
<style>
#animation_container {
position:absolute;
margin:auto;
left:0;right:0;
top:0;bottom:0;
}
</style>
<script src="libs/1.0.0/createjs.min.js"></script>
<script src="HelloWorld.js"></script>
<script>
var canvas, stage, exportRoot, anim_container, dom_overlay_container, fnStartAnimation;
function init() {
canvas = document.getElementById("canvas");
anim_container = document.getElementById("animation_container");
dom_overlay_container = document.getElementById("dom_overlay_container");
var comp=AdobeAn.getComposition("8F022118589B1141A961E277C0AE693B");
var lib=comp.getLibrary();
var loader = new createjs.LoadQueue(false);
loader.addEventListener("fileload", function(evt){handleFileLoad(evt,comp)});
loader.addEventListener("complete", function(evt){handleComplete(evt,comp)});
var lib=comp.getLibrary();
loader.loadManifest(lib.properties.manifest);
}
function handleFileLoad(evt, comp) {
var images=comp.getImages();
if (evt && (evt.item.type == "image")) { images[evt.item.id] = evt.result; }
}
function handleComplete(evt,comp) {
//This function is always called, irrespective of the content. You can use the variable "stage" after it is created in token create_stage.
var lib=comp.getLibrary();
var ss=comp.getSpriteSheet();
var queue = evt.target;
var ssMetadata = lib.ssMetadata;
for(i=0; i<ssMetadata.length; i++) {
ss[ssMetadata[i].name] = new createjs.SpriteSheet( {"images": [queue.getResult(ssMetadata[i].name)], "frames": ssMetadata[i].frames} )
}
exportRoot = new lib.HelloWorld();
stage = new lib.Stage(canvas);
//Registers the "tick" event listener.
fnStartAnimation = function() {
stage.addChild(exportRoot);
createjs.Ticker.framerate = lib.properties.fps;
createjs.Ticker.addEventListener("tick", stage);
}
//Code to support hidpi screens and responsive scaling.
AdobeAn.makeResponsive(false,'both',false,1,[canvas,anim_container,dom_overlay_container]);
AdobeAn.compositionLoaded(lib.properties.id);
fnStartAnimation();
}
</script>
<!-- write your code here -->'
<script>
});
</script>
</head>
<body onload="init();" style="margin:0px;">
<div id="animation_container" style="background-color:rgba(0, 204, 153, 1.00); width:800px; height:600px">
<canvas id="canvas" width="800" height="600" style="position: absolute; display: block; background-color:rgba(0, 204, 153, 1.00);"></canvas>
<div id="dom_overlay_container" style="pointer-events:none; overflow:hidden; width:800px; height:600px; position: absolute; left: 0px; top: 0px; display: block;">
</div>
</div>
</body>
</html>
Inside the HelloWorld.js this is the function where my elements get created:
// stage content:
(lib.HelloWorld = function(mode,startPosition,loop,reversed) {
if (loop == null) { loop = true; }
if (reversed == null) { reversed = false; }
var props = new Object();
props.mode = mode;
props.startPosition = startPosition;
props.labels = {};
props.loop = loop;
props.reversed = reversed;
cjs.MovieClip.apply(this,[props]);
this.actionFrames = [0];
this.isSingleFrame = false;
// timeline functions:
this.frame_0 = function() {
if(this.isSingleFrame) {
return;
}
if(this.totalFrames == 1) {
this.isSingleFrame = true;
}
/* Button Click Event
Clicking on the specified button executes this function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
*/
if(!this.SendInfoButton_click_cbk) {
function SendInfoButton_click(evt) {
// Start your custom code
console.log("Button clicked");
alert('Click')
// End your custom code
}
$("#dom_overlay_container").on("click", "#SendInfoButton", SendInfoButton_click.bind(this));
this.SendInfoButton_click_cbk = true;
}
}
// actions tween:
this.timeline.addTween(cjs.Tween.get(this).call(this.frame_0).wait(1));
// Animation
this.instance = new lib.circleAnimation();
this.instance.setTransform(36.25,34.05,0.1804,0.1804);
this.timeline.addTween(cjs.Tween.get(this.instance).wait(1));
// Buttons
this.GetInfoButton = new lib.an_Button({'id': 'GetInfoButton', 'label':'Get Info', 'disabled':false, 'visible':true, 'class':'ui-button'});
this.GetInfoButton.name = "GetInfoButton";
this.GetInfoButton.setTransform(102.05,156.85,1,1,0,0,0,50,11);
this.SendInfoButton = new lib.an_Button({'id': 'SendInfoButton', 'label':'Send Info', 'disabled':false, 'visible':true, 'class':'ui-button'});
this.SendInfoButton.name = "SendInfoButton";
this.SendInfoButton.setTransform(102.05,106.05,1,1,0,0,0,50,11);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.SendInfoButton},{t:this.GetInfoButton}]}).wait(1));
// Lights_mc
this.Light_1 = new lib.Light_mc();
this.Light_1.name = "Light_1";
this.Light_1.setTransform(177.25,377.3,1,1,0,0,0,41.2,12.5);
this.Light_1_1 = new lib.Light_mc();
this.Light_1_1.name = "Light_1_1";
this.Light_1_1.setTransform(187.25,343.65,1,1,0,0,0,51.2,12.5);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.Light_1_1},{t:this.Light_1}]}).wait(1));
// Textfields
this.instance_1 = new lib.CachedBmp_5();
this.instance_1.setTransform(351.25,329.8,0.5,0.5);
this.textfield_1 = new cjs.Text("Text 1", "20px 'Arial'", "#FFFFFF");
this.textfield_1.name = "textfield_1";
this.textfield_1.lineHeight = 24;
this.textfield_1.lineWidth = 321;
this.textfield_1.parent = this;
this.textfield_1.setTransform(416.5,260.85);
this.textfield_2 = new cjs.Text("Text 2", "20px 'Arial'", "#FFFFFF");
this.textfield_2.name = "textfield_2";
this.textfield_2.lineHeight = 24;
this.textfield_2.lineWidth = 321;
this.textfield_2.parent = this;
this.textfield_2.setTransform(416.5,215.85);
this.textfield_3 = new cjs.Text("Text 3", "20px 'Arial'", "#FFFFFF");
this.textfield_3.name = "textfield_4";
this.textfield_3.lineHeight = 24;
this.textfield_3.lineWidth = 321;
this.textfield_3.parent = this;
this.textfield_3.setTransform(54.05,260.85);
this.instance_4 = new lib.CachedBmp_1();
this.instance_4.setTransform(233,28.6,0.5,0.5);
this.instance_5 = new lib.CachedBmp_2();
this.instance_5.setTransform(6.5,6.5,0.5,0.5);
this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.instance_5},{t:this.instance_4},{t:this.sendInfo_1_text},{t:this.sendInfo_2_text},{t:this.textfield_3},{t:this.textfield_4},{t:this.textfield_5},{t:this.textfield_6},{t:this.instance_3},{t:this.instance_2},{t:this.light_1_value},{t:this.light_2_value},{t:this.instance_1}]}).wait(1));
// outlines
this.shape = new cjs.Shape();
this.shape.graphics.f().s("#FFFFFF").ss(1,1,1).p("Eg4egH4MBw9AAAIAAPxMhw9AAAg");
this.shape.setTransform(401.475,134.55);
this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));
// Background
this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#0066CC").s().p("Eg+fAu4MAAAhdvMB8/AAAMAAABdvg");
this.shape_1.setTransform(400,300);
this.timeline.addTween(cjs.Tween.get(this.shape_1).wait(1));
this._renderFirstFrame();
}).prototype = p = new lib.AnMovieClip();
p.nominalBounds = new cjs.Rectangle(400,300,400,300);
// library properties:
lib.properties = {
id: '8F022118589B1141A961E277C0AE693B',
width: 800,
height: 600,
fps: 24,
color: "#000000",
opacity: 1.00,
manifest: [
{src:"images/HelloWorld_atlas_1.png", id:"HelloWorld_atlas_1"},
{src:"components/lib/jquery-3.4.1.min.js", id:"lib/jquery-3.4.1.min.js"},
{src:"components/sdk/anwidget.js", id:"sdk/anwidget.js"},
{src:"components/ui/src/button.js", id:"an.Button"}
],
preloads: []
};
I have tried to access the "Text 1" text field by writing the following inside the <script>
tags :
<script>
const demoId = document.getElementById('#textfield_1');
console.log(demoId);
</script>
but all I get is null when I check the console window which brings the initial question around: Given my current set up, how can I access a text field and change its value?