⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 actionblockwriter.java

📁 java和flash混合编程
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
        int offsetAddr = mOut.getCount();
        mOut.writeUI16( 0 );   //will be fixed up later
        
        mFixers.add( new OffsetFixer( mOut.getCount(), offsetAddr, label ) );
    }
 
    public void jump( String jumpLabel ) throws IOException
    {
        writeJump( jumpLabel, JUMP );
    }
 
    public void ifJump( String jumpLabel ) throws IOException
    {
        writeJump( jumpLabel, IF );
    }
 
    public void waitForFrame( int frameNumber, String jumpLabel ) throws IOException
    {
        writeCode( WAIT_FOR_FRAME );
        mOut.writeUI16( 3 );
        mOut.writeUI16( frameNumber );

        int addr = (int) mOut.getCount();
        mOut.writeUI8 ( 0 ); //will be fixed up later
        
        int thisCount = mActionCount[0];
        
        SkipActionFixer fixer = new SkipActionFixer( thisCount, addr, jumpLabel );
        
        mFixers.add( fixer );
    }
 
    public void waitForFrame( String jumpLabel ) throws IOException
    {
        writeCode( WAIT_FOR_FRAME_2 );
        mOut.writeUI16( 1 );

        int addr = (int) mOut.getCount();
        mOut.writeUI8 ( 0 ); //will be fixed up later
        
        int thisCount = mActionCount[0];
        
        SkipActionFixer fixer = new SkipActionFixer( thisCount, addr, jumpLabel );
        
        mFixers.add( fixer );
    }
 
    public void pop() throws IOException
    {
        writeCode( POP );
    }
 
    public void add() throws IOException
    {
        writeCode( ADD );
    }
 
    public void substract() throws IOException
    {
        writeCode( SUBTRACT );
    }
 
    public void multiply() throws IOException
    {
        writeCode( MULTIPLY );
    }
 
    public void divide() throws IOException
    {
        writeCode( DIVIDE );
    }
 
    public void equals() throws IOException
    {
        writeCode( EQUALS );
    }
 
    public void lessThan() throws IOException
    {
        writeCode( LESS );
    }
 
    public void and() throws IOException
    {
        writeCode( AND );
    }
 
    public void or() throws IOException
    {
        writeCode( OR );
    }
 
    public void not() throws IOException
    {
        writeCode( NOT );
    }
 
    public void stringEquals() throws IOException
    {
        writeCode( STRING_EQUALS );
    }
 
    public void stringLength() throws IOException
    {
        writeCode( STRING_LENGTH );
    }
 
    public void concat() throws IOException
    {
        writeCode( STRING_ADD );
    }
 
    public void substring() throws IOException
    {
        writeCode( STRING_EXTRACT );
    }
 
    public void stringLessThan() throws IOException
    {
        writeCode( STRING_LESS );
    }
 
    public void stringLengthMB() throws IOException
    {
        writeCode( MB_STRING_LENGTH );
    }
 
    public void substringMB() throws IOException
    {
        writeCode( MB_STRING_EXTRACT );
    }    
 
    public void toInteger() throws IOException
    {
        writeCode( TO_INTEGER );
    }
 
    public void charToAscii() throws IOException
    {
        writeCode( CHAR_TO_ASCII );
    }
 
    public void asciiToChar() throws IOException
    {
        writeCode( ASCII_TO_CHAR );
    }
 
    public void charMBToAscii() throws IOException
    {
        writeCode( MB_CHAR_TO_ASCII );
    }
 
    public void asciiToCharMB() throws IOException
    {
        writeCode( MB_ASCII_TO_CHAR );
    }
 
    public void call() throws IOException
    {
        writeCode( CALL );
        mOut.writeUI16( 0 );   //SWF File Format anomaly
    }
 
    public void getVariable() throws IOException
    {
        writeCode( GET_VARIABLE );
    }
 
    public void setVariable() throws IOException
    {
        writeCode( SET_VARIABLE );
    }
 
    public void getURL( int sendVars, int loadMode ) throws IOException
    {
        writeCode( GET_URL_2 );
        mOut.writeUI16( 1 );

        int flags = 0;
        
        String sendVars_ = null;
        switch( sendVars )
        {
	        case SWFActions.GET_URL_SEND_VARS_GET:  flags = 1; break;
	        case SWFActions.GET_URL_SEND_VARS_POST: flags = 2; break;
	        
	        case SWFActions.GET_URL_SEND_VARS_NONE:
	        default: break;
        }
        
        String mode = null;
        switch( loadMode )
        {
	        case SWFActions.GET_URL_MODE_LOAD_MOVIE_INTO_LEVEL:  break;                
	        case SWFActions.GET_URL_MODE_LOAD_MOVIE_INTO_SPRITE: flags |= 0x40; break;
	        case SWFActions.GET_URL_MODE_LOAD_VARS_INTO_LEVEL :  flags |= 0x80; break;
	        case SWFActions.GET_URL_MODE_LOAD_VARS_INTO_SPRITE:  flags |= 0xC0; break;
	        default: break;
        }
        
        mOut.writeUI8( flags );        
    }
 
    public void gotoFrame( boolean play ) throws IOException
    {
        writeCode( GOTO_FRAME_2 );
        mOut.writeUI16( 1 );
        mOut.writeUI8( play ? 1 : 0 );
    }
  
    public void setTarget() throws IOException
    {
        writeCode( SET_TARGET_2 );
    }
 
    public void getProperty() throws IOException
    {
        writeCode( GET_PROPERTY );
    }
 
    public void setProperty() throws IOException
    {
        writeCode( SET_PROPERTY );
    }
 
    public void cloneSprite() throws IOException
    {
        writeCode( CLONE_SPRITE );
    }
 
    public void removeSprite() throws IOException
    {
        writeCode( REMOVE_SPRITE );
    }
 
    public void startDrag() throws IOException
    {
        writeCode( START_DRAG );
    }
   
    public void endDrag() throws IOException
    {
        writeCode( END_DRAG );
    }     
 
    public void trace() throws IOException
    {
        writeCode( TRACE );
    }     
 
    public void getTime() throws IOException
    {
        writeCode( GET_TIME );
    }     
 
    public void randomNumber() throws IOException
    {
        writeCode( RANDOM_NUMBER );
    }         
 
    public void lookupTable( String[] values ) throws IOException
    {
        writeCode( LOOKUP_TABLE );
        
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        OutStream bout = new OutStream( baout );
        
        bout.writeUI16( values.length );
        
        for( int i = 0; i < values.length; i++ )
        {
            bout.writeString( values[i], mStringEncoding );
        }

        bout.flush();
        byte[] data = baout.toByteArray();
        mOut.writeUI16( data.length );
        mOut.write( data );        
    }
   
    public void callFunction() throws IOException
    {
        writeCode( CALL_FUNCTION );
    }         
                                      
    public void callMethod() throws IOException
    {
        writeCode( CALL_METHOD );
    }         
   
    public SWFActionBlock startFunction( String name, String[] paramNames ) throws IOException
    {
        writeCode( DEFINE_FUNCTION );        
        
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        OutStream bout = new OutStream( baout );
        
        bout.writeString( name, mStringEncoding );
        bout.writeUI16( paramNames.length );
        
        for( int i = 0; i < paramNames.length; i++ )
        {
            bout.writeString( paramNames[i], mStringEncoding );
        }
        
        bout.flush();
        byte[] data = baout.toByteArray();
        mOut.writeUI16( data.length + 2 );
        mOut.write( data );
        
        int lengthAddr = mOut.getCount();
        mOut.writeUI16( 0 );  //code size - will be fixed up later
        
        BlockLengthFixer fixer = new BlockLengthFixer( lengthAddr );        
        mFixers.add( fixer );
        
        SWFActionBlock block = new SubBlockWriter( fixer, mOut, mByteOut, mFixers, mLabelToInfo, mActionCount, mFlashVersion );
        return block;
    }    
     
    public SWFActionBlock startFunction2( String name, 
								          int numRegistersToAllocate,
								          int preloadingFlags,
								          String[] paramNames,
								          int[] registersForArguments ) throws IOException {

        writeCode( DEFINE_FUNCTION_2 );        
        
        ByteArrayOutputStream baout = new ByteArrayOutputStream();
        OutStream bout = new OutStream( baout );
        
        bout.writeString( name, mStringEncoding );
        bout.writeUI16( paramNames.length );
        bout.writeUI8( numRegistersToAllocate );
        bout.writeUI16( preloadingFlags );
        
        for( int i = 0; i < paramNames.length; i++ )
        {
            bout.writeUI8( registersForArguments[i] );
            bout.writeString( paramNames[i], mStringEncoding );
        }

        bout.flush();
        byte[] data = baout.toByteArray();
        mOut.writeUI16( data.length + 2 );
        mOut.write( data );
        
        int lengthAddr = mOut.getCount();
        mOut.writeUI16( 0 );  //code size - will be fixed up later
        
        BlockLengthFixer fixer = new BlockLengthFixer( lengthAddr );        
        mFixers.add( fixer );
        

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -