kennylerma commented on issue #36: Slow Compiler Build Time
URL: https://github.com/apache/royale-compiler/issues/36#issuecomment-377042090
 
 
   This is actually something I've been wanting to look into.  I just haven't 
seen any documentation on how to create them.  This would vastly reduce export 
and compiling time.  Here's a quick example from Animate.
   ```javascript
   (function (cjs, an) {
   
   var p; // shortcut to reference prototypes
   var lib={};var ss={};var img={};
   lib.ssMetadata = [];
   
   
   // symbols:
   // helper functions:
   
   function mc_symbol_clone() {
        var clone = this._cloneProps(new this.constructor(this.mode, 
this.startPosition, this.loop));
        clone.gotoAndStop(this.currentFrame);
        clone.paused = this.paused;
        clone.framerate = this.framerate;
        return clone;
   }
   
   function getMCSymbolPrototype(symbol, nominalBounds, frameBounds) {
        var prototype = cjs.extend(symbol, cjs.MovieClip);
        prototype.clone = mc_symbol_clone;
        prototype.nominalBounds = nominalBounds;
        prototype.frameBounds = frameBounds;
        return prototype;
        }
   
   
   (lib.GreenCircle = function(mode,startPosition,loop) {
        this.initialize(mode,startPosition,loop,{});
   
        // Layer_1
        this.shape = new cjs.Shape();
        
this.shape.graphics.f("#00FF00").s().p("AojIkQjjjjAAlBQAAlADjjjQDjjjFAAAQFBAADjDjQDjDjAAFAQAAFBjjDjQjjDjlBAAQlAAAjjjjg");
        this.shape.setTransform(77.5,77.5);
   
        this.timeline.addTween(cjs.Tween.get(this.shape).wait(1));
   
   }).prototype = getMCSymbolPrototype(lib.GreenCircle, new 
cjs.Rectangle(0,0,155,155), null);
   
   
   // stage content:
   (lib.AnimateTest = function(mode,startPosition,loop) {
        this.initialize(mode,startPosition,loop,{});
   
        // Layer_1
        this.instance = new lib.GreenCircle();
        this.instance.parent = this;
        this.instance.setTransform(357.5,273.5,1,1,0,0,0,77.5,77.5);
   
        
this.timeline.addTween(cjs.Tween.get(this.instance).to({x:352.5,y:94.6},29).wait(1));
   
        // Layer_2
        this.shape = new cjs.Shape();
        this.shape.graphics.f("#000000").s().p("ArFK8IAA13IWLAAIAAV3g");
        this.shape.setTransform(121,107.1);
   
        this.timeline.addTween(cjs.Tween.get(this.shape).wait(30));
   
   }).prototype = p = new cjs.MovieClip();
   p.nominalBounds = new cjs.Rectangle(325.1,237.1,385,314);
   // library properties:
   lib.properties = {
        id: '75B8C1BBBE52AB4F9D57C9D574755C2B',
        width: 550,
        height: 400,
        fps: 24,
        color: "#FFFFFF",
        opacity: 1.00,
        manifest: [],
        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[i]);
                }
        }
   };
   
   an.compositions = an.compositions || {};
   an.compositions['75B8C1BBBE52AB4F9D57C9D574755C2B'] = {
        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[j](id);
        }
   }
   
   an.getComposition = function(id) {
        return an.compositions[id];
   }
   
   
   
   })(createjs = createjs||{}, AdobeAn = AdobeAn||{});
   var createjs, AdobeAn;
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to