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

📄 fsbuttonevent.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
    {
        event = obj.event;
        
        if (obj.actions != null)
        {
            actions = new ArrayList();
            
            for (Iterator i = obj.actions.iterator(); i.hasNext();)
                actions.add(((FSActionObject)i.next()).clone());
        }
        else
        {
            encodedActions = Transform.clone(obj.encodedActions);
        }
    }


    /** Add an action to the end of the actions array.
        
        @param anAction an object derived from the base class FSActionObject.
        */
    public void add(FSActionObject anAction)
    {
        if (encodedActions != null)
        {
            actions = FSMovie.decodeActions(encodedActions);
            encodedActions = null;
        }            
        actions.add(anAction);
    }

    /** Gets the event code that this FSButtonEvent defines actions for.

        @return the compound event code.
        */
    public int getEvent()
    {
        return event;
    }

    /** Gets the array of actions that are executed by the button in response to specified event(s).

        @return the array of action objects that will be executed when the specified event(s) occur.
        */   
    public ArrayList getActions()
    {
        if (encodedActions != null)
        {
            actions = FSMovie.decodeActions(encodedActions);
            encodedActions = null;
        }
        return actions;
    }

    /** 
     * 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;
    }
    /** Sets the event code that this FSButtonEvent defines actions for.

        @param aNumber the event code.
        */
    public void setEvent(int aNumber)
    {
        event = aNumber;
    }

    /** Sets the array of actions that are executed by the button in response to specified event(s).

        @param anArray the array of action objects that will be executed when the specified event(s) occur.
        */  
    public void setActions(ArrayList anArray)
    {
        actions = anArray;
        encodedActions = null;
    }

    /** 
     * Set the array of encoded actions 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()
    {
        FSButtonEvent anObject = (FSButtonEvent)super.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;
    }

    /** 
     * Returns true if anObject is equal to this one. Objects are considered 
     * equal if they would generate identical binary data when they are encoded 
     * to a Flash file.
     *
     * @return true if this object would be identical to anObject when encoded.
     */
    public boolean equals(Object anObject)
    {
        boolean result = false;
        
        if (super.equals(anObject))
        {
            FSButtonEvent typedObject = (FSButtonEvent)anObject;
            
            result = event == typedObject.event;                

            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, "event", event);

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

            buffer.append("}");
        }
    }
    
    public int length(FSCoder coder)
    {
        int length = 2;
    
        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)
    {
        coder.writeWord(event, 2);

        if (actions != null)
        {
            for (Iterator i=actions.iterator(); i.hasNext();)
            {
                FSActionObject action = (FSActionObject)i.next();
                
                int objStart = coder.getPointer();
                int length = action.getLength();
                int start = coder.getPointer() + ((action.getType() > 128) ? 24 : 8);
                int next = start + (length << 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);
    }
    
    public void decode(FSCoder coder)
    {
        event = coder.readWord(2, false);
        
        if (coder.context[FSCoder.DecodeActions] == 1)
        {
            actions = FSMovie.decodeActions(coder);
        }
        else
        {
            coder.readBytes(encodedActions);
        }
        coder.readWord(1, false);
    }
}

⌨️ 快捷键说明

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