?? moviebuilder.java
字號:
/**
* SWFTagTypes interface
*/
public void tagFrameLabel( String label, boolean isAnchor ) throws IOException
{
currentFrame().setLabel( label );
currentFrame().setAnchor( isAnchor );
}
/**
* SWFTagTypes interface
*/
public SWFTagTypes tagDefineSprite( int id ) throws IOException
{
MovieClip clip = new MovieClip();
saveSymbol( id, clip );
return new MovieBuilder( this, clip );
}
/**
* SWFTagTypes interface
*/
public void tagProtect( byte[] password ) throws IOException
{
if( newMovie ) movie.protect( true );
}
/**
* SWFTagTypes interface
*/
public void tagEnableDebug( byte[] password ) throws IOException
{
//not implemented
}
/**
* SWFTagTypes interface
*/
public void tagEnableDebug2( byte[] password ) throws IOException
{
//not implemented
}
/**
* SWFTagTypes interface
*/
public SWFVectors tagDefineFont( int id, int numGlyphs ) throws IOException
{
FontDefinition fontDef = new FontDefinition();
Font font = new Font( fontDef );
saveSymbol( id, font );
return new GlyphBuilder( fontDef, font, numGlyphs );
}
/**
* SWFTagTypes interface
*/
public void tagDefineFontInfo( int fontId, String fontName, int flags, int[] codes )
{
defineFontInfo( fontId, fontName, flags, codes, SWFConstants.LANGUAGE_CODE_NONE );
}
/**
* SWFTagTypes interface
*/
public void defineFontInfo( int fontId, String fontName, int flags, int[] codes, int langCode )
{
Symbol s = getSymbol(fontId);
if( s == null || !(s instanceof Font)) return;
Font font = (Font)s;
FontDefinition def = font.getDefinition();
def.setName( fontName );
boolean isUnicode = ( (flags & SWFConstants.FONT_UNICODE) != 0 );
boolean isShiftJIS = ( (flags & SWFConstants.FONT_SHIFTJIS) != 0 );
boolean isAnsi = ( (flags & SWFConstants.FONT_ANSI ) != 0 );
boolean isItalic = ( (flags & SWFConstants.FONT_ITALIC ) != 0 );
boolean isBold = ( (flags & SWFConstants.FONT_BOLD ) != 0 );
def.setFontFlags( isUnicode, isShiftJIS, isAnsi, isItalic, isBold, false );
//--set the glyph codes
List glyphs = font.getGlyphList();
int glyphCount = glyphs.size();
for( int i = 0; i < codes.length && i < glyphCount; i++ )
{
int code = codes[i];
font.setCode( i, code );
}
font.setLanguageCode( langCode );
}
/**
* SWFTagTypes interface
*/
public void tagDefineFontInfo2( int fontId, String fontName, int flags, int[] codes, int langCode ) {
defineFontInfo( fontId, fontName, flags, codes, langCode );
}
/**
* 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
{
boolean hasMetrics = ((flags & SWFConstants.FONT2_HAS_LAYOUT) != 0 );
boolean isShiftJIS = ((flags & SWFConstants.FONT2_SHIFTJIS ) != 0 );
boolean isUnicode = ((flags & SWFConstants.FONT2_UNICODE ) != 0 );
boolean isAnsi = ((flags & SWFConstants.FONT2_ANSI ) != 0 );
boolean isItalic = ((flags & SWFConstants.FONT2_ITALIC ) != 0 );
boolean isBold = ((flags & SWFConstants.FONT2_BOLD ) != 0 );
FontDefinition fontDef = new FontDefinition(
name,
((double)ascent)/SWFConstants.TWIPS,
((double)descent)/SWFConstants.TWIPS,
((double)leading)/SWFConstants.TWIPS,
isUnicode, isShiftJIS, isAnsi, isItalic,
isBold, hasMetrics);
Font font = new Font( fontDef );
saveSymbol( id, font );
//--save the kerning info
if( hasMetrics && kernCodes1 != null )
{
List kerns = fontDef.getKerningPairList();
for( int i = 0; i < kernCodes1.length; i++ )
{
FontDefinition.KerningPair pair =
new FontDefinition.KerningPair(
kernCodes1[i],
kernCodes2[i],
((double)kernAdjustments[i])/SWFConstants.TWIPS );
kerns.add( pair );
}
}
return new GlyphBuilder( fontDef, font, codes, advances, bounds );
}
/**
* 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
{
Symbol f = getSymbol( fontId );
if( f == null || !(f instanceof Font)) return;
Font font = (Font)f;
EditField field = new EditField( fieldName, initialText, font,
((double)fontSize)/SWFConstants.TWIPS,
((double)boundary.getMinX())/SWFConstants.TWIPS,
((double)boundary.getMinY())/SWFConstants.TWIPS,
((double)boundary.getMaxX())/SWFConstants.TWIPS,
((double)boundary.getMaxY())/SWFConstants.TWIPS);
field.setTextColor( textColor );
field.setAlignment( alignment );
field.setCharLimit( charLimit );
field.setLeftMargin ( ((double)leftMargin )/SWFConstants.TWIPS );
field.setRightMargin( ((double)rightMargin)/SWFConstants.TWIPS );
field.setIndentation( ((double)indentation)/SWFConstants.TWIPS );
field.setLineSpacing( ((double)lineSpacing)/SWFConstants.TWIPS );
boolean isSelectable = ((flags & SWFConstants.TEXTFIELD_NO_SELECTION ) == 0 );
boolean hasBorder = ((flags & SWFConstants.TEXTFIELD_DRAW_BORDER ) != 0 );
boolean isHtml = ((flags & SWFConstants.TEXTFIELD_HTML ) != 0 );
boolean usesSystemFont = ((flags & SWFConstants.TEXTFIELD_FONT_GLYPHS ) == 0 );
boolean hasWordWrap = ((flags & SWFConstants.TEXTFIELD_WORD_WRAP ) != 0 );
boolean isMultiline = ((flags & SWFConstants.TEXTFIELD_IS_MULTILINE ) != 0 );
boolean isPassword = ((flags & SWFConstants.TEXTFIELD_IS_PASSWORD ) != 0 );
boolean isEditable = ((flags & SWFConstants.TEXTFIELD_DISABLE_EDIT ) == 0 );
field.setProperties( isSelectable, hasBorder, isHtml, usesSystemFont,
hasWordWrap, isMultiline, isPassword, isEditable );
saveSymbol( fieldId, field );
}
/**
* SWFTagTypes interface
*/
public SWFText tagDefineText( int id, Rect bounds, Matrix matrix )
throws IOException
{
Text text = new Text( new Transform(matrix) );
saveSymbol( id, text );
return new TextBuilder( text );
}
/**
* SWFTagTypes interface
*/
public SWFText tagDefineText2( int id, Rect bounds, Matrix matrix ) throws IOException
{
Text text = new Text( new Transform(matrix) );
saveSymbol( id, text );
return new TextBuilder( text );
}
/**
* SWFTagTypes interface
*/
public SWFActions tagDefineButton( int id, Vector buttonRecords )
throws IOException
{
Button but = new Button( false );
saveSymbol( id, but );
for( Enumeration e = buttonRecords.elements(); e.hasMoreElements(); )
{
ButtonRecord rec = (ButtonRecord)e.nextElement();
Symbol s = getSymbol( rec.getCharId() );
if( s == null ) continue;
int flags = rec.getFlags();
boolean hit = (( flags & ButtonRecord.BUTTON_HITTEST ) != 0 );
boolean up = (( flags & ButtonRecord.BUTTON_UP ) != 0 );
boolean over = (( flags & ButtonRecord.BUTTON_OVER ) != 0 );
boolean down = (( flags & ButtonRecord.BUTTON_DOWN ) != 0 );
but.addLayer( s, new Transform( rec.getMatrix()), null,
rec.getLayer(),
hit, up, down, over );
}
return new ButtonActionBuilder( but, movie.getVersion() );
}
/**
* SWFTagTypes interface
*/
public void tagButtonCXForm( int buttonId, ColorTransform transform )
throws IOException
{
Symbol s = getSymbol( buttonId );
if( s == null || !(s instanceof Button )) return;
Button but = (Button)s;
List layers = but.getButtonLayers();
//apply the transform to all the layers of the button
for( Iterator it = layers.iterator(); it.hasNext(); )
{
Button.Layer layer = (Button.Layer)it.next();
layer.setColoring( new AlphaTransform( transform ));
}
}
/**
* SWFTagTypes interface
*/
public SWFActions tagDefineButton2( int id,
boolean trackAsMenu,
Vector buttonRecord2s )
throws IOException
{
Button but = new Button( trackAsMenu );
saveSymbol( id, but );
for( Enumeration e = buttonRecord2s.elements(); e.hasMoreElements(); )
{
ButtonRecord2 rec = (ButtonRecord2)e.nextElement();
Symbol s = getSymbol( rec.getCharId() );
if( s == null ) continue;
int flags = rec.getFlags();
boolean hit = (( flags & ButtonRecord.BUTTON_HITTEST ) != 0 );
boolean up = (( flags & ButtonRecord.BUTTON_UP ) != 0 );
boolean over = (( flags & ButtonRecord.BUTTON_OVER ) != 0 );
boolean down = (( flags & ButtonRecord.BUTTON_DOWN ) != 0 );
but.addLayer( s, new Transform( rec.getMatrix()), rec.getTransform(),
rec.getLayer(),
hit, up, down, over );
}
return new ButtonActionBuilder( but, movie.getVersion() );
}
/**
* SWFTagTypes interface
*/
public void tagExport( String[] names, int[] ids ) throws IOException
{
Symbol[] symbols = new Symbol[ ids.length ];
for( int i = 0; i < ids.length; i++ )
{
symbols[i] = getSymbol(ids[i]);
}
movie.exportSymbols( names, symbols );
}
/**
* SWFTagTypes interface
*/
public void tagImport( String movieName, String[] names, int[] ids )
throws IOException
{
movie.importSymbols( movieName, names );
}
/**
* SWFTagTypes interface
*/
public void tagDefineQuickTimeMovie( int id, String filename ) throws IOException
{
saveSymbol( id, new QTMovie( filename ) );
}
/**
* SWFTagTypes interface
*/
public void tagDefineBitsJPEG2( int id, byte[] data ) throws IOException
{
saveSymbol( id, new Image.JPEG( data ) );
}
/**
* SWFTagTypes interface
*/
public void tagDefineBitsJPEG2( int id, InputStream jpegImage ) throws IOException
{
saveSymbol( id, new Image.JPEG( jpegImage ) );
}
/**
* SWFTagTypes interface
*/
public void tagDefineBitsLossless( int id, int format, int width, int height,
Color[] colors, byte[] imageData )
throws IOException
{
saveSymbol( id, new Image.Lossless( colors, imageData,
((double)width)/SWFConstants.TWIPS,
((double)height)/SWFConstants.TWIPS,
false, format ));
}
/**
* SWFTagTypes interface
*/
public void tagDefineBitsLossless2( int id, int format, int width, int height,
Color[] colors, byte[] imageData )
throws IOException
{
saveSymbol( id, new Image.Lossless( colors, imageData,
((double)width)/SWFConstants.TWIPS,
((double)height)/SWFConstants.TWIPS,
true, format ));
}
/**
* SWFTagTypes interface
*/
public SWFShape tagDefineMorphShape( int id, Rect startBounds, Rect endBounds )
throws IOException
{
return new MorphShapeBuilder( id, startBounds, endBounds );
}
/**
* A SWFActions implementation that breaks multiple action arrays into
* separate Actions objects
*/
protected static class ActionsBuilder extends SWFActionsImpl
{
protected int version;
protected Vector actions = new Vector();
protected ActionsBuilder( int flashVersion )
{
super( null );
version = flashVersion;
}
public Actions[] getActions()
{
Actions[] a = new Actions[ actions.size() ];
actions.copyInto( a );
return a;
}
public void start( int conditions )
{
acts = new Actions( conditions, version );
actions.addElement( acts );
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -