0

Here's the situation. I have the following line of code:

console.log(contents.storeShapes_mc.children[i]);

which prints out in the console like so:

lib.Store106II {id: 137, _matrix: a, _rectangle: a, children: Array[2], shape: a…}

I want to retrieve lib.Store106II to use in my JavaScript, but the console seems to be the one and only place I can get my hands on this particular string of data. Is there any way to access this information from inside the code?

Notes: (1) I am using content created in Flash, exported for EaselJS (2) Due to the syntax Toolkit for CreateJS implements, all of the advice in this answer does not help me, unfortunately.

Edit: Here is the javascript that "Toolkit for CreateJS" exported from Flash to create this object, along with dozens of similar objects:

(lib.Store106II = function() {
this.initialize();

// Layer 1
this.shape = new cjs.Shape();
this.shape.graphics.f().s("#DDE0CE").ss(1,0,0,4).p("AgGE4IEyjjIkfmLIk4Dlg");

this.shape_1 = new cjs.Shape();
this.shape_1.graphics.f("#A0A67C").s().p("AkrhRIE4jmIEfGMIkyDjg");

this.addChild(this.shape_1,this.shape);
}).prototype = p = new cjs.Container();
p.nominalBounds = new cjs.Rectangle(-30,-31.1,60.2,62.4);

/* some other code */

this.s106II = new lib.Store106II();    

/* s106II is eventually added as an element of storeShapes_mc 
which is in turn added as an element of contents */
Community
  • 1
  • 1
Steve Bird
  • 67
  • 1
  • 8

3 Answers3

0

I am assuming you are calling console.log from inside flash? If so you need to call a function from in flash and pass the function the data you want: contents.storeShapes_mc.children[i]

Then you store the data in a variable and that can be used to query the object and return whatever you need.

But will need an example of what you are using to get a better understanding.

--Edit--

Might have misunderstood slightly but if you're calling

console.log(contents.storeShapes_mc.children[i]);

can you not simply do the following:

var obj = contents.storeShapes_mc.children[i];
console.log(obj.id);
console.log(obj._matrix);
etc...
Eli Stone
  • 1,515
  • 4
  • 33
  • 57
  • I don't see any flash mentioned? – Christoph Dec 19 '13 at 14:10
  • 2
    `Notes: 1) I am using content created in Flash` – Eli Stone Dec 19 '13 at 14:11
  • another case of: you should not stop reading in the before the last paragraph;) – Christoph Dec 19 '13 at 14:15
  • @EliStone, thanks for your response, but I'm afraid I probably wasn't clear enough in my question. I used the "Toolkit for CreateJS" export tool in Flash, but I'm doing all my programming in javascript. Also, I can access `id`, `_matrix`, etc. That's not what I'm interested in. I'm interested in `lib.Store106II` which seems to only be accessible through the console. But I don't want it in the console, I want it within my javascript logic. Thanks. – Steve Bird Dec 19 '13 at 18:05
0

Your object has the following structure:

var contents = {
    "storeShapes_mc": {
        "children": [
            {
                "lib": {
                    "Store106II": {
                        "id": 137,
                        /* other stuff */
                    }
                }
            }, /* possibly other stuff*/
        ], /* possibly other stuff*/
    }
}

Now if you know the name of the properties lib and Store106II you can write:

var obj = contents.storeShapes_mc.children[0];

console.log(obj.lib); // to access Store106II 
// or something like this
console.log(obj.lib.Store106II.id);

Otherwise you have to iterate through the Object's properties and pick the one you think is the correct one.

If I misunderstood you, please tell me;)

Community
  • 1
  • 1
Christoph
  • 50,121
  • 21
  • 99
  • 128
  • I've edited the question to clarify my situation. I've included the javascript that defines this object. Thanks. – Steve Bird Dec 19 '13 at 18:15
0

With great thanks to fkranenburg on the CreateJS community support forums, I have found the answer to my question! http://community.createjs.com/discussions/easeljs/4568-is-there-a-way-to-retrieve-an-array-of-all-the-custom-classes-created-in-the-lib-namespace

    for ( libname in lib ) { 
        lib[libname].prototype.className = libname;
    }

This loop cycles through the lib namespace (you can do that, apparently!) and retrieves the names of all the constructors created in that namespace. Then, using dynamic referencing (aka square bracket notation, aka array notation) I reference each constructor in that namespace by name and access its prototype to add a new property named className to objects created by that constructor which returns the name of the object's constructor!

Steve Bird
  • 67
  • 1
  • 8