jswiff,生成flash文件的java框架

JSwiff 是一款开源的,基于Java的操作Macromedia Flash file 的框架,可以创建,和操作Flash文件。
JSwiff 还提供了JSwiff Investigator,可以直接分析现有的SWF文件的结构,得到Tag层次的信息..
Jswiff是完全开源的,基于dual license (GPL/commercial).
官方网站是 http://www.jswiff.com/
呵呵~看到这个消息兴奋吧,根据信息生成swf,难以想象,RIA,哈哈(虽然目前这个软件不是很完善,即使有flex可以根据xml生成swf)
其他不多说,喜欢的人自己可以到该网站去了解,下面我就拿出一个例子来。呵~~从官方那边修改过来的,我就不多做解释了(呵~人家说得很明白啦,虽然有点烦琐)
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"nullnull);
  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(0000), 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(25500255));
  
// 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 * 4520 * 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();
}

}


呵~记得把jswiff-8.0-beta-2.jar配置进环境变量哦。接着编译运行,就会产生一个test.swf文件啦。哈哈,赶快运行
 
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值