Пример #1
0
 /// <summary>
 /// Initializes a new instance of the PlaceObject class as a display
 /// list instruction to put an item onto the stage.
 /// </summary>
 public PlaceObject(
     ICharacter character,
     Layer layer,
     int? clipDepth,
     Matrix matrix,
     string name,
     bool isMove,
     ColorTransform cxform,
     string className,
     int? ratio)
 {
     this.Character = character;
     this.ClipDepth = clipDepth;
     this.Matrix = matrix;
     this.Name = name;
     this.IsMove = isMove;
     this.CXForm = cxform;
     this.Layer = layer;
     this.ClassName = className;
     this.Ratio = ratio;
 }
Пример #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));
        }