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

📄 fsclipevent.java

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

    /** Adds an action to the array of actions.
        
        @param anAction a pointer to an action object.
        */
    public void add(FSActionObject anAction)
    {
        if (encodedActions != null)
        {
            actions = FSMovie.decodeActions(encodedActions);
            encodedActions = null;
        }            
        actions.add(anAction);
    }

    /** Sets the event code that this FSClipEvent defines actions for.

        @param aNumber the code representing one or more events.
        */
    public void setEvent(int aNumber)
    {
        event = aNumber;
    }

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

        @return the eventCode representing the events that the FSClipEvent object will respond to.
        */
    public int getEvent()
    {
        return event;
    }

// Flash 6
    /** Gets the code for the key that triggers the event when pressed. The code 
     *  is typically the ASCII code for standard western keyboards.
     * 
     *  @return the code for the key that triggers the event.
     */
    public int getKeyCode()
    {
        return keyCode;
    }

    /** Sets the code for the key that triggers the event when pressed. The code 
     *  is typically the ASCII code for standard western keyboards.
     * 
     *  @param code the ASCII code for the key that triggers the event.
     */
    public void setKeyCode(int code)
    {
        keyCode = code;
    }
// End Flash 6

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

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

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

        @return the array of actions that will be executed when the specified event occurs.
        */   
    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;
    }
    /** 
     * 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()
    {
        FSClipEvent anObject = (FSClipEvent)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))
        {
            FSClipEvent typedObject = (FSClipEvent)anObject;
            
            result = event == typedObject.event;              
// Flash 6
            result = result && keyCode == typedObject.keyCode;              
// End Flash 6
            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);
// Flash 6
            Transform.append(buffer, "keyCode", keyCode);
// End Flash 6
            if (actions != null)
                Transform.append(buffer, "actions", actions, depth);
            else
                buffer.append("actions = <data>; ");
                
            buffer.append("}");
        }
    }

    public int length(FSCoder coder)
    {
        int length = 4 + ((coder.context[FSCoder.Version] > 5) ? 4 : 2);
    
// Flash 6
        length += ((event & KeyPress) != 0) ? 1 : 0;
// End Flash 6
    
        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)
    {
        int eventSize = (coder.context[FSCoder.Version] > 5) ? 4 : 2;
        
        int offset = 1; // End of actions marker
        
        if (actions != null)
        {        
            for (Iterator i = actions.iterator(); i.hasNext();)
            {
                FSActionObject currentAction = (FSActionObject)i.next();
            
                offset += currentAction.getLength();
                offset += (currentAction.getType() > 128) ? 3 : 1;
            }
        }
        else
        {
            offset += encodedActions.length;
        }

// Flash 6
        offset += ((event & KeyPress) != 0) ? 1 : 0;
// End Flash 6
            
        coder.writeWord(event, eventSize);
        coder.writeWord(offset, 4);
            
// Flash 6
        if ((event & KeyPress) != 0)
            coder.writeWord(keyCode, 1);
// End Flash 6
        
        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)
    {
        int eventSize = (coder.context[FSCoder.Version] > 5) ? 4 : 2;

        event = coder.readWord(eventSize, false);
        int length = coder.readWord(4, false);

// Flash 6
        if ((event & KeyPress) != 0) {
            keyCode = coder.readWord(1, false);
            length -= 1;
        }
// End Flash 6
    
        if (coder.context[FSCoder.DecodeActions] == 1)
        {
            actions = FSMovie.decodeActions(coder);
        }
        else
        {
            encodedActions = new byte[length-1];
            coder.readBytes(encodedActions);
        }
        coder.readWord(1, false);
    }
}

⌨️ 快捷键说明

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