Exemple #1
0
        public Layer GetFreeLayer(Layer.Position position)
        {
            switch (position)
            {
            case Layer.Position.Front:
                Layer l = new Layer(this);
                this.LayerList.Add(l);
                return(l);

            case Layer.Position.Back:
            default:
                throw new SWFModellerException(
                          SWFModellerError.Internal,
                          "SWF::GetFreeLayer; " + position.ToString());
            }
        }
Exemple #2
0
        public void Instantiate(int frameNum, Sprite sprite, Layer.Position layering, Matrix position, string instanceName, string qClassName)
        {
            AS3Class instanceClass = sprite.Class;

            if (this.Class == null)
            {
                throw new SWFModellerException(
                          SWFModellerError.Internal,
                          "Can't instantiate " + instanceName + " on timeline with no code");
            }

            DoABC scriptTag = this.Root.FirstScript;

            if (scriptTag == null)
            {
                /* ISSUE 70: Y'know, we can generate scripts. We should probably do that. */
                throw new SWFModellerException(
                          SWFModellerError.Internal,
                          "Can't instantiate clips in a SWF with no code.");
            }

            if (instanceClass == null)
            {
                DoABC.GenerateDefaultScript(qClassName, sprite);
                instanceClass = sprite.Class;
            }

            /* Create instance variable of type referenced by instanceClass */

            Namespace propNS   = scriptTag.Code.CreateNamespace(Namespace.NamespaceKind.Package, string.Empty);
            Multiname propName = scriptTag.Code.CreateMultiname(Multiname.MultinameKind.QName, instanceName, propNS, NamespaceSet.EmptySet);

            if (this.Class is AS3ClassDef)
            {
                ((AS3ClassDef)this.Class).AddInstanceTrait(new SlotTrait()
                {
                    Kind     = TraitKind.Slot,
                    TypeName = instanceClass.Name,
                    Name     = propName,
                    ValKind  = ConstantKind.ConUndefined
                });
            }

            this.GetFrame(frameNum).AddTag(new PlaceObject(sprite, this.GetFreeLayer(layering), null, position, instanceName, false, null, null, null));
        }