CardEffect no.1
テンポ重視
サブカードの枚数は可変。
何枚に増やしても終わるタイミングは一緒。
/**
* Copyright sakusan393 ( http://wonderfl.net/user/sakusan393 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/aIT7
*/
package
{
import com.bit101.components.*;
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.media.*;
import flash.net.*;
import flash.system.LoaderContext;
import flash.system.Security;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFormat;
import flash.utils.*;
import jp.progression.commands.lists.*;
import jp.progression.commands.media.*;
import jp.progression.commands.net.*;
import jp.progression.data.*;
import org.libspark.betweenas3.*;
import org.libspark.betweenas3.easing.*;
import org.libspark.betweenas3.tweens.*;
/**
* ...
* @author 393
*/
[SWF(backGroundColor = 0x000000, width = 465, height = 465, frameRate = 30)]
public class CardEffect4 extends Sprite
{
public static const MAIN_CARD_WIDTH:uint = 120;
public static const MAIN_CARD_HEIGHT:uint = 144;
public static const SUB_CARD_WIDTH:uint = 60;
public static const SUB_CARD_HEIGHT:uint = 72;
public static const SUB_CARD_NUM:uint = 10;
public static const SUB_CARD_NUM_MAX:uint = 50;
public static const STAR_NUM:uint = 60;
public static const MAHOUJIN_LENGTH:uint = 2;
public static const DEGREE_TO_RADIAN:Number = Math.PI / 180;
private var _w:int;
private var _h:int;
private var _subCardLength:int = SUB_CARD_NUM;
private var _mahoujinBaseBmd:BitmapData;
private var _mainCardBaseBmd:BitmapData;
private var _mahoujinContainer:Sprite;
private var _subCardContainer:Sprite;
private var _starContainer:Sprite;
private var _mainCardContainer:Sprite;
private var _levelUpContainer:Sprite;
private var _rect:Rectangle;
private var _ct:ColorTransform;
private var _starArray:Vector.<Star> = new Vector.<Star>(STAR_NUM);
private var _mahoujinArray:Vector.<BitmapContainer> = new Vector.<BitmapContainer>(2);
private var _mahoujinMainArray:Vector.<BitmapContainer> = new Vector.<BitmapContainer>(3);
private var _subCardArray:Vector.<BitmapContainer> = new Vector.<BitmapContainer>(SUB_CARD_NUM);
private var _cardArray:Vector.<Sprite> = new Vector.<Sprite>();
private var _mainTween:ITween;
private var _levelTween:ITween;
private var _mainCardTween:ITween;
private var _starPositionTween:ITween;
private var _changeTimer:Timer;
private var _starLastTween:ITween;
private var _fadeTimer:Timer;
private var _s7:Sound;
private var _soundList:SerialList;
private var _tf:TextField;
public function CardEffect4()
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
_w = stage.stageWidth;
_h = stage.stageHeight;
_ct = new ColorTransform(.9, .9, 2.9, .95);
_rect = new Rectangle(0, 0, _w, _h);
transform.perspectiveProjection.fieldOfView = 70;
Security.loadPolicyFile("http://393.bz/data/crossdomain.xml");
Security.allowDomain("assets.wonderfl.net");
Security.allowDomain("393.bz");
Security.allowDomain("wonderfl.net");
SoundMixer.soundTransform = new SoundTransform(0.5);
loadIData();
}
private function loadIData():void
{
_tf = new TextField();
var tfm:TextFormat = new TextFormat("Arial", 30, 0x999999, true);
_tf.defaultTextFormat = tfm;
_tf.autoSize = TextFieldAutoSize.RIGHT;
_tf.x = 450;
_tf.text = "0 %";
addChild(_tf);
var loaderList:LoaderList = new LoaderList( {
onProgress:function():void{
trace(this.percent)
_tf.text = int(this.percent) + " %";
}
,onComplete:function():void
{
dispatchEvent(new Event(Event.COMPLETE));
}
,catchError:function(target:Object, e:Error):void
{
//trace( target, e );
_tf.text = "catchError :" + e.toString();
target.interrupt();
}
,onError:function():void
{
_tf.text = "onError :"
}
});
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.MAIN_CARD),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.SUB_CARD),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.BG),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.MAHOUJIN),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.MAHOUJIN0),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.MAHOUJIN1),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.MAHOUJIN2),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.LVUP),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadBitmapData(new URLRequest(URL.KIRA),{context: new LoaderContext(true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE0),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE1),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE2),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE3),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE4),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE5),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE6),{context:new SoundLoaderContext(10, true)}));
loaderList.addCommand(new LoadSound(new URLRequest(URL.SE7),{context:new SoundLoaderContext(10, true)}));
loaderList.execute();
this.addEventListener(Event.COMPLETE, loadCompleteHandler);
}
//読み込み完了後の処理
private function loadCompleteHandler(e:Event):void
{
//背景の設置
addChild(new Bitmap(getResourceById(URL.BG).data as BitmapData));
//魔方陣
var mahoujinBmd:BitmapData = getResourceById(URL.MAHOUJIN).data as BitmapData;
var mahoujinBmdArray:Vector.<BitmapData> = new Vector.<BitmapData>(3);
mahoujinBmdArray[0] = getResourceById(URL.MAHOUJIN0).data as BitmapData;
mahoujinBmdArray[1] = getResourceById(URL.MAHOUJIN1).data as BitmapData;
mahoujinBmdArray[2] = getResourceById(URL.MAHOUJIN2).data as BitmapData;
_mahoujinContainer = new Sprite();
for (var i:int = 0; i < MAHOUJIN_LENGTH; i++)
{
_mahoujinArray[i] = new BitmapContainer(mahoujinBmd.clone(), 3);
_mahoujinContainer.addChild(_mahoujinArray[i]);
}
for (i = 0; i < 3; i++)
{
_mahoujinMainArray[i] = new BitmapContainer(mahoujinBmdArray[i].clone(),5);
_mahoujinContainer.addChild(_mahoujinMainArray[i]);
}
//魔方陣描画用のBitmapData
_mahoujinBaseBmd = new BitmapData(_w, _h, true, 0x0);
addChild(new Bitmap(_mahoujinBaseBmd));
//メインカード描画用のBitmapData
_mainCardBaseBmd = new BitmapData(_w, _h, true, 0x0);
addChild(new Bitmap(_mainCardBaseBmd));
//サブカード
var subCardBmd:BitmapData = getResourceById(URL.SUB_CARD).data as BitmapData;
_subCardContainer = new Sprite();
addChild(_subCardContainer);
_subCardContainer.x = _w / 2;
_subCardContainer.y = _h / 2 - 50;
_subCardContainer.z = _w / 2
for (i = 0; i < SUB_CARD_NUM; i++)
{
_subCardArray[i] = new BitmapContainer(subCardBmd.clone(), 0.7);
_subCardContainer.addChild(_subCardArray[i]);
_cardArray[i] = _subCardArray[i];
}
//スター
var kiraBmd:BitmapData = getResourceById(URL.KIRA).data as BitmapData;
_starContainer = new Sprite();
_starContainer.blendMode = BlendMode.ADD;
addChild(_starContainer);
_starContainer.x = _w / 2;
_starContainer.y = _h / 2 - 50;
_starContainer.z = _w / 2
for (i = 0; i < STAR_NUM; i++)
{
_starArray[i] = new Star(kiraBmd.clone(), 1);
_starContainer.addChild(_starArray[i]);
}
_starContainer.blendMode = BlendMode.ADD;
//メインカード
var mainCardBmd:BitmapData = getResourceById(URL.MAIN_CARD).data as BitmapData;
_mainCardContainer = new BitmapContainer(mainCardBmd,1);
_subCardContainer.addChild(_mainCardContainer);
_cardArray.push(_mainCardContainer);
//レベルアップ
var levelUpBmd:BitmapData = getResourceById(URL.LVUP).data as BitmapData;
_levelUpContainer = new BitmapContainer(levelUpBmd,2);
addChild(_levelUpContainer);
//SE初期化
soundInit();
//UI生成
createUI();
//初期化
reset();
}
private function startAnimation():void
{
var i:int;
var unit:int = 1;
var iTween:ITween;
var iTween0:ITween;
var iTween1:ITween;
//メインカード
//魔方陣の中身の回転
var _moujinInnerTweenArray:Array = [];
for (i = 0; i < 3; i++)
{
if (i == 1) unit = 1;
else unit = -1;
_moujinInnerTweenArray[i] = BetweenAS3.delay(BetweenAS3.tween(_mahoujinMainArray[i].container,{rotationZ:90*unit},{rotationZ:0},1.5,Linear.linear), 1.2);
}
BetweenAS3.parallelTweens(_moujinInnerTweenArray).play();
unit = 1;
iTween = BetweenAS3.tween(_mainCardContainer, { height:3,scaleX:2,rotationX:0 },{scaleY:1,scaleX:1}, 0.5, Back.easeIn);
iTween1 = BetweenAS3.tween(_mainCardContainer, { _glowFilter:{blurY: 16,blurX:16,color:0xFFFFFF,alpha:0.8},transform: { colorTransform: { redOffset:255, greenOffset:255, blueOffset:255 }} },{ _glowFilter:{blurY: 0,blurX:0,color:0xFFFFFF,alpha:0},transform: { colorTransform: { redOffset:0, greenOffset:0, blueOffset:0 }} }, 0.5, Expo.easeIn);
iTween0 = BetweenAS3.to(_mainCardContainer, { rotation:360,y:50,z:-_h/2 }, 0.3, Back.easeIn);
var mainCardOutTween:ITween = BetweenAS3.delay(BetweenAS3.serial(iTween1, iTween, iTween0), 2.2);
var mainCardRollTween:ITween = BetweenAS3.to(_mainCardContainer, { $rotation:360 *2 ,scaleX:2}, 0.8, Expo.easeOut);
var mainCardInTween:ITween = BetweenAS3.tween(_mainCardContainer, { scaleY:2, y:50,transform: { colorTransform: { redOffset:0, greenOffset:0, blueOffset:0 }},_glowFilter:{blurY: 64,blurX:64,color:0xFFFFFF,alpha:0.5,strength:1} },{transform: { colorTransform: { redOffset:255, greenOffset:255, blueOffset:255 }}}, .3, Back.easeOut);
//メインカードの挙動
_mainCardTween = BetweenAS3.serial(mainCardOutTween, mainCardRollTween, mainCardInTween);
_mainCardTween.play();
//メインカードが回り終わったら、
mainCardRollTween.onComplete = function():void
{
_subCardContainer.setChildIndex(_mainCardContainer, 0);
var starTweenArray:Array = [];
for (i = 0; i < STAR_NUM; i++)
{
starTweenArray[i] = BetweenAS3.to(_starArray[i], { z:0,scaleX:1, scaleY:1, x:Math.cos(DEGREE_TO_RADIAN * 360 / STAR_NUM * i) * 320, y:Math.sin(DEGREE_TO_RADIAN * 360 / STAR_NUM * i) * 320 + 50 }, 0.5, Expo.easeOut);
_starArray[i].tweenPlay();
}
_starPositionTween = BetweenAS3.parallelTweens(starTweenArray);
_starPositionTween.play();
}
//魔法陣
var mahoujinScaleInTweenArray:Array = [];
for (i = 0; i < 3; i++)
{
mahoujinScaleInTweenArray[i] = BetweenAS3.delay(BetweenAS3.tween(_mahoujinMainArray[i], { scaleX:1, scaleY:1 }, { scaleX:0, scaleY:0 }, 0.5, Expo.easeOut), 0.05+i*0.05);
}
var mahoujinScaleInTween:ITween = BetweenAS3.parallelTweens(mahoujinScaleInTweenArray);
var mahoujinRollTweenArray:Array = [];
for (i = 0; i < MAHOUJIN_LENGTH; i++)
{
mahoujinRollTweenArray[i] = BetweenAS3.to(_mahoujinArray[i], { $rotationX:360, $rotationY:360, $rotationZ:360 }, 1.2, Expo.easeInOut);
}
for (i = 0; i < 3; i++)
{
if (i == 1) unit = -1;
else unit = 1;
mahoujinRollTweenArray.push(BetweenAS3.to(_mahoujinMainArray[i], { rotationX:360 * unit, rotationY:360 * unit, rotationZ:360 }, 1.2, Expo.easeInOut));
}
var mahoujinRollTween:ITween = BetweenAS3.delay(BetweenAS3.parallelTweens(mahoujinRollTweenArray), 2.3);
var mahoujinScaleOutTweenArray:Array = [];
for (i = 0; i < 3; i++)
{
mahoujinScaleOutTweenArray[i] = BetweenAS3.delay(BetweenAS3.to(_mahoujinMainArray[i], { scaleX:0.6, scaleY:0.6 }, 0.3, Expo.easeOut), i*0.05);
}
var mahoujinScaleOutTween:ITween = BetweenAS3.delay(BetweenAS3.parallelTweens(mahoujinScaleOutTweenArray), 0.05);
var mahoujinScaleOutTweenArray1:Array = [];
for (i = 0; i < 3; i++)
{
mahoujinScaleOutTweenArray1[i] = BetweenAS3.delay(BetweenAS3.to(_mahoujinMainArray[i], { scaleX:8, scaleY:8 }, 0.5, Sine.easeIn), 0.5);
}
var mahoujinScaleOutTween1:ITween = BetweenAS3.parallelTweens(mahoujinScaleOutTweenArray1);
//スター
var starAlphaInTween:ITween;
var starAlphaInTweenArray:Array = [];
for (i = STAR_NUM-1; i >= 0; i--)
{
var iTweenStar:ITween
= BetweenAS3.serial(
BetweenAS3.delay(BetweenAS3.tween(_starArray[i], {scaleX:1,scaleY:1},{scaleX:0,scaleY:0}, 0.5, Expo.easeOut), i * 0.05/3.5)
,BetweenAS3.delay(BetweenAS3.bezierTo(_starArray[i], { x:0,y:0,z:0,scaleX:0,scaleY:0 },{x:(0 -_starArray[i].x)*2 ,y:Math.abs((0-_starArray[i].y) * 1.2) * -1,z:(0-_starArray[i].z)*2}, 0.6,Expo.easeOut), 0.2/3.5)
)
starAlphaInTweenArray[i] = iTweenStar;
}
starAlphaInTween = BetweenAS3.parallelTweens(starAlphaInTweenArray);
//サブカード
var subCardAlphaInTween:ITween;
var subCardAlphaInTweenArray:Array = [];
var subCardLength:int = _subCardArray.length;
var offset:Number = 10 / subCardLength;
if (offset >= 1) offset = 1;
trace( "offset : " + offset );
for (i = subCardLength-1; i >= 0; i--)
{
var subInTween:ITween = BetweenAS3.to(_subCardArray[i], { rotationZ:30 }, i * 0.05 * offset+0.00000001 )
subInTween.onComplete = function():void
{
new DoSound(_s7, 53, 1, false).execute();
}
iTween = BetweenAS3.serial(
subInTween
,BetweenAS3.tween(_subCardArray[i], { scaleX:1, scaleY:1, transform: { colorTransform: { redOffset:0, greenOffset:0, blueOffset:0 }}}, { scaleX:0, scaleY:0, transform: { colorTransform: { redOffset:255, greenOffset:255, blueOffset:255 }} }, 0.5, Expo.easeOut)
,BetweenAS3.delay(BetweenAS3.bezier(_subCardArray[i], {rotationZ:0,alpha:0.2, x:0,y:0,z:0,rotationY:0,rotationX:90,transform: { colorTransform: { redOffset:255, greenOffset:255, blueOffset:255 }} },{alpha:1,transform: { colorTransform: { redOffset:0, greenOffset:0, blueOffset:0}}},{y:Math.abs((-_subCardArray[i].y - 100) * 2) * -1}, 0.6,Expo.easeOut), 0.2 * offset)
,BetweenAS3.to(_subCardArray[i], {scaleX:0,scaleY:0,rotationX:0 }, 0)
)
subCardAlphaInTweenArray[i] = iTween;
}
subCardAlphaInTween = BetweenAS3.parallel(BetweenAS3.parallelTweens(subCardAlphaInTweenArray), starAlphaInTween);
//スターの最後のとびちり
var starOutTweenArray:Array = [];
for (i = 0; i < STAR_NUM; i++)
{
var posX:Number = Math.cos(DEGREE_TO_RADIAN * 360 / STAR_NUM * i) * 350;
var posY:Number = Math.sin(DEGREE_TO_RADIAN * 360 / STAR_NUM * i) * 350 + 50;
starOutTweenArray[i] = BetweenAS3.delay(BetweenAS3.to(_starArray[i], { scaleX:1,scaleY:1, x:posX, y:posY ,z:0 }, Math.random() * 0.5+1, Sine.easeInOut), 0);
}
var starOutTween:ITween = BetweenAS3.delay(BetweenAS3.parallelTweens(starOutTweenArray), 0.3);
//最初のメインカードジャンプ→魔方陣ぐるぐる→魔方陣正面→魔方陣縮小
iTween0 = BetweenAS3.tween(_mainCardContainer, { scaleY:0.8,y:64 },{scaleY:1,y:50}, 0.2, Sine.easeOut);
iTween1 = BetweenAS3.bezierTo(_mainCardContainer, { y:0, z:0 ,scaleY:1,rotationX:40},{y:-500,scaleY:1}, 0.5, Quad.easeOutIn);
var mainCardFirstTween:ITween = BetweenAS3.serial(iTween0, iTween1);
var mahoujinTween:ITween = BetweenAS3.parallel(BetweenAS3.serial(mahoujinScaleInTween,subCardAlphaInTween), mahoujinRollTween);
_mainTween = BetweenAS3.serial(mainCardFirstTween,mahoujinTween, mahoujinScaleOutTween, BetweenAS3.parallel(mahoujinScaleOutTween1,starOutTween));
_mainTween.play();
//レベルアップのイン→レベルアップアウト
var levelTweenArray:Array = [];
levelTweenArray[0] = BetweenAS3.tween(_levelUpContainer, { x: -15 + _w/2,_blurFilter:{blurX: 0}}, { x:-_w ,_blurFilter:{blurX: 128} }, 1, Expo.easeIn);
levelTweenArray[1] = BetweenAS3.to(_levelUpContainer, { x:15 + _w/2 }, 0.8, Linear.linear);
levelTweenArray[2] = BetweenAS3.to(_levelUpContainer, { x:_w + _w ,_blurFilter:{blurX: 128}}, 1, Expo.easeOut);
_levelTween = BetweenAS3.delay(BetweenAS3.serialTweens(levelTweenArray), 3.3);
_levelTween.play();
_levelTween.onComplete = function():void
{
_fadeTimer = new Timer(1000, 1);
_fadeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function():void {removeEventListener(Event.ENTER_FRAME, enterFrameHandler); } );
_fadeTimer.start();
}
this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(e:Event):void
{
_mahoujinBaseBmd.draw(_mahoujinContainer );
_mahoujinBaseBmd.colorTransform(_rect, _ct);
}
private function reset():void
{
this.removeEventListener(Event.ENTER_FRAME, enterFrameHandler);
if (_mainCardTween) _mainCardTween.stop();
if (_starPositionTween) _starPositionTween.stop();
if (_mainTween) _mainTween.stop();
if (_levelTween) _levelTween.stop();
if (_starLastTween) _starLastTween.stop();
if (_fadeTimer) _fadeTimer.stop();
if (_soundList) _soundList.interrupt();
_mahoujinBaseBmd.fillRect(_rect, 0x0);
//魔方陣
for (var i:int = 0; i < MAHOUJIN_LENGTH; i++)
{
_mahoujinArray[i].x = _w / 2;
_mahoujinArray[i].y = _h / 2;
_mahoujinArray[i].z = _w / 2;
_mahoujinArray[i].rotationX = 0;
_mahoujinArray[i].rotationY = 0;
_mahoujinArray[i].rotationZ = 0;
if (i == 0) _mahoujinArray[i].rotationY = 90;
if (i == 1) _mahoujinArray[i].rotationX = 90;
}
for (i = 0; i < 3; i++)
{
_mahoujinMainArray[i].x = _w / 2;
_mahoujinMainArray[i].y = _h / 2;
_mahoujinMainArray[i].z = _w / 2;
_mahoujinMainArray[i].rotationX = 0;
_mahoujinMainArray[i].rotationY = 0;
_mahoujinMainArray[i].rotationZ = 0;
_mahoujinMainArray[i].rotationX = -60;
_mahoujinMainArray[i].scaleX = _mahoujinMainArray[i].scaleY = 0;
}
//サブカード
var subCardLength:int = _subCardArray.length;
var position:Number = subCardLength;
var offsetIndex:int = 0;
var offsetR:int = 0;
var offsetY:int = 40;
if (position == 1)
{
position = 1 / 0.75;
offsetIndex = 1;
}
else if (position == 2)
{
offsetY = 0;
}
else if (subCardLength % 2 != 0 && subCardLength < 10) offsetR = 360 / subCardLength - 90;
for (i = 0; i < subCardLength; i++)
{
_subCardArray[i].x = Math.cos(DEGREE_TO_RADIAN * (360 / position * (i + offsetIndex) + offsetR)) * 250;
_subCardArray[i].z = Math.sin(DEGREE_TO_RADIAN * (360 / position * (i + offsetIndex) + offsetR)) * 350;
_subCardArray[i].y = -Math.sin(DEGREE_TO_RADIAN * (360 / position * (i + offsetIndex) + offsetR)) * 150 - offsetY;
_subCardArray[i].scaleX = _subCardArray[i].scaleY = 0;
_subCardArray[i].alpha = 1;
_subCardArray[i].rotationX = 30;
_subCardArray[i].visible = true;
_subCardArray[i].name = i.toString();
}
//スター
for (i = 0; i < STAR_NUM; i++)
{
_starArray[i].x = Math.cos(DEGREE_TO_RADIAN * (360 / STAR_NUM * i + offsetR)) * 280;
_starArray[i].z = Math.sin(DEGREE_TO_RADIAN * (360 / STAR_NUM * i + offsetR)) * 330 - 0;
_starArray[i].y = -Math.sin(DEGREE_TO_RADIAN * (360 / STAR_NUM * i + offsetR)) * 150 -100 + 10* (Math.random()-0.5)
_starArray[i].scaleX = _starArray[i].scaleY = 0;
_starArray[i].tweenStop();
}
//メインカード
_mainCardContainer.scaleX = _mainCardContainer.scaleY = 1;
_mainCardContainer.y = 50;
_mainCardContainer.rotation = 0;
_mainCardContainer.rotationX = 0;
_mainCardContainer.z = 10;
_mainCardContainer.filters = [];
BetweenAS3.to(_mainCardContainer, { transform: { colorTransform: { redOffset:0, greenOffset:0, blueOffset:0 }} }, .01).play();
//
var compare:Function = function(x:Sprite, y:Sprite):Number
{
return y.z - x.z;
}
var compare2:Function = function(y:Sprite, x:Sprite):Number
{
return int(y.name) - int(x.name);
}
_cardArray.sort(compare);
var cardLength:int = _cardArray.length;
for (i = 0; i < cardLength; i++)
{
_subCardContainer.setChildIndex(_cardArray[i], i);
}
_mainCardContainer.z = -_w / 2;
//レベル
_levelUpContainer.x = -_w;
_levelUpContainer.y = _h / 2 +100;
}
//UI生成
private function createUI():void
{
var panel:Panel = new Panel(stage, 0, 0);
panel.width = 190;
panel.addEventListener(MouseEvent.MOUSE_OVER, function():void { BetweenAS3.to(panel,{alpha:1,x:0},0.5,Expo.easeOut).play()} );
panel.addEventListener(MouseEvent.MOUSE_OUT, function():void {BetweenAS3.to(panel,{alpha:0.5,x:-panel.width+30},0.5,Expo.easeOut).play()} );
var slider:HUISlider = new HUISlider(panel, 10, 10, "CARD_NUM", sliderChangeHandler);
slider.minimum = 1;
slider.width = 200;
slider.maximum = SUB_CARD_NUM_MAX;
slider.value = SUB_CARD_NUM;
var restartBtn:PushButton = new PushButton(panel, 10, 70, "START", function():void {reset(); startAnimation();_soundList.execute(); } );
var resetButton:PushButton = new PushButton(panel, 10, 40, "RESET", function():void { reset();} );
resetButton.width = restartBtn.width = 170;
_changeTimer = new Timer(200, 1);
}
//スライダーの変更時の処理
private function sliderChangeHandler(e:Event):void
{
_subCardLength = e.target.value;
if (_changeTimer.running)
{
_changeTimer.stop();
}
_changeTimer.addEventListener(TimerEvent.TIMER_COMPLETE, timerCompleteHandler);
_changeTimer.start();
}
//スライダー変更後決定
private function timerCompleteHandler(e:TimerEvent):void
{
var subCardLength:int = _subCardArray.length;
for (var i:int = 0; i < subCardLength + 1; i++)
{
if (i < subCardLength)
{
_subCardArray[i].destroy();
_subCardContainer.removeChild(_subCardArray[i]);
_subCardArray[i] = null;
}
_cardArray[i] = null;
}
_subCardArray = new Vector.<BitmapContainer>(_subCardLength);
_cardArray = new Vector.<Sprite>();
var subCardBmd:BitmapData = getResourceById(URL.SUB_CARD).data as BitmapData;
for (i = 0; i < _subCardLength; i++)
{
_subCardArray[i] = new BitmapContainer(subCardBmd.clone(), 0.7);
_subCardContainer.addChild(_subCardArray[i]);
_cardArray.push(_subCardArray[i]);
}
_cardArray.push(_mainCardContainer);
reset();
}
//効果音
private function soundInit():void
{
var sTransform4:SoundTransform = new SoundTransform(0.4);
var sTransform6:SoundTransform = new SoundTransform(0.8);
var s0:Sound = getResourceById(URL.SE0).data;
var s1:Sound = getResourceById(URL.SE1).data;
var s2:Sound = getResourceById(URL.SE2).data;
var s3:Sound = getResourceById(URL.SE3).data;
var s4:Sound = getResourceById(URL.SE4).data;
var s5:Sound = getResourceById(URL.SE5).data;
var s6:Sound = getResourceById(URL.SE6).data;
_s7 = getResourceById(URL.SE7).data;
_soundList = new SerialList();
_soundList.addCommand(
//ジャンプ
new DoSound(s0,0,1,false)
,0.55
//魔方陣出現
,new DoSound(s1, 0, 1, false)
,0.5
//カード出現
,new DoSound(s2, 0, 1, false)
,0.1
,new DoSound(s2, 0, 1, false)
,0.1
,new DoSound(s2, 0, 1, false)
,1.1
//カード合体
,new DoSound(s3, 0, 1, false)
,0.5
//魔方陣回転
,new DoSound(s4, 0, 1, false,{soundTransform:sTransform4})
,0.01
,new DoSound(s4, 0, 1, false)
,0.01
,new DoSound(s4, 0, 1, false)
,1.05
//カード拡大
,new DoSound(s5, 0, 1, false)
,0.8
//魔方陣解散
,new DoSound(s6,0,1,false,{soundTransform:sTransform6})
)
}
}
}
import flash.display.*;
import flash.events.*;
import org.libspark.betweenas3.*;
import org.libspark.betweenas3.easing.*;
import org.libspark.betweenas3.tweens.*;
class BitmapContainer extends Sprite
{
private var _scale:Number = 1;
private var _bmd:BitmapData;
private var _container:Sprite;
function BitmapContainer(bmd:BitmapData,scale:Number = 1)
{
_scale = scale;
_bmd = bmd;
var bm:Bitmap = new Bitmap(_bmd,PixelSnapping.NEVER,true);
bm.x = -bm.width / 2;
bm.y = -bm.height / 2;
_container = new Sprite();
_container.scaleX = _container.scaleY = scale;
_container.addChild(bm);
addChild(_container);
}
public function destroy():void
{
_bmd.dispose();
}
public function get container():Sprite
{
return _container;
}
}
class Star extends Sprite
{
private var _container:Sprite;
private var _fadeTween:ITween;
public var scale:Number = 1;
public function Star(bmd:BitmapData,scale:Number = 1)
{
this.scale = 1.5 * Math.random() + 1;
var bm:Bitmap = new Bitmap(bmd,PixelSnapping.NEVER,true);
bm.x = -bm.width / 2;
bm.y = -bm.height / 2;
_container = new Sprite();
_container.scaleX = _container.scaleY = this.scale;
_container.addChild(bm);
addChild(_container);
this.alpha = 0.9;
this.addEventListener(Event.ENTER_FRAME, enterFrameHandler);
}
private function enterFrameHandler(e:Event):void
{
this.rotation += 10;
}
public function tweenPlay():void
{
this.scale = 4 * Math.random() + 1;
var iTween:ITween = BetweenAS3.tween(_container, { scaleX:0.3, scaleY:0.3,$rotation:30 }, { scaleX:this.scale, scaleY:this.scale,rotation:0 }, 1, Expo.easeOut);
_fadeTween = BetweenAS3.serial(BetweenAS3.tween(_container, { scaleX:0, scaleY:0 }, { scaleX:0, scaleY:0 }, Math.random()/2), iTween);
_fadeTween.stopOnComplete = false;
_fadeTween.play();
}
public function tweenStop():void
{
if(_fadeTween) _fadeTween.stop();
this.scale = 1.5 * Math.random() + 1;
_container.scaleX = _container.scaleY = this.scale;
}
}
class URL
{
public static const MAIN_CARD:String = "http://assets.wonderfl.net/images/related_images/f/fc/fcfb/fcfb1f18a586ad79fd30a5c08cb4f267e9714530";
public static const SUB_CARD:String = "http://assets.wonderfl.net/images/related_images/c/c3/c3b9/c3b9c082c57786d6d70cd72f342b232942865a1c";
public static const BG:String = "http://assets.wonderfl.net/images/related_images/6/6a/6a39/6a39d24903a88ef0e43693fa953fb2aabe242387";
public static const MAHOUJIN:String = "http://assets.wonderfl.net/images/related_images/d/d3/d3a6/d3a65301bb89f0e7db4ea5b727224b8b944fba97";
public static const LVUP:String = "http://assets.wonderfl.net/images/related_images/e/ef/efdd/efdd32f0082c3456d2268d25c487a3fc1bb12d33";
public static const KIRA:String = "http://assets.wonderfl.net/images/related_images/3/31/3167/31679ab5ea5e6b984bd4476ca107be3bf2c37391";
public static const MAHOUJIN2:String = "http://393.bz/data/magic0.png";
public static const MAHOUJIN1:String = "http://393.bz/data/magic1.png";
public static const MAHOUJIN0:String = "http://393.bz/data/magic2.png";
public static const SE0:String = "http://393.bz/data/00.mp3";
public static const SE1:String = "http://393.bz/data/01.mp3";
public static const SE2:String = "http://393.bz/data/02.mp3";
public static const SE3:String = "http://393.bz/data/03.mp3";
public static const SE4:String = "http://393.bz/data/04.mp3";
public static const SE5:String = "http://393.bz/data/05.mp3";
public static const SE6:String = "http://393.bz/data/06.mp3";
public static const SE7:String = "http://393.bz/data/07.mp3";
}