2 Replies Latest reply on Oct 11, 2016 8:36 PM by xu zhang

    How to use JS to get the movieclip in the canvas?

    xu zhang Level 1

      HI ,

      look this example code:

      JS of the canvas:

      (function (lib, img, cjs, ss) {
      var p; // shortcut to reference prototypes
      // library properties:
      lib.properties = {
      width: 550,
      height: 400,
      fps: 24,
      color: "#FFFFFF",
      opacity: 1.00,
      manifest: []
      };
      lib.ssMetadata = [];
      // symbols:
      (lib.mc = function(mode,startPosition,loop) {
      this.initialize(mode,startPosition,loop,{});
      // ss 1
      this.shape = new cjs.Shape();
      this.shape.graphics.f().s("#FFFFFF").ss(1,1,1).p("ApwmjIThAAIAANHIzhAAg");
      this.shape.setTransform(62.5,42);
      this.shape_1 = new cjs.Shape();
      this.shape_1.graphics.f("#FF0000").s().p("ApwGjIAAtGIThAAIAANGg");
      this.shape_1.setTransform(62.5,42);
      this.timeline.addTween(cjs.Tween.get({}).to({state:[{t:this.shape_1},{t:this.shape}]}).wait(1));
      }).prototype = p = new cjs.MovieClip();
      p.nominalBounds = new cjs.Rectangle(-1,-1,127,86);
      
      // stage content:
      (lib.mymc = function(mode,startPosition,loop) {
      this.initialize(mode,startPosition,loop,{});
      // mc
      this.mc = new lib.mc();
      this.mc.setTransform(215.5,167.1,1,1,0,0,0,62.5,42);
      this.timeline.addTween(cjs.Tween.get(this.mc).wait(1));
      }).prototype = p = new cjs.MovieClip();
      p.nominalBounds = new cjs.Rectangle(427.5,324.6,126,85);
      })(lib = lib||{}, images = images||{}, createjs = createjs||{}, ss = ss||{});
      var lib, images, createjs, ss;
      

       

       

      html:

      <body>
      <canvas id='canvas'></canvas>
      </body>
      <script>
      alert('lib.properties.fps')
      </script>
      

       

      my question:

      the canvas has a movieclip named 'mc'.

      how can i alert the "mc" as alert the "lib.properties.fps"?

      alert('lib.mymc')//success
      alert('lib.mc')//success,but it is library ,Not in the scene
      alert('lib.mymc.mc')//undefined,how do it?
      
      

      THANKS VERY MUCH!!