/// <summary> /// Generates the timeline scripts. /// </summary> public void GenerateTimelineScripts() { if (this.scripts.Count != 0) { throw new SWFModellerException( SWFModellerError.Internal, "Internal error. Can't make auto-generated scripts if scripts already exist."); } string flaName = this.Context.Name.Replace('.', '_') + "_swiffotron"; string qualClassName = flaName + ".MainTimeline"; this.scripts.Add(DoABC.GenerateDefaultScript(qualClassName, this)); }
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)); }