当前位置: 首页 > 工具软件 > JSwiff > 使用案例 >

java flash jswiff_jswiff 下载-Java的Flash类库(JSwiff)8.0 官网最新版-东坡下载

宰父俊彦
2023-12-01

JSwiff是一款开源的,基于Java的操作Macromedia Flash file 的框架,可以创建,和操作Flash文件。JSwiff还提供了JSwiff Investigator,可以直接分析现有的SWF文件的结构,得到Tag层次的信息..

其他不多说,喜欢的人自己可以到该网站去了解,下面我就拿出一个例子来。呵~~从官方那边修改过来的,我就不多做解释了(呵~人家说得很明白啦,虽然有点烦琐)

Java的Flash类库(JSwiff)用法

import java.io.FileOutputStream;

import java.io.IOException;

import com.jswiff.SWFWriter;

import com.jswiff.SWFDocument;

import com.jswiff.swfrecords.Rect;

import com.jswiff.swfrecords.RGBA;

import com.jswiff.swfrecords.Matrix;

import com.jswiff.swfrecords.tags.DefineFont2;

import com.jswiff.swfrecords.tags.DefineEditText;

import com.jswiff.swfrecords.tags.PlaceObject2;

import com.jswiff.swfrecords.tags.ShowFrame;

public class CreateSwf

{

public static void main(String[] args)

{

String fileName = "test.swf";

SWFDocument document = new SWFDocument();

// first we define a font for the text

// get a character ID for the font

int fontId = document.getNewCharacterId();

// use a standard font (e.g. Arial), we don't want to define shapes for each glyph

DefineFont2 defineFont2 = new DefineFont2(fontId, "Arial", null, null);

document.addTag(defineFont2);

// get a character ID for our text

int textId = document.getNewCharacterId();

// dynamic text is a good way to go, we use DefineEditText for this

// we don't care about bounds and variables

DefineEditText defineEditText = new DefineEditText(

textId, new Rect(0, 0, 0, 0), null);

// we have set the text bounds to a zero rectangle;

// to see the whole text, we set the autosize flag

defineEditText.setAutoSize(true);

// assign the font defined above to the text, set font size to 24 px (in twips!)

defineEditText.setFont(fontId, 20 * 24);

// set text color to red

defineEditText.setTextColor(new RGBA(255, 0, 0, 255));

// don't let viewers mess around with our text

defineEditText.setReadOnly(true);

// finally set the text

defineEditText.setInitialText("弃天笑(soda) test!");

document.addTag(defineEditText);

// place our text at depth 1

PlaceObject2 placeObject2 = new PlaceObject2(1);

placeObject2.setCharacterId(textId);

// place text at position (45; 10) (in twips!)

placeObject2.setMatrix(new Matrix(20 * 45, 20 * 10));

document.addTag(placeObject2); // place text

document.addTag(new ShowFrame()); // show frame

try

{

writeDocument(document, fileName);

}

catch (IOException e)

{

System.out.println("An error occured while writing " + fileName + ":");

e.printStackTrace();

}

}

private static void writeDocument(SWFDocument document, String fileName)

throws IOException

{

SWFWriter writer = new SWFWriter(document, new FileOutputStream(fileName));

writer.write();

}

}

PC官方版

安卓官方手机版

IOS官方手机版

 类似资料: