forked from: forked from: アップロードした画像はBitmap化できない?
forked from forked from: アップロードした画像はBitmap化できない? (diff: 31)
ローカルでは出来た 謎です
Related images
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/oU0R
*/
// forked from zahir's forked from: アップロードした画像はBitmap化できない?
// ローカルでは出来た
// 謎です
package
{
import flash.display.Sprite;
import flash.display.Loader;
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.events.Event;
import flash.net.URLRequest;
import flash.text.TextField;
import flash.system.LoaderContext;
public class LoaderTest extends Sprite{
private var l:Loader;
private var bmp:Bitmap;
private var bd:BitmapData;
public function LoaderTest(){
var url:String = "http://assets.wonderfl.net/images/related_images/e/eb/ebe6/ebe6916059860d7a40eb32784ed6a71b58986239m";
l = new Loader();
l.contentLoaderInfo.addEventListener(Event.COMPLETE, onComp);
l.load( new URLRequest( url ) , new LoaderContext( true ));
var g:Graphics = this.graphics;
g.beginFill(0xFF0000);
g.drawRect(0,208, 20,20);
g.endFill();
}
private function onComp( e:Event ):void{
// 通常静止画を読んだ場合はBitmapになってるはず
var g:Graphics = this.graphics;
g.beginFill(0xFF00);
g.drawRect(20,l.height + 8, 20,20);
g.endFill();
if(l.content is Bitmap){
g.beginFill(0xFF);
g.drawRect(40,l.height + 8, 20,20);
g.endFill();
text();
var b:Bitmap = l.content as Bitmap;
addChild(b);
clone( b );
}
}
private function clone( data:Bitmap ):void{
bmp = new Bitmap( data.bitmapData.clone() );
bmp.x = data.width + 20;
addChild( bmp );
}
private function text():void{
var t:TextField = new TextField();
t.text = "Bitmapだったよ!"
addChild(t);
t.y = l.height + 30;
}
}
}