private void ReadSprite()
{
int characterID = this.sdtr.ReadUI16();
uint frameCount = this.sdtr.ReadUI16();
#if DEBUG
this.Log("char id=" + characterID + ", frames=" + frameCount);
#endif
Sprite sprite = this.swf.NewSprite(CID_PREFIX + characterID, frameCount, (this.frameCursor == 1));
this.currentTimeline = sprite;
this.characterUnmarshaller.Add(characterID, sprite);
int currentFrame = 1;
for (; ; )
{
int type;
uint followingOffset;
this.sdtr.ReadRECORDHEADER(out type, out followingOffset);
#if DEBUG
Tag _tag = (Tag)type;
bool isDefine = _tag == Tag.DefineShape ||
_tag == Tag.DefineShape3 ||
_tag == Tag.DefineShape4 ||
_tag == Tag.DefineSprite;
this.MarkDumpOffset(
"Body of " + _tag + " (" + type + ") len=" + (followingOffset - this.sdtr.Offset),
isDefine);
this.binaryDumpNest++;
#endif
switch ((Tag)type)
{
case Tag.ShowFrame:
#if DEBUG
this.MarkDumpOffset("");
#endif
currentFrame++;
break;
case Tag.End:
if ((currentFrame - 1) != frameCount)
{
throw new SWFModellerException(
SWFModellerError.SWFParsing,
@"Frame count mismatch in sprite " + characterID, swf.Context);
}
this.currentTimeline = this.swf;
#if DEBUG
this.binaryDumpNest--;
#endif
return;
case Tag.PlaceObject2:
sprite.GetFrame(currentFrame).AddTag(this.ReadPlaceObject2());
break;
case Tag.PlaceObject:
sprite.GetFrame(currentFrame).AddTag(this.ReadPlaceObject(followingOffset));
break;
case Tag.FrameLabel:
sprite.GetFrame(currentFrame).Label = this.sdtr.ReadString();
#if DEBUG
this.Log("Frame label = " + sprite.GetFrame(currentFrame).Label);
#endif
break;
case Tag.RemoveObject2:
sprite.GetFrame(currentFrame).AddTag(this.ReadRemoveObject2());
break;
case Tag.RemoveObject:
case Tag.StartSound:
case Tag.SoundStreamHead:
case Tag.SoundStreamHead2:
case Tag.SoundStreamBlock:
case Tag.DoAction:
/* ISSUE 73 */
throw new SWFModellerException(
SWFModellerError.UnimplementedFeature,
@"Unsupported tag within a sprite definition: " + ((Tag)type).ToString(), swf.Context);
default:
throw new SWFModellerException(
SWFModellerError.SWFParsing,
@"Bad SWF; A " + ((Tag)type).ToString() + @" tag is not permitted within a sprite definition", swf.Context);
}
#if DEBUG
this.binaryDumpNest--;
#endif
}
}