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

📄 fsdefinebutton.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        {
            actions = FSMovie.decodeActions(encodedActions);
            encodedActions = null;
        }            
        actions.add(anAction);
    }

    /** Gets the array of button records defined for this button.

        @return the array of FSButton objects defined for this button.
        */
    public ArrayList getButtonRecords() { return buttonRecords; }

    /** Gets the array of actions that will be executed when the button is clicked and released.

        @return the array of action objects defined for this button.
        */
    public ArrayList getActions() 
    { 
        if (encodedActions != null)
        {
            actions = FSMovie.decodeActions(encodedActions);
            encodedActions = null;
        }
        return actions;
    }

    /** Sets the array of button records defined for this button.

        @param anArray an array of FSButton objects.
        */
    public void setButtonRecords(ArrayList anArray)
    {
        buttonRecords = anArray;
    }

    /** Sets the array of actions that will be executed when the button is clicked and released.

        @param anArray and array of action objects.
        */
    public void setActions(ArrayList anArray)
    {
        actions = anArray;
        encodedActions = null;
    }

    /** 
     * Get the array of encoded actions that are executed when the frame is displayed.
     *
     * @return the array of action objects or null if the actions have been
     * decoded.
     */
    public byte[] getEncodedActions() 
    { 
        return encodedActions;
    }
    /** 
     * Set the array of encoded actions that will be executed when the button is 
     * clicked and released. The encoded actions are typically generated by the 
     * classes in the Translate framework. If the object already contains an 
     * array of actions then they will be deleted.
     * 
     * @param bytes the array of encoded actions.
     */
    public void setEncodedActions(byte[] bytes)
    {
        encodedActions = bytes;
        actions = null;
   }

    public Object clone()
    {
        FSDefineButton anObject = (FSDefineButton)super.clone();
        
        anObject.buttonRecords = new ArrayList();
            
        for (Iterator i = buttonRecords.iterator(); i.hasNext();)
            anObject.buttonRecords.add(((FSButton)i.next()).clone());

        if (actions != null)
        {
            anObject.actions = new ArrayList();
            
            for (Iterator i = actions.iterator(); i.hasNext();)
                anObject.actions.add(((FSActionObject)i.next()).clone());
        }
        else
        {
            anObject.encodedActions = Transform.clone(encodedActions);
        }
        
        return anObject;
    }

    public boolean equals(Object anObject)
    {
        boolean result = false;
        
        if (super.equals(anObject))
        {
            FSDefineButton typedObject = (FSDefineButton)anObject;
            
            if (buttonRecords != null)
                result = buttonRecords.equals(typedObject.buttonRecords);
            else
                result = buttonRecords == typedObject.buttonRecords;

            if (actions != null)
                result = actions.equals(typedObject.actions);
            else
                result = Transform.equals(encodedActions, typedObject.encodedActions);
        }
        return result;
    }

    public void appendDescription(StringBuffer buffer, int depth)
    {
        buffer.append(name());
        
        if (depth > 0)
        {
            buffer.append(": { ");
            Transform.append(buffer, "buttonRecords", buttonRecords, depth);

            if (actions != null)
                Transform.append(buffer, "actions", actions, depth);
            else
                buffer.append("actions = <data>; ");

            buffer.append("}");
        }
    }

    public int length(FSCoder coder)
    {
        super.length(coder);
    
        for (Iterator buttonIterator = buttonRecords.iterator(); buttonIterator.hasNext();) 
            length += ((FSTransformObject)buttonIterator.next()).length(coder);

        length += 1;
    
        if (actions != null)
        {
            for (Iterator i = actions.iterator(); i.hasNext();)
            {
                FSActionObject currentAction = (FSActionObject)i.next();
            
                length += currentAction.length(coder);
                length += (currentAction.getType() > 128) ? 3 : 1;
            }
        }
        else
        {
            length += encodedActions.length;
        }
        length += 1;

        return length;
    }
    
    public void encode(FSCoder coder)
    {
        super.encode(coder);
        
        for (Iterator buttonIterator = buttonRecords.iterator(); buttonIterator.hasNext();) 
            ((FSTransformObject)buttonIterator.next()).encode(coder);

        coder.writeWord(0, 1);
    
        if (actions != null)
        {
            for (Iterator i=actions.iterator(); i.hasNext();)
            {
                FSActionObject action = (FSActionObject)i.next();
                    
                int objStart = coder.getPointer();
                int start = coder.getPointer() + ((action.getType() > 128) ? 24 : 8);
                int next = start + (action.getLength() << 3);
                
                action.encode(coder);
                coder.setPointer(next);
                
                int delta = (coder.getPointer() - next) >> 3;
                
                if (delta != 0)
                {
                    coder.context[FSCoder.CodingError] = 1;
                    coder.context[FSCoder.TypeInError] = action.getType();
                    coder.context[FSCoder.StartOfError] = objStart >>> 3;
                    coder.context[FSCoder.ExpectedLength] = (next-objStart)>>>3;
                    coder.context[FSCoder.Delta] = delta;
                }
            }
        }
        else
        {
            coder.writeBytes(encodedActions);
        }
        coder.writeWord(0, 1);
        coder.endObject(name());
    }
    
    public void decode(FSCoder coder)
    {
        super.decode(coder);
        
        int start = coder.getPointer();
        
        buttonRecords = new ArrayList();
        
        while (coder.scanWord(1, false) != 0)
            buttonRecords.add(new FSButton(coder));
            
        coder.readWord(1, false); // character end
        
        if (coder.context[FSCoder.DecodeActions] == 1)
        {
            actions = FSMovie.decodeActions(coder);
        }
        else
        {
            encodedActions = new byte[((coder.getPointer()-start) >>> 3)-1];
            coder.readBytes(encodedActions);
        }
        coder.readWord(1, false);
        coder.endObject(name());
    }
}

⌨️ 快捷键说明

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