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

How can i get the id of the canvas?

Explorer ,
Jun 27, 2017 Jun 27, 2017

HI,thans you help first!

for example:

lib.properties = {

  id: '054D1722FC18B043A207F8FDCA4D6A20',

  width: 1024,

  height: 768,

  fps: 12,

  color: "#FFFFFF",

  opacity: 1.00,

  manifest: [

  {src:"images/_1.jpg?1498542790116", id:"_1"}

  ],

  preloads: []

};

we can get the lib like this:

var comp=AdobeAn.getComposition("054D1722FC18B043A207F8FDCA4D6A20");

var lib=comp.getLibrary();

but ,if i don't know the id,so i can't get the id like above.

so how can it do it ?

thanks !

7.4K
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 1 Correct answer

LEGEND , Jul 12, 2017 Jul 12, 2017

Huh, who would have thought Adobe would decide to complicate the Animate CC API by inflicting Edge's "compositions" concept on it.

Well anyway, this isn't that hard. Just do:

var lib = AdobeAn.getComposition(Object.keys(AdobeAn.compositions)[0]).getLibrary();

Err, okay that is a little dense. Broken down into a multi-liner, the above would be:

var key = Object.keys(AdobeAn.compositions)[0];

var comp = AdobeAn.getComposition(key);

var lib = comp.getLibrary();

Object.keys is a method supported by newer b

...
Translate
LEGEND ,
Jun 28, 2017 Jun 28, 2017

It looks like lib.properties is being set to an object, which would make the id be lib.properties.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
Explorer ,
Jun 28, 2017 Jun 28, 2017

I'm sorry, may I didn't fully describe the problem. The new version of the animation CC export HTML JS files changed, I don't want to go to edit export documents. How to get the id number in the lib.

new animation cc add bootstrap callback support,and export the JS files like this:

(function (cjs, an) {

var p; // shortcut to reference prototypes

var lib={};var ss={};var img={};

lib.ssMetadata = [];

// symbols:

// stage content:

// library properties:

lib.properties = {

  id: '054D1722FC18B043A207F8FDCA4D6A20',

  width: 1024,

  height: 768,

  fps: 12,

  color: "#FFFFFF",

  opacity: 1.00,

  manifest: [

  {src:"images/_1.jpg?1498542790116", id:"_1"}

  ],

  preloads: []

};

// bootstrap callback support:

(lib.Stage = function(canvas) {

  createjs.Stage.call(this, canvas);

}).prototype = p = new createjs.Stage();

p.setAutoPlay = function(autoPlay) {

  this.tickEnabled = autoPlay;

}

p.play = function() { this.tickEnabled = true; this.getChildAt(0).gotoAndPlay(this.getTimelinePosition()) }

p.stop = function(ms) { if(ms) this.seek(ms); this.tickEnabled = false; }

p.seek = function(ms) { this.tickEnabled = true; this.getChildAt(0).gotoAndStop(lib.properties.fps * ms / 1000); }

p.getDuration = function() { return this.getChildAt(0).totalFrames / lib.properties.fps * 1000; }

p.getTimelinePosition = function() { return this.getChildAt(0).currentFrame / lib.properties.fps * 1000; }

an.bootcompsLoaded = an.bootcompsLoaded || [];

if(!an.bootstrapListeners) {

  an.bootstrapListeners=[];

}

an.bootstrapCallback=function(fnCallback) {

  an.bootstrapListeners.push(fnCallback);

  if(an.bootcompsLoaded.length > 0) {

  for(var i=0; i<an.bootcompsLoaded.length; ++i) {

  fnCallback(an.bootcompsLoaded);

  }

  }

};

an.compositions = an.compositions || {};

an.compositions['054D1722FC18B043A207F8FDCA4D6A20'] = {

  getStage: function() { return exportRoot.getStage(); },

  getLibrary: function() { return lib; },

  getSpriteSheet: function() { return ss; },

  getImages: function() { return img; }

};

an.compositionLoaded = function(id) {

  an.bootcompsLoaded.push(id);

  for(var j=0; j<an.bootstrapListeners.length; j++) {

  an.bootstrapListeners(id);

  }

}

an.getComposition = function(id) {

  return an.compositions[id];

}

})(createjs = createjs||{}, AdobeAn = AdobeAn||{});

var createjs, AdobeAn;

old animation cc export the JS files like this:

(function (lib, img, cjs, ss, an) {

//content;}

})(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{}, AdobeAn = AdobeAn||{});

var lib, images, createjs, ss, AdobeAn;

so,old version we can get lib.properties,but new version lib is not defined.

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
LEGEND ,
Jul 06, 2017 Jul 06, 2017

I tried what I suggested earlier, this:

alert(lib.properties.id);

shows the id of the lib. Does that not work for 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 Beginner ,
Jul 07, 2017 Jul 07, 2017

Hi Colin!

Yes, it's working but not before the library is fetched:

var comp=AdobeAn.getComposition("054D1722FC18B043A207F8FDCA4D6A20"); 

var lib=comp.getLibrary(); 

..with the same auto-generated id string.

So if you have a situation (with custom publishing templates for example) where you don't have the id, you have no way of getting the library, which is not good practise in my opinion.

You should at least have some kind of getCompositionID or getLibraryID function without any auto-generated hash.

br, eero

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 ,
Sep 28, 2017 Sep 28, 2017
LATEST

The id number in the lib properties and the all of the bootstrap callback support on export is screwing everything up for me when I go back and export old files. Why do this? There is no way to turn this option off in Animate.

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
LEGEND ,
Jun 28, 2017 Jun 28, 2017

This is an Edge Animate question, not Animate CC.

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
LEGEND ,
Jun 28, 2017 Jun 28, 2017

I did wonder why someone was doing things the hard way! My answer is probably still good though. Should we move this to Edge Animate, if there is still a forum for it?

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
LEGEND ,
Jun 28, 2017 Jun 28, 2017

It's not that it's the hard way, it's more the completely inapplicable way. There is no such function as getComposition() in Animate CC. That's an Edge function.

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
LEGEND ,
Jun 28, 2017 Jun 28, 2017

https://forums.adobe.com/people/Colin+Holgate  wrote

Should we move this to Edge Animate, if there is still a forum for it?

The Edge Animate forum is here: Edge Animate CC

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
Explorer ,
Jul 12, 2017 Jul 12, 2017

HI,this is animate cc question,so should we move this to animate cc? thanks !

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
LEGEND ,
Jul 12, 2017 Jul 12, 2017

I think so. Many people will have read both, but it would be good to see if Adobe Animate users have ideas. I'll move it.

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
LEGEND ,
Jul 12, 2017 Jul 12, 2017

Huh, who would have thought Adobe would decide to complicate the Animate CC API by inflicting Edge's "compositions" concept on it.

Well anyway, this isn't that hard. Just do:

var lib = AdobeAn.getComposition(Object.keys(AdobeAn.compositions)[0]).getLibrary();

Err, okay that is a little dense. Broken down into a multi-liner, the above would be:

var key = Object.keys(AdobeAn.compositions)[0];

var comp = AdobeAn.getComposition(key);

var lib = comp.getLibrary();

Object.keys is a method supported by newer browsers that returns an array of all the keys (property names) on an object. Assuming an Animate project only has a single "composition", the code above just grabs the first element of the keys array.

Wait... so this means Animate 2017 no longer populates the lib global, which means they just broke every single project that uses bla = new lib.linkageName to instantiate objects from the library. My god.

I'd be submitting an angrily-worded bug report to Adobe regarding this. At the very least there should be a less obtuse method for pages to access their own library. This is looking like Adobe actively trying to discourage developers from using the library object.

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
Explorer ,
Jul 13, 2017 Jul 13, 2017

thanks  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
Explorer ,
Jul 22, 2017 Jul 22, 2017

Great ​ - That works perfect!!

Is there any way to reference a specific js file when using these?

For example I load...

<script src="canvas1.js"></script>

<script src="canvas2.js"></script>

And want to load both without knowing the composition ID - Is anything like this possible:

var lib = AdobeAn.getComposition(Object.keys(canvas1.AdobeAn.compositions)[0]).getLibrary();

canvas1.AdobeAn.compositions or canvas2.AdobeAn.compositions

Or any way to reference which file you want to get the composition ID for?


Thanks for any help!

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
LEGEND ,
Jul 23, 2017 Jul 23, 2017

There is no such concept as "files" in JavaScript variable referencing. If you're trying to smash two Animate movies into the same HTML document, it's your responsibility to rename all the global variables so the two movies don't conflict with each other. If you know enough to do that, you'll by default know enough to modify the above code, which directly accesses one of those global variables.

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 Beginner ,
Jul 06, 2017 Jul 06, 2017

Hi,

this is indeed Animate CC question, as xu zhang suggested, the structure of library and the way to call it have changed since June 2017 release.

br, eero

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