amazon的なやつ CLICKで画像拡大
http://blog.boreal-kiss.com/2008/05/09185722.html
外部ファイルを表示するだけならloaderでOK
↓
しかし,いじる場合はエラーw
↓
crossdomain.xml めんどくせぇ…
↓
loader2重で行けるとかくぁwせdrftgyふじこlp;@:「」
↓
こんな感じ
↓参考にしました
http://wonderfl.net/c/d8DH/
//http://blog.boreal-kiss.com/2008/05/09185722.html
//外部ファイルを表示するだけならloaderでOK
//↓
//しかし,いじる場合はエラーw
//↓
//crossdomain.xml めんどくせぇ…
//↓
//loader2重で行けるとかくぁwせdrftgyふじこlp;@:「」
//↓
//こんな感じ
//↓参考にしました
//http://wonderfl.net/c/d8DH/
package {
import flash.net.URLRequest;
import flash.display.Loader;
import flash.display.Shape;
import flash.events.Event;
import flash.display.Sprite;
import flash.events.MouseEvent;
[SWF(backgroundColor=0xffffff,width=500,height=400,frameRate=30)]
public class FlashTest extends Sprite {
private var biFlag:Boolean = false;
private var imgArray:Array = new Array();
private var s:Sprite = new Sprite();
private var s1:Sprite = new Sprite();
private var urlArray:Array = ["http://ec3.images-amazon.com/images/I/410eIqft8%2BL._SL500_AA300_.jpg",
"http://ec3.images-amazon.com/images/I/31KQwxWXe3L._SL500_AA300_.jpg",
"http://ec3.images-amazon.com/images/I/415xG7a0ZDL._SL500_AA300_.jpg",
"http://ecx.images-amazon.com/images/I/41A79nE6RoL._SL500_PIsitb-sticker-arrow-big,TopRight,35,-73_SL135_OU09_.jpg",
"http://ecx.images-amazon.com/images/I/51V0s3h9fGL._SL160_SL125_.jpg",
"http://ec2.images-amazon.com/images/I/41TtzIVD3KL._SL500_AA300_.jpg",
"http://ec2.images-amazon.com/images/I/51bTAE%2B2KhL._SL500_AA300_.jpg"
];
public function FlashTest() {
s1.addEventListener(MouseEvent.CLICK, closeImage);
for(var n:int = 0;n < urlArray.length;n++){
var icon:Icon = new Icon(urlArray[n]);
icon.addEventListener(MouseEvent.CLICK, BigImage);
imgArray.push(icon);
}
for(n = 0;n < imgArray.length;n++){
imgArray[n].degree = -360 * n / imgArray.length;
imgArray[n].N = n;
}
addChild(s);
this.addEventListener(Event.ENTER_FRAME, front);
}
private function BigImage(e:MouseEvent):void
{
if(biFlag == false){
biFlag = true;
var loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.INIT, s1_patch);
var icon:Icon = e.target as Icon;
loader.load(new URLRequest(urlArray[icon.N]));
s1.addChildAt(loader, 0);
addChild(s1);
}
}
private function s1_patch(e:Event):void{
s1.x = 250 - e.target.width / 2;
s1.y = 200 - e.target.height/ 2;
}
private function closeImage(e:MouseEvent):void{
if(biFlag){
biFlag = false;
s1.graphics.clear();
s1.removeChildAt(0);
}
}
private function front(e:Event):void{
imgArray.sort(sortOnZ);
for(var i:int = 0;i < imgArray.length;i++){
s.addChildAt(imgArray[i] as Sprite, i);
}
}
private function sortOnZ(a:Icon, b:Icon):Number {
var aZ:Number = a.z;
var bZ:Number = b.z;
if(aZ < bZ) {
return 1;
} else if(aZ > bZ) {
return -1;
} else {
return 0;
}
}
}
}
import flash.display.*;
import flash.events.*;
import flash.filters.*;
import flash.geom.*;
import flash.net.*;
import flash.system.*;
import flash.text.*;
import flash.utils.*;
class Icon extends Sprite{
private var img:Bitmap;
private var initialX:Number;
private var loader:Loader;
private var loader2:Loader;
private const SIZE:int = 100;
public var degree:Number = 0;
public var N:int;
public function Icon(str:String):void{
img = new Bitmap();
loader = new Loader();
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, function():void { } );
loader.contentLoaderInfo.addEventListener(Event.INIT,init);
loader.load(new URLRequest(str), new LoaderContext(true));
}
private function init(e:Event):void{
loader2 = new Loader();
loader2.contentLoaderInfo.addEventListener(Event.INIT, initCOMP);
loader2.loadBytes(loader.contentLoaderInfo.bytes);
}
private function initCOMP(e:Event):void{
var l:Loader = e.currentTarget.loader;
var scale:Number = 0;
if(loader.height > SIZE){
if (loader.width < loader.height) scale = SIZE / loader.height;
else scale = SIZE / loader.width;
}else{
scale = 1;
}
var matrix:Matrix = new Matrix();
matrix.scale(scale, scale);
var bd:BitmapData = new BitmapData(scale * loader.width, scale * loader.height, false);
bd.draw(l, matrix);
img = new Bitmap(bd);
addChild(img);
//Reflect
var reverse:BitmapData = img.bitmapData.clone();
var reverseImg:Bitmap = new Bitmap(reverse);
reverseImg.scaleY = -1;
reverseImg.x = img.x;
reverseImg.y = img.height*2;
addChild(reverseImg);
reverseImg.filters = [rFilter(0.95)];
var degree:Number = 0;
addEventListener(Event.ENTER_FRAME, Circle);
}
private function Circle(e:Event):void{
degree-=0.5;
if(degree == -360)degree = 0;
e.target.x = 190 + 170 * Math.cos(Math.PI / 180 * degree);
e.target.y = 150 + 35 * Math.sin(Math.PI / 180 * degree);
e.target.z = -15 * Math.sin(Math.PI / 180 * degree);
}
private function rFilter(n:Number):ColorMatrixFilter{
var M:Array = new Array();
M = M.concat([n, 0, 0, 0, 0]);
M = M.concat([0, n, 0, 0, 0]);
M = M.concat([0, 0, n, 0, 0]);
M = M.concat([0, 0, 0, 0.3, 0]);
return new ColorMatrixFilter(M);
}
}