📄 tagwriter.java
字号:
out.writeUBits( 1, hasClipActions ? 1 : 0 );
out.writeUBits( 1, (clipDepth > 0) ? 1 : 0 );
out.writeUBits( 1, (name != null) ? 1 : 0 );
out.writeUBits( 1, (ratio >= 0) ? 1 : 0 );
out.writeUBits( 1, (cxform != null) ? 1 : 0 );
out.writeUBits( 1, (matrix != null) ? 1 : 0 );
out.writeUBits( 1, (charId > 0) ? 1 : 0 );
out.writeUBits( 1, isMove ? 1 : 0 );
out.writeUI16( depth );
if( charId > 0 ) out .writeUI16( charId );
if( matrix != null ) matrix.write ( out );
if( cxform != null ) cxform.write ( out );
if( ratio >= 0 ) out .writeUI16( ratio );
if( name != null ) {
out.writeString( name, mStringEncoding );
longTag = true;
}
if( clipDepth > 0 ) out .writeUI16( clipDepth );
if( hasClipActions )
{
final boolean isMX = version >= SWFConstants.FLASH_MX_VERSION;
out.writeUI16( 0 ); //unknown
if( isMX ) out.writeUI32( clipActionFlags );
else out.writeUI16( clipActionFlags );
return new ActionWriter( this, version )
{
private int mKeycode = -1;
public SWFActionBlock start( int conditions ) throws IOException
{
if( isMX ) mTagWriter.out.writeUI32( conditions );
else mTagWriter.out.writeUI16( conditions );
return super.start( conditions );
}
public SWFActionBlock start( int conditions, int keycode ) throws IOException
{
mKeycode = keycode;
return start( conditions );
}
protected void writeBytes( byte[] bytes ) throws IOException
{
if( mKeycode >= 0 ) {
mTagWriter.out.writeUI32( bytes.length + 1 );
mTagWriter.out.writeUI8( mKeycode );
} else {
mTagWriter.out.writeUI32( bytes.length );
}
super.writeBytes( bytes );
}
public void done() throws IOException
{
if( isMX ) mTagWriter.out.writeUI32( 0 );
else mTagWriter.out.writeUI16( 0 );
super.done();
}
};
}
completeTag();
return null;
}
/**
* SWFTagTypes interface
*/
public void tagRemoveObject( int charId, int depth ) throws IOException
{
startTag( TAG_REMOVEOBJECT, false );
out.writeUI16( charId );
out.writeUI16( depth );
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagRemoveObject2(int depth ) throws IOException
{
startTag( TAG_REMOVEOBJECT2, false );
out.writeUI16( depth );
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagSetBackgroundColor( Color color ) throws IOException
{
startTag( TAG_SETBACKGROUNDCOLOR, false );
color.writeRGB( out );
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagFrameLabel( String label ) throws IOException
{
tagFrameLabel( label, false );
}
/**
* SWFTagTypes interface
*/
public void tagFrameLabel( String label, boolean isAnchor ) throws IOException {
startTag( TAG_FRAMELABEL, true );
out.writeString( label, mStringEncoding );
if( isAnchor ) out.writeUI8( 1 );
completeTag();
}
/**
* SWFTagTypes interface
*/
public SWFTagTypes tagDefineSprite( int id ) throws IOException
{
startTag( TAG_DEFINESPRITE, id, true );
out.writeUI16( 0 ); //framecount - to be filled in later
TagWriter writer = new TagWriter( new SpriteTags() );
writer.version = version;
return writer;
}
/**
* SWFTagTypes interface
*/
public void tagProtect( byte[] password ) throws IOException
{
mTags.tag( TAG_PROTECT, false, password );
}
/**
* SWFTagTypes interface
*/
public void tagEnableDebug( byte[] password ) throws IOException
{
mTags.tag( TAG_ENABLEDEBUG, false, password );
}
/**
* SWFTagTypes interface
*/
public void tagEnableDebug2( byte[] password ) throws IOException
{
startTag( TAG_ENABLEDEBUGGER2, 0, false );
out.write( password );
completeTag();
}
/**
* SWFTagTypes interface
*/
public SWFVectors tagDefineFont( int id, int numGlyphs ) throws IOException
{
startTag( TAG_DEFINEFONT, id, true );
return new SWFShapeImpl( this, numGlyphs );
}
/**
* SWFTagTypes interface
*/
public void tagDefineFontInfo( int fontId, String fontName, int flags, int[] codes )
throws IOException
{
startTag( TAG_DEFINEFONTINFO, true );
out.writeUI16( fontId );
byte[] chars = fontName.getBytes();
out.writeUI8( chars.length );
out.write( chars );
out.writeUI8( flags );
boolean wide = (flags & FONT_WIDECHARS) != 0;
for( int i = 0; i < codes.length; i++ )
{
if( wide ) out.writeUI16( codes[i] );
else out.writeUI8 ( codes[i] );
}
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagDefineFontInfo2( int fontId, String fontName, int flags, int[] codes, int languageCode )
throws IOException
{
startTag( TAG_DEFINEFONTINFO2, true );
out.writeUI16( fontId );
byte[] chars = fontName.getBytes();
out.writeUI8( chars.length );
out.write( chars );
flags |= SWFConstants.FONT_WIDECHARS; //always wide
out.writeUI8( flags );
out.writeUI8( languageCode );
for( int i = 0; i < codes.length; i++ )
{
out.writeUI16( codes[i] );
}
completeTag();
}
/**
* SWFTagTypes interface
*/
public SWFVectors tagDefineFont2( int id, int flags, String name, int numGlyphs,
int ascent, int descent, int leading,
int[] codes, int[] advances, Rect[] bounds,
int[] kernCodes1, int[] kernCodes2,
int[] kernAdjustments ) throws IOException
{
startTag( TAG_DEFINEFONT2, id, true );
out.writeUI8( flags );
out.writeUI8( 0 ); //reserved flags
byte[] nameBytes = name.getBytes();
out.writeUI8 ( nameBytes.length );
out.write ( nameBytes );
out.writeUI16( numGlyphs );
return new Font2ShapeImpl( this, flags, numGlyphs, ascent, descent, leading,
codes, advances, bounds,
kernCodes1, kernCodes2, kernAdjustments );
}
/**
* SWFTagTypes interface
*/
public void tagDefineTextField( int fieldId, String fieldName,
String initialText, Rect boundary, int flags,
AlphaColor textColor, int alignment, int fontId, int fontSize,
int charLimit, int leftMargin, int rightMargin, int indentation,
int lineSpacing )
throws IOException
{
flags |= 0x2005;
startTag( TAG_DEFINETEXTFIELD, fieldId, true );
boundary.write( out );
out.writeUI16( flags );
out.writeUI16( fontId );
out.writeUI16( fontSize );
textColor.write( out );
if( (flags & TEXTFIELD_LIMIT_CHARS ) != 0 )
{
out.writeUI16( charLimit );
}
out.writeUI8 ( alignment );
out.writeUI16( leftMargin );
out.writeUI16( rightMargin );
out.writeUI16( indentation );
out.writeUI16( lineSpacing );
out.writeString( fieldName, mStringEncoding );
if( (flags & TEXTFIELD_HAS_TEXT ) != 0 )
{
out.writeString( initialText, mStringEncoding );
}
completeTag();
}
/**
* SWFTagTypes interface
*/
public SWFText tagDefineText( int id, Rect bounds, Matrix matrix )
throws IOException
{
startTag( TAG_DEFINETEXT, id, true );
return defineText( bounds, matrix, false );
}
/**
* SWFTagTypes interface
*/
public SWFText tagDefineText2( int id, Rect bounds, Matrix matrix ) throws IOException
{
startTag( TAG_DEFINETEXT2, id, true );
return defineText( bounds, matrix, true );
}
/**
* SWFTagTypes interface
*/
public SWFActions tagDefineButton( int id, Vector buttonRecords )
throws IOException
{
startTag( TAG_DEFINEBUTTON, id, true );
ButtonRecord.write( out, buttonRecords );
System.out.println( "BUTTON" );
return new ActionWriter( this, version );
}
/**
* SWFTagTypes interface
*/
public void tagButtonCXForm( int buttonId, ColorTransform transform )
throws IOException
{
startTag( TAG_DEFINEBUTTONCXFORM, buttonId, false );
transform.writeWithoutAlpha( out );
completeTag();
}
/**
* SWFTagTypes interface
*/
public SWFActions tagDefineButton2( int id,
boolean trackAsMenu,
Vector buttonRecord2s )
throws IOException
{
startTag( TAG_DEFINEBUTTON2, id, true );
out.writeUI8( trackAsMenu ? 1 : 0 );
return new ButtonActionWriter( this, version, buttonRecord2s );
}
/**
* SWFTagTypes interface
*/
public void tagExport( String[] names, int[] ids ) throws IOException
{
startTag( TAG_EXPORT, true );
int count = ids.length;
out.writeUI16( count );
for( int i = 0; i < count; i++ )
{
//System.out.println( "Exporting " + ids[i] + " as " + names[i] );
out.writeUI16 ( ids [i] );
out.writeString( names[i], mStringEncoding );
}
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagImport( String movieName, String[] names, int[] ids )
throws IOException
{
startTag( TAG_IMPORT, true );
int count = ids.length;
out.writeString( movieName, mStringEncoding );
out.writeUI16 ( count );
for( int i = 0; i < count; i++ )
{
//System.out.println( "Importing " + names[i] + " as " + ids[i] + " from " + movieName );
out.writeUI16 ( ids [i] );
out.writeString( names[i], mStringEncoding );
}
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagDefineQuickTimeMovie( int id, String filename ) throws IOException
{
startTag( TAG_DEFINEQUICKTIMEMOVIE, id, true );
out.writeString( filename, mStringEncoding );
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagDefineBitsJPEG2( int id, byte[] data ) throws IOException
{
startTag( TAG_DEFINEBITSJPEG2, id, true );
out.write( data );
completeTag();
}
/**
* SWFTagTypes interface
*/
public void tagDefineBitsLossless( int id, int format, int width, int height,
Color[] colors, byte[] imageData )
throws IOException
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -