Twitterのユーザーアイコンにgifアニメを使えるようにするswf
♥3 |
Line 50 |
Modified 2010-05-30 04:53:16 |
MIT License
archived:2017-03-09 02:32:16
ActionScript3 source code
/**
* Copyright zahir ( http://wonderfl.net/user/zahir )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/cL9F
*/
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="465" height="465">
<fx:Script>
<![CDATA[
/*
* Twitter のアイコンにアニメーションgifを適用できるようにする
* 只それだけ
*/
private var fr:FileReference;
private const type:Array = [ new FileFilter("load gif file","*.gif;*.GIF") ];
private var ba:ByteArray;
private var fileName:String = "";
private function start():void{
s_btn.enabled = false;
fr = new FileReference();
fr.addEventListener(Event.SELECT, onSelect );
fr.browse( type );
}
private function onSelect( e:Event ):void{
fr.removeEventListener( Event.SELECT, onSelect );
fr.addEventListener(Event.COMPLETE, onComp );
fr.load();
}
private function onComp( e:Event ):void{
fr.removeEventListener( Event.COMPLETE, onComp);
fileName = fr.name;
execute( fr.data );
}
private function execute( bytes:ByteArray ):void{
ba = new ByteArray();
bytes.readBytes( ba, 0, bytes.length - 1 );
ba.position = ba.length;
ba.writeByte(0x3C);
ba.writeByte(0x2C);
s_btn.enabled = true;
}
private function save():void{
fr = new FileReference();
fr.addEventListener(Event.SELECT, saveSelect);
fr.save(ba,fileName);
}
private function saveSelect(e:Event):void{
fr.removeEventListener(Event.SELECT, saveSelect);
}
]]>
</fx:Script>
<s:HGroup horizontalCenter="0" verticalCenter="0">
<s:Button label="Load gif file" click="start();"/>
<s:Button id="s_btn" enabled="false" click="save();" label="Save gif file"/>
</s:HGroup>
<s:Label text="Twitterにgifファイルをupできるようにします" horizontalCenter="0" verticalCenter="-50"/>
</s:Application>