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

📄 fsmovie.java

📁 利用opensource的开源jar实现生成flash文件
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        return array;
    }

    static ArrayList decodeShape(byte[] bytes)
    {
        FSCoder coder = new FSCoder(FSCoder.LITTLE_ENDIAN, bytes);
        
        return decodeShape(coder);
    }
    
    static ArrayList decodeShape(FSCoder coder)
    {
        ArrayList objects = new ArrayList();
        
        int fillBits = coder.readBits(4, false);
        int lineBits = coder.readBits(4, false);

        coder.context[FSCoder.NumberOfFillBits] = fillBits;
        coder.context[FSCoder.NumberOfLineBits] = lineBits;

        while (coder.scanBits(6, false) > 0)
        {
            if ((coder.scanBits(6, false) & 0x20) > 0)
            {
                if ((coder.scanBits(6, false) & 0x10) > 0)
                    objects.add(new FSLine(coder));
                else
                    objects.add(new FSCurve(coder));
            }
            else
            {
                objects.add(new FSShapeStyle(coder));
            }
        }
    
        coder.adjustPointer(6); // Skip over end of shape marker
        coder.alignToByte();

        return objects;
    }
    
    private boolean decodeActions = true;
    private boolean decodeShapes = true;
    private boolean decodeGlyphs = true;
    
    private int identifier = 0;
    private String encoding = "UTF8";

    private String signature = "";
    private int version = Transform.VERSION;
    private FSBounds frameSize = null;
    private int length = 0;
    private float frameRate = 0.0f;
    private int frameCount = 0;
    
    private ArrayList objects = new ArrayList();

    /** Constructs an FSMovie object with no objects. The Flash version defaults to the package constant Transform.VERSION. From VERSION = 6 onwards the signature attribute defaults to "CWS" indicating that the binary data generated when a movie is encoded movie will be compressed using the zlib algorithm.

        */
    public FSMovie()
    {
        if (Transform.VERSION > 5)
            signature = "CWS";
        else
            signature = "FWS";
    }

    /** Constructs an FSMovie object with the specified bounding rectangle, frame rate and no objects. The Flash version defaults to the package constant Transform.VERSION. From VERSION = 6 onwards the signature attribute defaults to "CWS" indicating that the binary data generated when a movie is encoded movie will be compressed using the zlib algorithm.

        @param aBounds the bounding rectangle that defines the size of each frame in the coder.
        @param framesPerSecond the number of frames per second that the Player plays the movie at.
        */
    public FSMovie(FSBounds aBounds, float framesPerSecond)
    {
        if (Transform.VERSION > 5)
            signature = "CWS";
        else
            signature = "FWS";

        setFrameSize(aBounds);
        setFrameRate(framesPerSecond);
    }

    /** 
     * Constructs an FSMovie object with the specified signature, version, bounding rectangle, 
     * frame rate and array of objects.
     *
     * The signature controls whether the file will be compressed when encoded. If the signature is 
     * "FWS" the file will not be compressed. If the signature is "CWS" then the file will be 
     * compressed using the zlib algorithm after encoding. Note that compressed Flash files are 
     * only readable by a Flash Player that supports Flash from version 6 onwards.
     *
        @param encoding the format used to encode or decode strings.
        @param signature a string indicating that the file contains Flash data, 
        either "FWS" for uncompressed files or "CWS" for compressed files.
        @param version the version number of Flash implemented in this coder.
        @param aBounds the bounding rectangle that defines the size of each frame in the coder.
        @param framesPerSecond the number of frames per second that the Player plays the movie at.
        @param anArray the array of objects that define the coder.
        */
    public FSMovie(String encoding, String signature, int version, FSBounds aBounds, float framesPerSecond, ArrayList anArray)
    {
        setEncoding(encoding);
        setSignature(signature);
        setVersion(version);
        setFrameSize(aBounds);
        setFrameRate(framesPerSecond);
        setObjects(anArray);
    }

    /** Constructs an FSMovie object and decodes the contents of the specified 
     * 	file to generate an array of objects representing the Flash file. If 
     * an error occurs while reading and parsing the file then an exception is 
     * thrown.
     * 
     * @param fileName the path to the Flash file that will be parsed.
     * @throws FileNotFoundException - if an error occurs while reading the file.
     * @throws DataFormatException - if the file does not contain Flash data.
     * @throws FSCoderException - if an error occurs while decoding the file.
     * @throws IOException - if an I/O error occurs while reading the file.
     */
    public FSMovie(String fileName) throws IOException, DataFormatException
    {
        decodeFromFile(fileName);
    }
    /** 
     * Constructs an FSMovie object and decodes the contents of the specified 
     * file to generate an array of objects representing the Flash file. If 
     * an error occurs while reading and parsing the file a message is sent 
     * to the registered movie listener object.
     *
     * @param fileName the path to the Flash file that will be parsed.
     * @param listener an FSMovieListener object where errors messages are
     * sent.
     *
     * @deprecated
     */
    public FSMovie(String fileName, FSMovieListener listener)
    {
        decodeFromFile(fileName, listener);
    }

    /** 
     * Constructs an FSMovie object and decodes the binary data presented in the byte array to generate 
     * an array of objects representing the Flash data. If an error occurs while parsing the data then 
     * an Exception is thrown.
     *      
     * @param data an array of bytes containing the Flash binary data.
     * @throws DataFormatException - if the file does not contain Flash data.
     * @throws FSCoderException - if an error occurs while decoding the file.
     * @throws IOException - if an I/O error occurs while reading the file.
     */
    public FSMovie(byte[] data) throws DataFormatException, IOException
    {
        decodeFromData(data);
    }
    /** 
     * Constructs an FSMovie object and decodes the binary data presented in the byte 
     * array to generate an array of objects representing the Flash data. If an error 
     * occurs while parsing the data then a message is sent to the movie listener.
     *           
     * @param data an array of bytes containing the Flash binary data.
     * @param listener an FSMovieListener object where errors messages are
     * sent.
     *
     * @deprecated using the constructor FSMovie(byte[]) which throws an
     * exception if an error is detected.
     */
    public FSMovie(byte[] data, FSMovieListener listener)
    {
        decodeFromData(data, listener);
    }
    
    /** Returns a unique identifier for an object derived from the FSDefineObject class. In order to reference objects that define items such as shapes, sounds, etc. each must be assigned an identifier that is unique for a given Movie.

        When binary data is decoded into a sequence of objects, the Movie class tracks each Define tag decoded, recording the highest value. If a new Define tag is added to the array of decoded objects the identifier assigned to the new tag will be guaranteed to be unique.
        
        @return an unique identifier for objects that define shapes, sounds, etc. in a Flash file.
        */
    public synchronized int newIdentifier() 
    { 
        return ++identifier; 
    }

    /** Gets the current value for the unique identifier that will be assigned to definition objects (classes derived from the FSDefineObject class). The value returned is the last value requested using the newIdentifier() method.

        @return current value for the unique identifier.
        */
    public int getIdentifier()
    {
        return identifier;
    }

    /** Sets the initial value for the unique identifier assigned to definition objects. When a new identifier is requested the identifier is incremented before being returned. For most situations the method argument will be zero. This method should be used with caution as generating definition object with duplicate identifiers will most probably crash the program displaying the Flash file generated.

        @param aValue the initial value for the unique identifier.
        */
    public void setIdentifier(int aValue)
    {
        identifier = aValue;
    }

    /** 
     * Gets the encoding scheme for strings encoded and decoded from Flash files. The default 
     * encoding format is UTF8 which provides backward compatibility for Flash files that contain
     * ASCII encoded string. For files generated by internationalized versions of the Flash 
     * authoring tool any string recognised by the Java environment as identifying a character
     * encoding scheme may be used. For example, "SJIS" may be used to decode files generated 
     * using the Japanese language version of Flash - Version 5 or earlier.
     *
     * With the introduction of Flash 6 support for Unicode strings was added so the default 
     * encoding of UTF8 will be useful for most applications.
     *
     * @return the string identifying the format for strings. Any string recognised by the Java
     * environment may be used, "ASCII", "SJIS" and UTF8" will be the three most commonly used.
     */
    public String getEncoding()
    {
        return encoding;
    }

    /** 
     * Sets the encoding scheme for strings encoded and decoded from Flash files. For files 
     * generated by internationalized versions of the Flash authoring tool any string recognised
     * by the Java environment as identifying a character encoding scheme may be used. For example, 
     * "SJIS" may be used to decode files generated using the Japanese language version of 
     * Flash - Version 5 or earlier.
     *
     * @param encoding string identifying the format for strings. Any string recognised by the Java
     * environment may be used, "ASCII", "SJIS" and UTF8" will be the three most commonly used.
     */
    public void setEncoding(String encoding)
    {
        this.encoding = encoding;
    }

    public void setDecodeActions(boolean decode)
    {
        decodeActions = decode;
    }
    public boolean willDecodeActions()
    {
        return decodeActions;
    }
    public void setDecodeShapes(boolean decode)
    {
        decodeShapes = decode;
    }
    public boolean willDecodeShapes()
    {
        return decodeShapes;
    }
    public void setDecodeGlyphs(boolean decode)
    {
        decodeGlyphs = decode;
    }
    public boolean willDecodeGlyphs()
    {
        return decodeGlyphs;
    }
    /** 
     * Gets the signature identifying that the movie contains Flash. Up to version 5 the string
     * "FWS" identifies that data is encoded using the Flash file format. From Flash version 6 
     * onwards Flash data could also be compressed using the zlib algorithm to reduce the file 
     * size. A signature of "CWS" is used to denote that a file contain compressed Flash data.
     * The original signature "FWS" is still used to denote that a file contains uncompressed 
     * data.
     *
     * When encoding a FSMovie object the signature also determines whether the data generated
     * will be compressed.
     *
     * @return the string identifying the format for the encoded Flash data. 
     */
    public String getSignature()
    {
        return signature;
    }

    /** 
     * Sets the signature for the Flash data when it is encoded. The signature is used to control 
     * whether the encoded data will be compressed. If the signature is "CWS" then the movie 
     * data will be compressed. If the signature is "FWS" then the data will not be compressed.
     *
     * @param aString the signature used for the encoded Flash file.
     */
    public void setSignature(String aString)
    {
        signature = aString;
    }

    /** Gets the number representing the version of Flash that the movie represents.

        @return an integer defining the Flash version number for the coder.
        */
    public int getVersion()
    {
        return version;
    }

    /** Sets the Flash version supported in this Movie. Note that there are no restrictions on the objects that can be used in a coder. Using objects that are not supported by an earlier version of the Flash file format may cause the Player to not display the movie correctly or even crash the Player.

        @param aNumber the version of the Flash file format that this movie utilises.
        */
    public void setVersion(int aNumber)
    {
        version = aNumber;
    }

    /** Gets the bounding rectangle that defines the size of the player screen.

        @return the FSBounds object that defines the bounding rectangle that describes the size of each frame in the coder.
        */
    public FSBounds getFrameSize()
    {
        return frameSize;
    }

    /** Sets the bounding rectangle that defines the size of the player screen. The coordinates of the bounding rectangle are also used to define the coordinate range. For example if a 400 x 400 pixel  rectangle is defined, specifying the values for the x and y coordinates the range -200 to 200 sets the centre of the screen at (0,0), if the x and y coordinates are specified in the range 0 to 400 then the centre of the screen will be at (200, 200).

        @param aBounds the FSBounds object that defines the frame size.
        */

⌨️ 快捷键说明

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