private void PlaceItem(PlaceObject po) { if (Content.Items.ContainsKey(po.Depth)) { return; } var character = Context.GetCharacter(po.Character, _sprite); var itemTransform = CreateTransform(po); DisplayItem displayItem; if (character is Playable) { displayItem = new SpriteItem(); } else if (character is Button) { displayItem = new ButtonItem(); } else { displayItem = new RenderItem(); } displayItem.Transform = itemTransform; displayItem.Create(character, Context, this); //add this object as an AS property if (po.Flags.HasFlag(PlaceObjectFlags.HasName)) { ScriptObject.Variables[po.Name] = Value.FromObject(displayItem.ScriptObject); displayItem.Name = po.Name; } if (po.Flags.HasFlag(PlaceObjectFlags.HasClipAction)) { if (po.ClipEvents != null) { foreach (var clipEvent in po.ClipEvents) { if (clipEvent.Flags.HasFlag(ClipEventFlags.Initialize)) { Context.Avm.Execute(clipEvent.Instructions, displayItem.ScriptObject, Character.Container.Constants.Entries); } } } } if (po.Flags.HasFlag(PlaceObjectFlags.HasClipDepth)) { displayItem.ClipDepth = po.ClipDepth; // TODO: Need to dispose this. displayItem.ClipMask = new RenderTarget(Context.Window.ContentManager.GraphicsDevice); } Content.AddItem(po.Depth, displayItem); }