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

📄 fsbutton.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * FSButton.java
 * Transform
 * 
 * Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification, 
 * are permitted provided that the following conditions are met:
 *
 *  * Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *  * 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.
 *  * Neither the name of Flagstone Software Ltd. nor the names of its contributors 
 *    may be used to endorse or promote products derived from this software 
 *    without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "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 COPYRIGHT OWNER OR CONTRIBUTORS 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.flagstone.transform;

/**
FSButton identifies the shape that is drawn when a button is in a particular state. 
 
<p>Shapes can be drawn for each of three button states, Over, Up and Down. Creating a button with more than one FSButton object each referencing a different shape allows the button to be animated as it is clicked.</p>

<p>A shape is also used to define active area of the button. When defining the active area the outline of the shape defines the boundary of the area. The shape is not drawn when the button is displayed. The button will only respond to mouse events when the cursor is placed inside the active area.</p>

<table class="datasheet">

<tr><th align="left" colspan="2">Attributes</th></tr>

<tr>
<td><a name="FSButton_0">state</a></td>
<td>the state(s) the button is in when the shape will be drawn, either Up, Over or Down. Active is used to denote when a shape defined the active area of a button.</td>
</tr>

<tr>
<td><a name="FSButton_1">identifier<a/></td>
<td>The identifier, in the range 1..65535, of the object that contains the definition of the shape that is drawn.</td>
</tr>

<tr>
<td><a name="FSButton_2">layer</a></td>
<td>The layer number defines the order in which shapes are displayed. Shapes with a higher layer number are displayed in front of those on a lower layer. Complex buttons can be created by displaying more than one shape for a given button state. The layer number may be in the range 1..65535 - the range is determined by the size of the field when the value is encoded to a Flash file - however the vast majority of buttons will typically only use layer numbers less than 10.</td>
</tr>

<tr>
<td><a name="FSButton_3">transform</a></td>
<td>an FSCoordTransform object that defines a coordinate transform that will be applied to the shape when it is displayed. The transform is most commonly used to offset shapes to create a 3-D appearance. The size may also be changed allowing a single shape definition to be used to display buttons in a range of sizes while still maintaining the same look and feel.</td>
</tr>

<tr>
<td><a name="FSButton_3">colorTransform</a></td>
<td>an optional FSColorTransform object that can be used to change the shape's 
colour when it is drawn.</td>
</tr>


</table>

<p>An FSButton can define the appearance of the button for more than one state. Multiple states can be defined by bitwise Or-ing individual state codes together:</p>

<pre>
int buttonState = FSButton.Up | FSButton.Over;
</pre>

<p>The purpose of the layer attribute is to define the order in which shapes are displayed for a given button state. This is analogous to the layer number in the Flash Player's display list - specified using objects such as FSPlaceObject. When a button is displayed it is placed on a single layer in the display list and the layer numbers assigned to shapes in a FSButton object do not interfere with shapes assigned to the same layer in the display list.</p>

<p>The coordinate transform is used to change the appearance of the button without changing the original shape definitions. If it is omitted then a unity transform will be encoded which does not change the way the shape is drawn.</p>

<h1 class="datasheet">History</h1>

<p>The FSButton class represents the ButtonRecord structure from the Macromedia Flash (SWF) File Format Specification. It was introduced in Flash 1.</p>

 */  
public class FSButton extends FSTransformObject
{
    /** Code for the button in the up state. */
    public static final int Up = 1;
    /** Code for the state of the button when the mouse is over the active area. */
    public static final int Over = 2;
    /** Code for the state of the button when the mouse is clicked the active area. */
    public static final int Down = 4;
    /** Code for the active area of the button. */
    public static final int Active = 8;
    
    private int state = 0;
    private int identifier = 0;
    private int layer = 0;
    
    private FSCoordTransform transform = null;
    private FSColorTransform colorTransform = null;

    /**
     * Construct an FSButton object, initalizing it with values decoded from
     * an encoded object.
     * 
     * @param coder an FSCoder containing the binary data.
     */
    public FSButton(FSCoder coder)
    {
        decode(coder);
    }
    /**  Constructs an FSButton object without a coordinate or colour transform that will be applied to the shape drawn for the button states. The transforms default to unity transforms which do not change the location of colour of the shape for the button.

        @param aState the state of the button when the shape is drawn.
        @param anIdentifier the identifier of an FSDefineShape, FSDefineShape2 or FSDefineShape3 object.
        @param aLayer the layer in the display list on which the shape is drawn.
        */
    public FSButton(int aState, int anIdentifier, int aLayer)
    {
        setState(aState);
        setIdentifier(anIdentifier);
        setLayer(aLayer);
        setTransform(new FSCoordTransform(0,0));
        setColorTransform(new FSColorTransform());
    }

    /**  Constructs an FSButton object with a coordinate transform that will be applied to the shape drawn for the button states.

        @param aState the state of the button when the shape is drawn.
        @param anIdentifier the identifier of an FSDefineShape, FSDefineShape2 or FSDefineShape3 object.
        @param aLayer the layer in the display list on which the shape is drawn.
        @param aTransform an FSCoordTransform object that changes the appearance of the shape when it is drawn.
        */
    public FSButton(int aState, int anIdentifier, int aLayer, FSCoordTransform aTransform)
    {
        setState(aState);
        setIdentifier(anIdentifier);
        setLayer(aLayer);
        setTransform(aTransform);
        setColorTransform(new FSColorTransform());
    }

    /**  Constructs an FSButton object with a coordinate and colour transform that will be applied to the shape drawn for the button states.

        @param aState the state of the button when the shape is drawn.
        @param anIdentifier the identifier of an FSDefineShape, FSDefineShape2 or FSDefineShape3 object.
        @param aLayer the layer in the display list on which the shape is drawn.
        @param aTransform an FSCoordTransform object that changes the appearance of the shape when it is drawn.
        @param aColorTransform an FSColorTransform object that changes the colour of the shape when it is drawn.
        */
    public FSButton(int aState, int anIdentifier, int aLayer, FSCoordTransform aTransform, FSColorTransform aColorTransform)
    {
        setState(aState);
        setIdentifier(anIdentifier);
        setLayer(aLayer);
        setTransform(aTransform);
        setColorTransform(aColorTransform);
    }
    /**
     * Constructs an FSButton object by copying values from an existing object.
     *
     * @param obj an FSButton object.
     */
    public FSButton(FSButton obj)
    {
        state = obj.state;
        identifier = obj.identifier;
        layer = obj.layer;
        transform = new FSCoordTransform(obj.transform);
        
        if (obj.colorTransform != null)
            colorTransform = new FSColorTransform(obj.colorTransform);
    }

    /** Get the state(s) of the button when the shape is drawn.

        @return the state of the button when the shape is drawn.
        */
    public int getState() { return state; }

    /** Does the Button Record defines a shape for the button's active area.

        @return a boolean flag indicating whether the button record defines the button's active area.
        */

⌨️ 快捷键说明

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