上代码:
- private static function start():void{
- var jpeg3Encoder:JPEG3Encoder = new JPEG3Encoder();
- var bitmapData:ByteArray = jpeg3Encoder.encode(_bitmap);
- var bitmapAlphaData:ByteArray = jpeg3Encoder.bitmapAlphaBytes;
- bitmapAlphaData.compress();
- //修改图片
- var jpg:TagDefineBitsJPEG3 = getPngTag();//new TagDefineBitsJPEG3();
- jpg.bitmapAlphaData = bitmapAlphaData;
- jpg.bitmapData = bitmapData;
- //修改文本内容
- var txt:TagDefineEditText = getTextTag();
- txt.initialText = _desc;
- txt.html = false;
- //写入SWF
- var ba:SWFData = new SWFData();
- defaultSwf.publish(ba);
- var swfStream:FileStream = new FileStream();
- swfStream.open(new File(_fileName), FileMode.WRITE);
- swfStream.writeBytes(ba);
- swfStream.close();
- //回调
- if(_callBack != null ) _callBack.call();
- }
- private static function getTextTag():TagDefineEditText{
- for(var i:int=0;i<defaultSwf.tags.length;i++){
- if(defaultSwf.tags[i] is TagDefineEditText){
- return defaultSwf.tags[i] as TagDefineEditText;
- }
- }
- return null;
- }
- private static function getPngTag():TagDefineBitsJPEG3{
- for(var i:int=0;i<defaultSwf.tags.length;i++){
- if(defaultSwf.tags[i] is TagDefineBitsJPEG3){
- return defaultSwf.tags[i] as TagDefineBitsJPEG3;
- }
- }
- return null;
- }
在用AIR生成SWF过程中测试过很多种方法,都不能满足要求,最后想到的办法就是用一个模块,里面放罢了一个图形,连接名为bmp 再放一个text 属性名为txt 然后通过SWFData将SWF中的内容读出来,再对里面的tag进入修改,最后保存以达到了我的要求
要用到的资源包就是SWFDATA