copyPixelsの練習
/**
* Copyright hacker_cobulht0 ( http://wonderfl.net/user/hacker_cobulht0 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/uCTL
*/
//クリックでcopyPixels
//左下のひよこボタンでアルバム 増えてくだけ
package {
import flash.display.Sprite;
import flash.display.Shape;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.events.*;
import flash.display.Loader;
import flash.net.URLRequest;
import flash.geom.*;
import flash.system.*;
// Tweener
import caurina.transitions.Tweener;
[SWF(width = "465", height = "465", backgroundColor = 0xffffff, frameRate = "60")]
public class Chick_Albam extends Sprite{
private var photo_List:Vector.<Sprite>=new Vector.<Sprite>();
public var myLoader:Loader = new Loader();
private var bg_bmd:BitmapData;
private var bg_sp:Sprite=new Sprite();
private var photoWaq:Shape=new Shape();
private var albam:Albam=new Albam();
private var ck:Boolean=false;
private var shutter:Boolean=false;
private var shutterFO:picShutter=new picShutter();
public function Chick_Albam(){
if (stage) init();else addEventListener(Event.ADDED_TO_STAGE,init );
}
public function init(ev:Event = null){
removeEventListener( Event.ADDED_TO_STAGE, init ) ;
myLoader.load(new URLRequest("http://assets.wonderfl.net/images/related_images/8/8e/8ee5/8ee566ab5a4789ac2c26475f244b840ba083e99d"), new LoaderContext(true));
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,ready);
addChild(bg_sp);
addChild(photoWaq);
addChild(albam);
albam.y=465;
albam.btClose.addEventListener(MouseEvent.MOUSE_UP, function(ev){Tweener.addTween(albam, {y:465, time:0.8,transition:"easeOutQuad"});});
albam.btAlbam.addEventListener(MouseEvent.MOUSE_UP, function(ev){Tweener.addTween(albam, {y:0, time:0.8,transition:"easeOutQuad"});});
addChild(shutterFO);
shutterFO.alpha=0;
}
private function ready(ev){
var kari:Sprite = new Sprite();
bg_bmd = new BitmapData(myLoader.width, myLoader.height, false, 0xffffff);
kari.addChild(myLoader);
bg_bmd.draw(kari);
bg_sp.addChild(new Bitmap(bg_bmd));
addEventListener(MouseEvent.MOUSE_DOWN, ckON);
addEventListener(MouseEvent.MOUSE_UP, ckOFF);
addEventListener(Event.ENTER_FRAME,_Camera_);
}
private function ckON(ev){if(albam.y==465&&albam.btAlbam.alpha==1){ck=true;}}//albamのy位置&アルバムボタンに触れてないかで決める
private function ckOFF(ev){ck=false;}
private function _Camera_(ev){
if(ck){
shutter=true;
photoWaq.graphics.clear();
photoWaq.graphics.lineStyle(2, 0xFF496C);
photoWaq.graphics.drawRoundRect(mouseX-80, mouseY-50,160, 100, 5);
photoWaq.graphics.moveTo(mouseX-5,mouseY);
photoWaq.graphics.lineTo(mouseX+5,mouseY);
photoWaq.graphics.moveTo(mouseX,mouseY-5);
photoWaq.graphics.lineTo(mouseX,mouseY+5);
photoWaq.graphics.endFill();
photoWaq.graphics.lineStyle(2, 0xFD5E53);
photoWaq.graphics.drawRoundRect(mouseX-77, mouseY-47,154, 94, 10);
photoWaq.graphics.endFill();
}else{
if(shutter){
shutter=false;
shutterFO.x=mouseX-80;
shutterFO.y=mouseY-50;
shutterFO.alpha=1;
Tweener.addTween(shutterFO, {alpha:0,time:1,transition:"easeOutQuad"});
var photo:Sprite=new Sprite();
var copy_bmd: BitmapData =new BitmapData( 160 , 100);
copy_bmd.copyPixels(bg_bmd, new Rectangle( mouseX-80, mouseY-50,160, 100), new Point( 0, 0 ));
photo.addChild(new Bitmap(copy_bmd));
var _frame:picFRAME=new picFRAME(photo_List.length%4);
photo.addChild(_frame);
albam.base.addChild(photo);
photo.x=20+photo_List.length%2*200;
photo.y=20+Math.floor(photo_List.length/2)*140;
photo_List.push(photo);
}
photoWaq.graphics.clear();
}
}
//
}
}
import flash.display.Sprite;
import flash.events.*;
import flash.filters.GlowFilter;
//【Albam】----------------------------------------------------------------------------------------------------
class Albam extends Sprite{
public var base:Sprite=new Sprite;
public var btAlbam:Sprite=new Sprite;
public var btClose:Sprite=new Sprite;
public function Albam(){
btAlbam.graphics.beginFill(0x9F8170);
btAlbam.graphics.drawRoundRect(0,-40,40,50,20);
btAlbam.graphics.endFill();
var piyo:drawChick=new drawChick(0xEF324E);
piyo.scaleX=piyo.scaleY=0.55;
piyo.x=14;
piyo.y=-23;
btAlbam.addChild(piyo);
addChild(btAlbam);
btAlbam.x=20;
btAlbam.y=0;
btAlbam.addEventListener(MouseEvent.ROLL_OVER,func_ov);
btAlbam.addEventListener(MouseEvent.ROLL_OUT, func_ou);
var bgShape :Sprite=new Sprite();
bgShape.graphics.beginFill(0xFFFFFF,0.98);
bgShape.graphics.drawRect(0,0,465,465);
bgShape.graphics.endFill();
addChild(bgShape);
btClose.graphics.beginFill(0x9F8170);
btClose.graphics.drawCircle(-8,-8,16);
btClose.graphics.endFill();
btClose.graphics.lineStyle(3,0xFFFFFF);
btClose.graphics.moveTo(-15,-15);
btClose.graphics.lineTo(0,0);
btClose.graphics.moveTo(0,-15);
btClose.graphics.lineTo(-15,0);
btClose.graphics.endFill();
addChild(btClose);
btClose.x=450;
btClose.y=35;
btClose.addEventListener(MouseEvent.ROLL_OVER,func_ov);
btClose.addEventListener(MouseEvent.ROLL_OUT, func_ou);
addChild(base);//最後に
}
private function func_ov(ev){ev.target.alpha=0.2;}
private function func_ou(ev){ev.target.alpha=1;}
}
//【picShutter】----------------------------------------------------------------------------------------------------
class picShutter extends Sprite{
public function picShutter(){
this.graphics.lineStyle(4, 0xFFCFAB);
this.graphics.drawRoundRect(0,0,160, 100,10);
this.graphics.endFill();
}
}
//【FRAME】----------------------------------------------------------------------------------------------------
class picFRAME extends Sprite{
private var fraList:Array=[0xC5E384,0xFF496C,0x199EBD,0xEFDBC5];
private var skfList:Array=[0xFD7C6E,0x1CA9C9,0xEF324E,0x9D726A];
private var flw1List:Array=[0xFB5E79,0xFFAEA0,0xFCFFD0,0xCD9575];
private var flw2List:Array=[0xFF6E4A,0xFFA089,0xFAE7B5,0xCB9B84];
private var flw3List:Array=[0xFD7C6E,0xFDBCB4,0xFCE883,0xC9A483];
public function picFRAME(arg){
var rndm:uint=arg;
this.graphics.lineStyle(10,fraList[rndm]);
this.graphics.drawRoundRect(0,0,160,100,10);
this.graphics.endFill();
var ch:drawChick=new drawChick(skfList[rndm]);
var fl1:drawFlower=new drawFlower(flw1List[rndm]);
var fl2:drawFlower=new drawFlower(flw2List[rndm]);
var fl3:drawFlower=new drawFlower(flw3List[rndm]);
addChild(ch);
addChild(fl2);
addChild(fl3);
addChild(fl1);
ch.x=138;ch.y=90;
fl1.scaleX=fl1.scaleY=4;fl1.rotation=15;
fl2.scaleX=fl2.scaleY=3;fl2.rotation=30;
fl3.scaleX=fl3.scaleY=2.5;fl3.rotation=-15;
fl1.x=5;fl1.y=5;
fl2.x=30;fl2.y=10;
fl3.x=0;fl3.y=28;
}
}
//【Chick】----------------------------------------------------------------------------------------------------
class drawChick extends Sprite{
private var head:Sprite=new Sprite();
private var body:Sprite=new Sprite();
private var scarf:Sprite=new Sprite();
//public var foot:Sprite=new Sprite();
public function drawChick(arg){
head.graphics.beginFill(0xFFCC33);
head.graphics.drawCircle(0,0,10);//head
head.graphics.endFill();
var head_1:Sprite = new Sprite();
head_1.graphics.beginFill(0x34929A);//eye
head_1.graphics.drawCircle(-1,-1,2);
head_1.graphics.endFill();
head_1.graphics.beginFill(0xF6712E);//Bill
head_1.graphics.drawEllipse(-15,-2,7,4);
head_1.graphics.endFill();
head.addChild(head_1);
addChild(head);
body.graphics.beginFill(0xFFCC33);//body
body.graphics.drawEllipse(2,2,30,20);
body.graphics.endFill();
var body_1:Sprite = new Sprite();
body_1.graphics.beginFill(0xFFCC33);//teil
body_1.graphics.moveTo(20,5);
body_1.graphics.lineTo(35,-1);
body_1.graphics.lineTo(32,13);
body_1.graphics.endFill();
body.addChild(body_1);
addChild(body);
/*foot.graphics.lineStyle(2,0xF6721E);//foot
foot.graphics.moveTo(18,23);
foot.graphics.lineTo(18,25);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(15,30);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(12,28);
foot.graphics.moveTo(18,25);
foot.graphics.lineTo(10,25);
foot.graphics.endFill();
addChild(foot); */
scarf.graphics.beginFill(arg);//0xEF324E
scarf.graphics.drawEllipse(-5,8,14,3);
scarf.graphics.endFill();
scarf.rotation=-40;
var scarf_1:Sprite = new Sprite();
scarf_1.graphics.beginFill(arg);
scarf_1.graphics.drawEllipse(0,0,15,5);
scarf_1.graphics.endFill();
scarf_1.rotation=-60;
scarf_1.x=5;scarf_1.y=8;
var scarf_2:Sprite = new Sprite();
scarf_2.graphics.beginFill(arg);
scarf_2.graphics.drawEllipse(0,0,15,5);
scarf_2.graphics.endFill();
scarf_2.rotation=-20;
scarf_2.x=5;scarf_2.y=8;
scarf.addChild(scarf_2);
scarf.addChild(scarf_1);
addChild(scarf);
}
}
//【flower】----------------------------------------------------------------------------------------------------
class drawFlower extends Sprite{
public function drawFlower(arg){
for(var j:int=0; j < 5; j++){
var fl_sp:Sprite = new Sprite();
fl_sp.graphics.beginFill(arg);
fl_sp.graphics.drawEllipse(-1,0.2,2,4);
fl_sp.graphics.endFill();
fl_sp.rotation=j*72+180;
filters = [ new GlowFilter(arg, 1, 10, 10, 1,2,false ) ] ;
addChild(fl_sp);
}
}
}