Example #1
0
        internal bool SetPlacement(PlaceObject2Tag tag, StageObject parent)
        {
            bool load = false;

            // TODO: Morph ratio
            if (tag.HasCxForm) CxForm = tag.CxForm;
            if (tag.HasMatrix) Matrix = new VGMatrix(tag.Matrix);
            if (tag.HasCharacter)
            {
                var character = parent.Root.Document[tag.CharacterID];
                if (character == null) return false;

                var newInstance = character.MakeInstance(this, parent.Root);
                if (newInstance == null) return false;

                Removed();
                Character = character;
                Object = newInstance;
                Object.SetParent(parent);
                load = true;
            }

            if (tag.HasClipDepth) ClipDepth = tag.ClipDepth;
            if (Object is IInstanceable)
            {
                var obj = Object as IInstanceable;
                if (tag.HasName) obj.SetName(tag.Name);
                if (tag.HasActions) obj.SetClipActions(tag.Actions);
                if (load) obj.Load();
            }

            return Object != null;
        }
Example #2
0
        public void Set(PlaceObject2Tag tag, MovieClip clip)
        {
            DisplayObject obj;

            var n = _displayList.Last;
            for (; n != null && n.Value.Depth > tag.Depth; n = n.Previous) ;

            if (n == null)
            {
                obj = DisplayObject.CreateAndPlace(tag, clip);
                if (obj != null) _displayList.AddFirst(obj);
                return;
            }

            if (n.Value.Depth == tag.Depth)
            {
                if (!n.Value.SetPlacement(tag, clip))
                    _displayList.Remove(n);
                return;
            }

            obj = DisplayObject.CreateAndPlace(tag, clip);
            if (obj != null)
                _displayList.AddAfter(n, obj);
        }
Example #3
0
 internal static DisplayObject CreateAndPlace(PlaceObject2Tag tag, StageObject parent)
 {
     var obj = new DisplayObject(tag.Depth);
     if (!obj.SetPlacement(tag, parent))
         return null;
     return obj;
 }