Beispiel #1
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));
		}
Beispiel #2
0
        private void ParseTags(SwfReader r, byte swfVersion)
        {
            bool tagsRemain = true;

            uint curFrame = 0;
            while (tagsRemain)
            {
                uint b = r.GetUI16();
                curTag = (TagType)(b >> 6);
                curTagLen = b & 0x3F;
                if (curTagLen == 0x3F)
                {
                    curTagLen = r.GetUI32();
                }
                uint tagEnd = r.Position + curTagLen;
                Debug.WriteLine("sprite type: " + ((uint)curTag).ToString("X2") + " -- " + Enum.GetName(typeof(TagType), curTag));

                switch (curTag)
                {
                    case TagType.End:
                        tagsRemain = false;
                        ControlTags.Add(new EndTag(r));
                        break;

                    case TagType.PlaceObject:
                        PlaceObjectTag pot = new PlaceObjectTag(r, tagEnd);
                        FirstFrameObjects.Add(pot);
                        ControlTags.Add(pot);
                        break;
                    case TagType.PlaceObject2:
                        PlaceObject2Tag po2t = new PlaceObject2Tag(r, swfVersion);
                        if (po2t.HasCharacter)
                        {
                            FirstFrameObjects.Add(po2t);
                        }
                        ControlTags.Add(po2t);
                        break;
                    case TagType.PlaceObject3:
                        PlaceObject3Tag po3t = new PlaceObject3Tag(r);
                        if (po3t.HasCharacter)
                        {
                            FirstFrameObjects.Add(po3t);
                        }
                        ControlTags.Add(po3t);
                        break;

                    case TagType.RemoveObject:
                        ControlTags.Add(new RemoveObjectTag(r));
                        break;

                    case TagType.RemoveObject2:
                        ControlTags.Add(new RemoveObject2Tag(r));
                        break;

                    case TagType.ShowFrame:
                        ControlTags.Add(new ShowFrame(r));
                        curFrame++;
                        break;

                    case TagType.SoundStreamHead:
                    case TagType.SoundStreamHead2:
                        ControlTags.Add(new SoundStreamHeadTag(r));
                        break;

                    case TagType.FrameLabel:
                        ControlTags.Add(new FrameLabelTag(r));
                        break;

                    case TagType.DoAction:
                        ControlTags.Add(new DoActionTag(r, curTagLen));
                        break;

                    case TagType.DoInitAction:
                        ControlTags.Add(new DoActionTag(r, curTagLen, true));
                        break;

                    default:
                        // skip if unknown
                        Debug.WriteLine("invalid sprite tag: " + ((uint)curTag).ToString("X2") + " -- " + Enum.GetName(typeof(TagType), curTag));
                        r.SkipBytes(curTagLen);
                        break;
                }
                if (tagEnd != r.Position)
                {
                    Console.WriteLine("bad tag in sprite: " + Enum.GetName(typeof(TagType), curTag));
                }
            }
        }
Beispiel #3
0
        private void ParseTags(SwfReader r, byte swfVersion)
        {
            bool tagsRemain = true;

            uint curFrame = 0;

            while (tagsRemain)
            {
                uint b = r.GetUI16();
                curTag    = (TagType)(b >> 6);
                curTagLen = b & 0x3F;
                if (curTagLen == 0x3F)
                {
                    curTagLen = r.GetUI32();
                }
                uint tagEnd = r.Position + curTagLen;
                Debug.WriteLine("sprite type: " + ((uint)curTag).ToString("X2") + " -- " + Enum.GetName(typeof(TagType), curTag));

                switch (curTag)
                {
                case TagType.End:
                    tagsRemain = false;
                    ControlTags.Add(new EndTag(r));
                    break;

                case TagType.PlaceObject:
                    PlaceObjectTag pot = new PlaceObjectTag(r, tagEnd);
                    FirstFrameObjects.Add(pot);
                    ControlTags.Add(pot);
                    break;

                case TagType.PlaceObject2:
                    PlaceObject2Tag po2t = new PlaceObject2Tag(r, swfVersion);
                    if (po2t.HasCharacter)
                    {
                        FirstFrameObjects.Add(po2t);
                    }
                    ControlTags.Add(po2t);
                    break;

                case TagType.PlaceObject3:
                    PlaceObject3Tag po3t = new PlaceObject3Tag(r);
                    if (po3t.HasCharacter)
                    {
                        FirstFrameObjects.Add(po3t);
                    }
                    ControlTags.Add(po3t);
                    break;

                case TagType.RemoveObject:
                    ControlTags.Add(new RemoveObjectTag(r));
                    break;

                case TagType.RemoveObject2:
                    ControlTags.Add(new RemoveObject2Tag(r));
                    break;

                case TagType.ShowFrame:
                    ControlTags.Add(new ShowFrame(r));
                    curFrame++;
                    break;

                case TagType.SoundStreamHead:
                case TagType.SoundStreamHead2:
                    ControlTags.Add(new SoundStreamHeadTag(r));
                    break;

                case TagType.FrameLabel:
                    ControlTags.Add(new FrameLabelTag(r));
                    break;

                case TagType.DoAction:
                    ControlTags.Add(new DoActionTag(r, curTagLen));
                    break;

                case TagType.DoInitAction:
                    ControlTags.Add(new DoActionTag(r, curTagLen, true));
                    break;

                default:
                    // skip if unknown
                    Debug.WriteLine("invalid sprite tag: " + ((uint)curTag).ToString("X2") + " -- " + Enum.GetName(typeof(TagType), curTag));
                    r.SkipBytes(curTagLen);
                    break;
                }
                if (tagEnd != r.Position)
                {
                    Console.WriteLine("bad tag in sprite: " + Enum.GetName(typeof(TagType), curTag));
                }
            }
        }