public void Parse( Stream input, uint maxSize )
{
BinaryReader br = new BinaryReader( input );
//
// subtract the OffsetToNextCondAction as well as the Conditions from
// the available size
//
uint maxSizeInternal = maxSize - 4;
_OffsetToNextCondAction = br.ReadUInt16();
BitStream bits = new BitStream( input );
_CondIdleToOverDown = ( 0 != bits.GetBits( 1 ) );
_CondOutDownToIdle = ( 0 != bits.GetBits( 1 ) );
_CondOutDownToOverDown = ( 0 != bits.GetBits( 1 ) );
_CondOverDownToOutDown = ( 0 != bits.GetBits( 1 ) );
_CondOverDownToOverUp = ( 0 != bits.GetBits( 1 ) );
_CondOverUpToOverDown = ( 0 != bits.GetBits( 1 ) );
_CondOverUpToIdle = ( 0 != bits.GetBits( 1 ) );
_CondIdleToOverUp = ( 0 != bits.GetBits( 1 ) );
_CondKeyPress = (byte)bits.GetBits( 7 );
if ( ( 0 != _CondKeyPress ) && ( this.Version < 4 ) )
{
throw new SwfFormatException( "CondKeyPress != 0 with Swf version " + this.Version.ToString( "d" ) );
}
if (
( ( _CondKeyPress > 19 ) && ( _CondKeyPress < 32 ) )
|| ( _CondKeyPress > 126 )
)
{
throw new SwfFormatException( "Illegal CondKeyPress " + _CondKeyPress.ToString("d") + " in ButtonCondAction" );
}
_CondOverDownToIdle = ( 0 != bits.GetBits( 1 ) );
uint expectedSize;
if ( 0 != _OffsetToNextCondAction )
{
//
// if we have been given an offset, this defines our code
// size expecations (minus 4 bytes for the previous data)
//
expectedSize = (uint)( _OffsetToNextCondAction - 4 );
}
else
{
//
// if we have no offset, the caller must tell us how much
// we have left
//
expectedSize = maxSizeInternal;
}
AVM1.AVM1InstructionSequence bytecode = Helper.SwfCodeReader.GetCode( expectedSize, br, this.Version );
_Code = new AVM1.AVM1Code( bytecode );
}