📄 movieclip.java
字号:
/*
* MovieClips.java
* Examples
*
* Created by Stuart MacKay on Fri Jul 25 2003.
* Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved.
*
* This code is distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND Flagstone HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING
* WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
* PURPOSE, AND NONINFRINGEMENT OF THIRD PARTY RIGHTS.
*/
package com.flagstone.transform.examples;
import com.flagstone.transform.*;
import java.util.*;
/*
* This example shows some of the basic objects used to create a movie.
*
* To run this example, type the following on a command line:
*
* java MovieClip [--resultDir path]
*
* where
*
* resultDir is the directory where the Flash file generated by the example is
* written to.
*/
public class MovieClip extends Example
{
public static void main(String[] args)
{
new MovieClip(args);
}
public MovieClip(String[] args)
{
super(args);
createMovie();
writeFile("MovieClip.swf");
}
public void createMovie()
{
/*
* The movie bounds are specified in twips. The bounding rectangle is defined
* by two points: the lower left corner and the upper right corner of the
* rectangle that encloses the area.
*
* The bounding rectangle also defines the coordinate range for the x and y axes.
* Here the coordinates for the x and y axes range from -200 to +200. A point with
* the coordinates (0,0) lies in the center of the screen.
*
* If the coordinates of the corners were specified as (0,0) and (400, 400) the
* size of the screen is still the same however the center of the screen now
* lies at (200,200)
*/
int xLower = 0;
int yLower = 0;
int xUpper = 8000;
int yUpper = 8000;
/*
* Set the frame rate at which the movie will be played.
*/
float framesPerSecond = 1.0f;
movie.setFrameRate(framesPerSecond);
movie.setFrameSize(new FSBounds(xLower, yLower, xUpper, yUpper));
/*
* Set the movie's background colour to light blue. The background colour
* only be set once and should be the first object added to a movie. If no
* background colour is specified then the Flash Player will set it to white.
*/
movie.add(new FSSetBackgroundColor(FSColorTable.lightblue()));
/*
* Define a shape to be displayed. Each object must be assigned a unique identifier
* which is used to reference the object when adding, updating or removing it from
* the display list. The movie object keeps track of the identifier to guarantee
* each is unique.
*/
int identifier = movie.newIdentifier();
int width = 4000;
int height = 4000;
FSBounds bounds = new FSBounds(-2000, -2000, 2000, 2000);
ArrayList lineStyles = new ArrayList();
ArrayList fillStyles = new ArrayList();
lineStyles.add(new FSSolidLine(20, FSColorTable.black()));
fillStyles.add(new FSSolidFill(FSColorTable.red()));
/*
* Create the outline of the shape.
*/
ArrayList shapeRecords = new ArrayList();
shapeRecords.add(new FSShapeStyle(1, 1, 0, -width/2, -height/2));
shapeRecords.add(new FSLine(width, 0));
shapeRecords.add(new FSLine(0, height));
shapeRecords.add(new FSLine(-width, 0));
shapeRecords.add(new FSLine(0, -height));
FSDefineShape rectangle = new FSDefineShape(identifier, bounds, fillStyles, lineStyles, new FSShape(shapeRecords));
/*
* Add the rectangle to the movie. All shapes and objects must be defined before
* they can be placed on the display list and renderend on the Flash Player's
* screen.
*/
movie.add(rectangle);
ArrayList clipMovements = new ArrayList();
clipMovements.add(new FSPlaceObject2(identifier, 1, 0, 0));
clipMovements.add(new FSShowFrame());
FSDefineMovieClip clip1 = new FSDefineMovieClip(movie.newIdentifier(), clipMovements);
movie.add(clip1);
/*
* Place the shape on the display list. See the DisplayList example for the set of
* objects that are used to add, update and remove objects from the display list.
*/
movie.add(new FSPlaceObject2(clip1.getIdentifier(), 2, 4000, 4000));
/*
* Create the second rectangle.
*/
bounds = new FSBounds(-2000, -2000, 2000, 2000);
lineStyles = new ArrayList();
fillStyles = new ArrayList();
lineStyles.add(new FSSolidLine(20, FSColorTable.black()));
fillStyles.add(new FSSolidFill(FSColorTable.blue()));
/*
* Create the outline of the shape.
*/
shapeRecords = new ArrayList();
shapeRecords.add(new FSShapeStyle(1, 1, 0, -width/2, -height/2));
shapeRecords.add(new FSLine(width, 0));
shapeRecords.add(new FSLine(0, height));
shapeRecords.add(new FSLine(-width, 0));
shapeRecords.add(new FSLine(0, -height));
rectangle = new FSDefineShape(movie.newIdentifier(), bounds, fillStyles, lineStyles, new FSShape(shapeRecords));
/*
* Add the rectangle to the movie. All shapes and objects must be defined before
* they can be placed on the display list and renderend on the Flash Player's
* screen.
*/
movie.add(rectangle);
clipMovements = new ArrayList();
clipMovements.add(new FSPlaceObject2(clip1.getIdentifier(), 1, 0, 0));
clipMovements.add(new FSShowFrame());
FSDefineMovieClip clip = new FSDefineMovieClip(movie.newIdentifier(), clipMovements);
movie.add(clip);
/*
* Place the shape on the display list. See the DisplayList example for the set of
* objects that are used to add, update and remove objects from the display list.
*/
movie.add(new FSPlaceObject2(clip.getIdentifier(), 3, 5000, 5000));
/*
* Show the contents of the display list. Frames are delimited by successive
* FSShowFrame objects.
*/
movie.add(new FSShowFrame());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -