#region GenTag
private void GenTag(ISwfAction tag)
{
if(tag.ActionType == SwfActionId.Empty) return;
switch(tag.ActionType)
{
case SwfActionId.GotoFrame :
{
Gen((GotoFrameAction)tag);
break;
}
case SwfActionId.GetURL :
{
Gen((GetURLAction)tag);
break;
}
case SwfActionId.WaitForFrame :
{
Gen((WaitForFrameAction)tag);
break;
}
case SwfActionId.SetTarget :
{
Gen((SetTargetAction)tag);
break;
}
case SwfActionId.GoToLabel :
{
Gen((GoToLabelAction)tag);
break;
}
case SwfActionId.Push :
{
Gen((PushAction)tag);
break;
}
case SwfActionId.If :
{
Gen((IfAction)tag);
break;
}
case SwfActionId.Jump :
{
Gen((JumpAction)tag);
break;
}
case SwfActionId.GetURL2 :
{
Gen((GetURL2Action)tag);
break;
}
case SwfActionId.GotoFrame2 :
{
Gen((GotoFrame2Action)tag);
break;
}
case SwfActionId.WaitForFrame2 :
{
Gen((WaitForFrame2Action)tag);
break;
}
case SwfActionId.ConstantPool :
{
Gen((ConstantPoolAction)tag);
break;
}
case SwfActionId.DefineFunction :
{
Gen((DefineFunctionAction)tag);
break;
}
case SwfActionId.With :
{
Gen((WithAction)tag);
break;
}
case SwfActionId.StoreRegister :
{
Gen((StoreRegisterAction)tag);
break;
}
case SwfActionId.DoInitAction :
{
Gen((DoInitActionAction)tag);
break;
}
case SwfActionId.DefineFunction2 :
{
Gen((DefineFunction2Action)tag);
break;
}
case SwfActionId.Try :
{
Gen((TryAction)tag);
break;
}
default :
{
if(Enum.IsDefined(tag.ActionType.GetType(), tag.ActionType))
{
w.WriteByte((byte)(tag.ActionType));
}
else
{
throw(new InvalidCastException(
"Invalid swf action tag: " + ((int)tag.ActionType) ));
}
break;
}
}
}
#endregion
#region Gen GotoFrameAction
private void Gen(GotoFrameAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Length);
w.WriteUI16(tag.Frame);
}
#endregion
#region Gen GetURLAction
private void Gen(GetURLAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Length);
w.WriteString(tag.UrlString);
w.WriteString(tag.TargetString);
}
#endregion
#region Gen WaitForFrameAction
private void Gen(WaitForFrameAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Length);
w.WriteUI16(tag.Frame);
w.WriteByte(tag.SkipCount);
}
#endregion
#region Gen SetTargetAction
private void Gen(SetTargetAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Length);
w.WriteString(tag.TargetName);
}
#endregion
#region Gen GoToLabelAction
private void Gen(GoToLabelAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Length);
w.WriteString(tag.Label);
}
#endregion
#region Gen PushAction
private void Gen(PushAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteString(tag.StringValue);
w.WriteFixedBits(tag.FloatValue);
w.WriteByte(tag.RegisterNumber);
w.WriteBit(tag.BooleanValue);
w.WriteUI16(tag.IntegerValue);
w.WriteByte(tag.Constant8Value);
w.WriteUI16(tag.Constant16Value);
}
#endregion
#region Gen IfAction
private void Gen(IfAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.BranchOffset);
}
#endregion
#region Gen JumpAction
private void Gen(JumpAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.BranchOffset);
}
#endregion
#region Gen GetURL2Action
private void Gen(GetURL2Action tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteBit(tag.LoadVariables);
}
#endregion
#region Gen GotoFrame2Action
private void Gen(GotoFrame2Action tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteBit(tag.SceneBiasFlag);
w.WriteBit(tag.Play);
w.WriteUI16(tag.SceneBias);
}
#endregion
#region Gen WaitForFrame2Action
private void Gen(WaitForFrame2Action tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteByte(tag.SkipCount);
}
#endregion
#region Gen ConstantPoolAction
private void Gen(ConstantPoolAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Count);
for(int i = 0; i < tag.ConstantPool.Length; i++)
{
w.WriteString(tag.ConstantPool[i]);
}
}
#endregion
#region Gen DefineFunctionAction
private void Gen(DefineFunctionAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteString(tag.FunctionName);
w.WriteUI16(tag.NumParams);
for(int i = 0; i < tag.Params.Length; i++)
{
w.WriteString(tag.Params[i]);
}
w.WriteUI16(tag.CodeSize);
}
#endregion
#region Gen WithAction
private void Gen(WithAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Size);
w.WriteString(tag.WithBlock);
}
#endregion
#region Gen StoreRegisterAction
private void Gen(StoreRegisterAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Register);
}
#endregion
#region Gen DoInitActionAction
private void Gen(DoInitActionAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteUI16(tag.Sprite);
}
#endregion
#region Gen DefineFunction2Action
private void Gen(DefineFunction2Action tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteString(tag.FunctionName);
w.WriteUI16(tag.NumParams);
w.WriteByte(tag.RegisterCount);
w.WriteBit(tag.PreloadParent);
w.WriteBit(tag.PreloadRoot);
w.WriteBit(tag.SuppressSuper);
w.WriteBit(tag.PreloadSuper);
w.WriteBit(tag.SuppressArguments);
w.WriteBit(tag.PreloadArguments);
w.WriteBit(tag.SuppressThis);
w.WriteBit(tag.PreloadThis);
w.WriteBit(tag.PreloadGlobal);
w.WriteUI16(tag.codeSize);
}
#endregion
#region Gen TryAction
private void Gen(TryAction tag)
{
w.WriteByte((byte)(tag.ActionType));
w.WriteBit(tag.CatchInRegister);
w.WriteBit(tag.FinallyBlock);
w.WriteBit(tag.CatchBlock);
w.WriteUI16(tag.TrySize);
w.WriteUI16(tag.CatchSize);
w.WriteUI16(tag.FinallySize);
w.WriteString(tag.CatchName);
w.WriteUI16(tag.CatchRegister);
}
#endregion