Parser

Submitted by eLenka on 4 August, 2010 - 14:48
Parsing SWF files

This project can be named "Inside SWF file". The program allows to view all tags and action commands wrote in SWF file. Use the one to see how to make an SWF file (please use the one only for your own SWF files or by author consent).

Source archive: parser.zip (691 KB)

 

 

Some sample source: 
procedure TMDIChild.LoadSWF(fn: string);
 var MN: tTreeNode;
     il, il2, il3: word;
     STag: TSWFTagInfo;
     Node, Node2: PVirtualNode;
 var L: LongInt;
begin
  SwfName := fn;
 
  SWF:=TSWFStreamReader.Create(fn);
 
  LInfo.Caption:=Format('Ver: %d   Size: %d bytes   Frames count: %d',
    [SWF.Version, SWF.SWFHeader.FileSize, SWF.SWFHeader.FramesCount]);
 
  with SWF.MovieRect do
  begin
    EXMin.Text:= IntToStr(Left);
    EXMax.Text:= IntToStr(Right);
    EYMin.Text:= IntToStr(Top);
    EYMax.Text:= IntToStr(Bottom);
  end;
  EFPS.Text:=FloatToStr(SWF.FPS);
  CBCompress.Checked := SWF.Compressed;
  SWF.ReadBody(true, ParseAction);
 
  for il:=0 to SWF.TagList.count - 1 do
    begin
     Node := VTree.AddChild(nil);
     PMyRecNode(VTree.GetNodeData(Node))^.TagInfo :=  SWF.TagList.Items[il];
     if il < (SWF.TagList.count - 1) then
       begin
        Node.CheckType := ctCheckBox;
        VTree.CheckState[Node] := csUncheckedNormal;
        if TSWFTagInfo(SWF.TagList.Items[il]).TagID = tagDefineSprite then
         with TSWFTagInfo(SWF.TagList.Items[il]) do
          for il2 := 0 to SubTags.Count - 1 do
            begin
              Node2 := VTree.AddChild(Node);
              PMyRecNode(VTree.GetNodeData(Node2))^.TagInfo := SubTags.Items[il2];
            end;
       end;
   end;
//  VTree.RootNodeCount := SWF.TagList.count;
  if not MainForm.Dontrun.Checked then
    Player.Movie := fn;
end;