?? actiontextwriter.java
字號:
/****************************************************************
* Copyright (c) 2001, David N. Main, All rights reserved.
*
* Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the
* following conditions are met:
*
* 1. Redistributions of source code must retain the above
* copyright notice, this list of conditions and the following
* disclaimer.
*
* 2. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. The name of the author may not be used to endorse or
* promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
****************************************************************/
package com.anotherbigidea.flash.writers;
import java.io.IOException;
import java.io.PrintWriter;
import com.anotherbigidea.flash.SWFActionCodes;
import com.anotherbigidea.flash.interfaces.SWFActions;
/**
* A writer that implements the SWFActions interface and writes
* actions to a text format
*/
public class ActionTextWriter implements SWFActions, SWFActionCodes
{
protected PrintWriter printer;
protected String indent = "";
public ActionTextWriter( PrintWriter printer )
{
this.printer = printer;
}
protected void print( String mnemonic, String[] args )
{
printer.print( indent + " " );
writePaddedString( mnemonic + " ", 15 );
if( args != null )
{
for( int i = 0; i < args.length; i++ )
{
if( i > 0 ) printer.print( ", " );
printer.print( args[i] );
}
}
printer.println();
}
protected void writePaddedString( String s, int length )
{
int pad = length - s.length();
printer.print( s );
while( pad > 0 )
{
printer.print( " " );
pad--;
}
}
public void start( int conditions ) throws IOException
{
print( "conditions", new String[] { Integer.toBinaryString( conditions ) } );
printer.flush();
}
public void end() throws IOException
{
print( "end", null );
printer.println();
}
public void done() throws IOException
{
printer.flush();
}
public void blob( byte[] blob ) throws IOException
{
print( "(blob)", null );
printer.println();
}
public void unknown( int code, byte[] data ) throws IOException
{
print( "unknown code =", new String[] { Integer.toString( code ) } );
}
public void initArray() throws IOException
{
print( "initArray", null );
}
public void jumpLabel( String label ) throws IOException
{
printer.println( indent + label + ":" );
}
public void gotoFrame( int frameNumber ) throws IOException
{
print( "gotoFrame", new String[] { Integer.toString( frameNumber ) } );
}
public void gotoFrame( String label ) throws IOException
{
print( "gotoFrame", new String[] { "\"" + label + "\"" } );
}
public void getURL( String url, String target ) throws IOException
{
print( "getURL", new String[] { "\"" + url + "\"", "\"" + target + "\"" } );
}
public void nextFrame() throws IOException
{
print( "nextFrame", null );
}
public void prevFrame() throws IOException
{
print( "previousFrame", null );
}
public void play() throws IOException
{
print( "play", null );
}
public void stop() throws IOException
{
print( "stop", null );
}
public void toggleQuality() throws IOException
{
print( "toggleQuality", null );
}
public void stopSounds() throws IOException
{
print( "stopSounds", null );
}
public void setTarget( String target ) throws IOException
{
print( "setTarget", new String[] { "\"" + target + "\"" } );
}
public void jump( String jumpLabel ) throws IOException
{
print( "jump", new String[] { "\"" + jumpLabel + "\"" } );
}
public void ifJump( String jumpLabel ) throws IOException
{
print( "ifJump", new String[] { "\"" + jumpLabel + "\"" } );
}
public void waitForFrame( int frameNumber, String jumpLabel ) throws IOException
{
print( "waitForFrame", new String[] { Integer.toString( frameNumber ),
"\"" + jumpLabel + "\"" } );
}
public void waitForFrame( String jumpLabel ) throws IOException
{
print( "waitForFrame", new String[] { "\"" + jumpLabel + "\"" } );
}
public void pop() throws IOException
{
print( "pop", null );
}
public void push( String value ) throws IOException
{
print( "push", new String[] { "\"" + value + "\"" } );
}
public void push( float value ) throws IOException
{
print( "push", new String[] { "float " + value } );
}
public void push( double value ) throws IOException
{
print( "push", new String[] { "double " + value } );
}
public void pushNull() throws IOException
{
print( "push", new String[] { "null" } );
}
public void pushRegister( int registerNumber ) throws IOException
{
print( "push", new String[] { "register( " + registerNumber + " )" } );
}
public void push( boolean value ) throws IOException
{
print( "push", new String[] { value ? "true" : "false" } );
}
public void push( int value ) throws IOException
{
print( "push", new String[] { "" + value } );
}
public void lookup( int dictionaryIndex ) throws IOException
{
print( "push", new String[] { "lookup( " + dictionaryIndex + " )" } );
}
public void add() throws IOException
{
print( "add", null );
}
public void substract() throws IOException
{
print( "substract", null );
}
public void multiply() throws IOException
{
print( "multiply", null );
}
public void divide() throws IOException
{
print( "divide", null );
}
public void equals() throws IOException
{
print( "equals", null );
}
public void lessThan() throws IOException
{
print( "lessThan", null );
}
public void and() throws IOException
{
print( "and", null );
}
public void or() throws IOException
{
print( "or", null );
}
public void not() throws IOException
{
print( "not", null );
}
public void stringEquals() throws IOException
{
print( "stringEquals", null );
}
public void stringLength() throws IOException
{
print( "stringLength", null );
}
public void concat() throws IOException
{
print( "concat", null );
}
public void substring() throws IOException
{
print( "substring", null );
}
public void stringLessThan() throws IOException
{
print( "stringLessThan", null );
}
public void stringLengthMB() throws IOException
{
print( "stringLengthMB", null );
}
public void substringMB() throws IOException
{
print( "substringMB", null );
}
public void toInteger() throws IOException
{
print( "toInteger", null );
}
public void charToAscii() throws IOException
{
print( "charToAscii", null );
}
public void asciiToChar() throws IOException
{
print( "asciiToChar", null );
}
public void charMBToAscii() throws IOException
{
print( "charMBToAscii", null );
}
public void asciiToCharMB() throws IOException
{
print( "asciiToCharMB", null );
}
public void call() throws IOException
{
print( "call", null );
}
public void getVariable() throws IOException
{
print( "getVariable", null );
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -