示例#1
0
		private void ParsePlaceObject2Tag(PlaceObject2Tag tag)
		{
            uint curTime = (uint)((curFrame * (1 / swf.Header.FrameRate)) * 1000);
            uint totalTime = GetDuration(this.curTimeline.FrameCount); 

			Vex.Matrix mx = ParseMatrix(tag.Matrix);
			float alpha = 1;
			Instance inst;
			if (tag.HasCharacter && !tag.Move) // a new symbol at this depth, none preexisting
			{
				inst = new Instance();
				inst.DefinitionId = tag.Character;
				inst.StartTime = curTime;
				inst.EndTime = totalTime;
				inst.Depth = (int)tag.Depth;
				curDepthChart.Add(tag.Depth, inst);
				this.curTimeline.AddInstance(inst);
			}
			else if (!tag.HasCharacter && tag.Move) // an old symbol is modified
			{
				inst = curDepthChart[tag.Depth];
				Transform lastT = inst.Transformations[inst.Transformations.Count - 1];
				lastT.EndTime = curTime;
				inst.EndTime = curTime;
				alpha = lastT.Alpha;
			}
			else if (tag.HasCharacter && tag.Move) // a new symbol replaces an old one
			{
				Instance old = curDepthChart[tag.Depth];
				Transform lastT = old.Transformations[old.Transformations.Count - 1];
				lastT.EndTime = curTime;
				old.EndTime = curTime;

				curDepthChart.Remove(tag.Depth);

				inst = new Instance();
				// note: when replacing old symbol, the previous matrix is used
				if (!tag.HasMatrix)
				{
					mx = lastT.Matrix;
				}
				// as is old color xform
				if (!tag.HasColorTransform)
				{
					alpha = lastT.Alpha; // include rest of xform as it comes
				}
				inst.DefinitionId = tag.Character;
				inst.StartTime = curTime;
				inst.EndTime = totalTime;
                inst.Depth = (int)tag.Depth;

				curDepthChart.Add(tag.Depth, inst);
                this.curTimeline.AddInstance(inst);
			}
			else
			{
				throw new ArgumentException("swf error, no character to modify");
			}
			if (tag.HasColorTransform && (tag.ColorTransform.HasAddTerms || tag.ColorTransform.HasMultTerms))
			{
				int addMult = tag.ColorTransform.AMultTerm + tag.ColorTransform.AAddTerm;
				alpha = addMult < 0 ? 0 : addMult / 256F;
			}

			if (tag.HasClipDepth)
			{
				inst.IsMask = true;
				inst.MaskDepth = tag.ClipDepth;
			}
			if (tag.HasName)
			{
				inst.Name = tag.Name;
            }

            ColorTransform c = tag.ColorTransform;
            Vex.ColorTransform ct = new Vex.ColorTransform(c.RAddTerm, c.RMultTerm, c.GAddTerm, c.GMultTerm, c.BAddTerm, c.BMultTerm, c.AAddTerm, c.AMultTerm);
			inst.Transformations.Add(new Transform(curTime, totalTime, mx, alpha, ct));
		}
示例#2
0
		private void ParsePlaceObjectTag(PlaceObjectTag tag)
		{
			uint curTime = (uint)((curFrame * (1 / swf.Header.FrameRate)) * 1000);
            uint totalTime = GetDuration(this.curTimeline.FrameCount);

			Vex.Matrix mx = ParseMatrix(tag.Matrix);
			float alpha = 1;

			Instance inst = new Instance();
			inst.DefinitionId = tag.Character;
			inst.StartTime = curTime;
			inst.EndTime = totalTime;
            inst.Depth = (int)tag.Depth;

            // error from flashDevelop files
            if (curDepthChart.ContainsKey(tag.Depth))
            {
                curDepthChart.Remove(tag.Depth);
            }
			curDepthChart.Add(tag.Depth, inst);
			this.curTimeline.AddInstance(inst);

			if (tag.HasColorTransform && (tag.ColorTransform.HasAddTerms || tag.ColorTransform.HasMultTerms))
			{
				int addMult = tag.ColorTransform.AMultTerm + tag.ColorTransform.AAddTerm;
				alpha = addMult < 0 ? 0 : addMult / 256F;
			}
            ColorTransform c = tag.ColorTransform;
            Vex.ColorTransform ct = new Vex.ColorTransform(c.RAddTerm, c.RMultTerm, c.GAddTerm, c.GMultTerm, c.BAddTerm, c.BMultTerm, c.AAddTerm, c.AMultTerm);

			inst.Transformations.Add(new Transform(curTime, totalTime, mx, alpha, ct));
		}