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

Adobe Animate HTML 5 Error when accessing internal library via external js script

New Here ,
Aug 24, 2023 Aug 24, 2023

Recently started learning Javascript and here is the problem When trying to access the internal Adobe Animate library through an external JS script, it swears and writes an error And if I write this script inside Adobe Animate it works fine, please help

 

let myBlue = new lib.blueShape;
exportRoot.addChild(myBlue);
let xPosition = Math.floor(Math.random()*700);
let yPosition = Math.floor(Math.random()*700);
myBlue.x = xPosition;
myBlue.y = yPosition;
root.push(myBlue);

 throws an error on - let myBlue = new lib.blueShape;

 

1.jpgexpand image

1.3K
Translate
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

correct answers 2 Correct answers

Community Expert , Aug 25, 2023 Aug 25, 2023

1. remove your js file from the include panel

2. use code to reference your library (and you'll need the main timeline, too)

3. load your js with code

 

// don't use "var"

tl = this;  // main timeline reference
LIB = lib;  // library reference

 

// load your js file(s)
var queue = new createjs.LoadQueue();
queue.loadManifest([
"ext_file.js"
]);

 

in ext_file.js you can use:

 

let myBlue=new LIB.blueShape();

tl.addChild(myBlue);

Translate
Community Expert , Aug 25, 2023 Aug 25, 2023

i showed you how to do that

 

in your fla

 

// don't use "var"

tl = this;  // main timeline reference
LIB = lib;  // library reference

 

// load your js file(s)
var queue = new createjs.LoadQueue();
queue.loadManifest([
"ext_file.js"
]);

 

 

in your external js file

 

let myBlue=new LIB.blueShape();

tl.addChild(myBlue);

Translate
Community Expert ,
Aug 24, 2023 Aug 24, 2023

you have to wait until the library is initialized to access it. 

 

and that should be

 

new lib.blueShape();

Translate
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 24, 2023 Aug 24, 2023

Thanks for the reply, but it still gives the same error.

2.jpgexpand image

Translate
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
Community Expert ,
Aug 24, 2023 Aug 24, 2023

you still have a timing issue.  and then you'll need a lib reference.

Translate
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 25, 2023 Aug 25, 2023

Sorry for my bad English, maybe I don't understand something, how can I write a script correctly?

Translate
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
Community Expert ,
Aug 25, 2023 Aug 25, 2023

1. remove your js file from the include panel

2. use code to reference your library (and you'll need the main timeline, too)

3. load your js with code

 

// don't use "var"

tl = this;  // main timeline reference
LIB = lib;  // library reference

 

// load your js file(s)
var queue = new createjs.LoadQueue();
queue.loadManifest([
"ext_file.js"
]);

 

in ext_file.js you can use:

 

let myBlue=new LIB.blueShape();

tl.addChild(myBlue);

Translate
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 25, 2023 Aug 25, 2023

var queue = new createjs.LoadQueue(); queue.loadManifest([ "ext_file.js" ]); This is how I add the code well, I need something from the ext_file.js file to access the Adobe Animate library, and not from the timeline

 

Translate
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
Community Expert ,
Aug 25, 2023 Aug 25, 2023

i showed you how to do that

 

in your fla

 

// don't use "var"

tl = this;  // main timeline reference
LIB = lib;  // library reference

 

// load your js file(s)
var queue = new createjs.LoadQueue();
queue.loadManifest([
"ext_file.js"
]);

 

 

in your external js file

 

let myBlue=new LIB.blueShape();

tl.addChild(myBlue);

Translate
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 25, 2023 Aug 25, 2023

 It's my fault, everything works, thank you very much!

Translate
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
Community Expert ,
Aug 25, 2023 Aug 25, 2023

you're welcome 

Translate
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 25, 2023 Aug 25, 2023

 Sorry for another question, although it is not on the local topic. Here's how to make an object from the scene added to an array, so that my platforms would have the same properties, so that I would not write each platform separately in actionscrip 3.0 it looked like this

var list_platforms: Array = new Array();

init();
function init(){
for (var i:uint = 0; i < numChildren; i++){
if (getChildAt(i) is Platform){
list_platforms.push(getChildAt(i));
}

how will it look like in js?

Translate
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
Community Expert ,
Aug 26, 2023 Aug 26, 2023

are you trying to find the linkage id of objects, or how to use arrays?

Translate
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 26, 2023 Aug 26, 2023

 I want to copy movie clips on the canvas, for example platforms, so that they would be under the same name and that they would have one property, so that I wouldn’t call each platform like platform 1, platform 2 and so on, of course you can’t understand what I want to explain

Translate
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
Community Expert ,
Aug 26, 2023 Aug 26, 2023

you're still talking about html5/canvas, correct?

 

is Platform a linkage id and you're trying to find instances with that linkage id?

Translate
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 26, 2023 Aug 26, 2023

Yes, on actionscrip 3.0 the script looked like this

var list_platforms: Array = new Array();

init();
function init(){
for (var i:uint = 0; i < numChildren; i++){
if (getChildAt(i) is Platform){
list_platforms.push(getChildAt(i));
}

On js, I don’t know how it is written, the script indicates that when copying the platform, it automatically adds to the array, thereby one name from the library for all copied objects

Translate
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
Community Expert ,
Aug 26, 2023 Aug 26, 2023

you can find the linkage name using the following, but how to compare that to something needs more work:

 

getMCSymbolPrototype(this.getChildAt(i)).constructor

Translate
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 26, 2023 Aug 26, 2023

 I suspected that through the constructor, well, what does the script look like in full?

Translate
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
Community Expert ,
Aug 26, 2023 Aug 26, 2023

init();
function init(){
for (var i = 0; i < numChildren; i++){
console.log(getMCSymbolPrototype(this.getChildAt(i)).constructor);

}

Translate
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 26, 2023 Aug 26, 2023

 I can’t understand this script, I will try to do something, thanks for the answer, I won’t bother you

Translate
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
Community Expert ,
Aug 26, 2023 Aug 26, 2023

use the script and open the developer console when testing.

Translate
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 27, 2023 Aug 27, 2023

Yes, I do that, but it gives an error in the console

Translate
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
Community Expert ,
Aug 27, 2023 Aug 27, 2023

what error?

 

kglad_0-1693144830136.pngexpand image

 

 

kglad_1-1693144878207.pngexpand image

 

Translate
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 27, 2023 Aug 27, 2023

I don’t understand why I had an error, I didn’t write the way you wrote to me the first time, now it displays to me without an error, well, I don’t understand how I can add a property now, well, for example, so that when you click the mouse they disappear

Translate
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
Community Expert ,
Aug 27, 2023 Aug 27, 2023

you're trying to add a property to what?

Translate
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 27, 2023 Aug 27, 2023

Here to these objects in the C_link library so that they have one function, for example, these are coins, when pressed, they disappear 

Translate
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