business card
外部画像を表示するテスト。
サンドボックスに引っかかる。
更新すると走るってどういうことかが、わかりません。
/*
外部画像を表示するテスト。
サンドボックスに引っかかる。
更新すると走るってどういうことかが、わかりません。
*/
package
{
import caurina.transitions.Tweener;
import flash.display.Shape;
import flash.events.Event;
import flash.filters.BlurFilter;
import flash.system.Security;
import org.papervision3d.cameras.Camera3D;
import org.papervision3d.core.effects.view.ReflectionView;
import org.papervision3d.events.InteractiveScene3DEvent;
import org.papervision3d.objects.primitives.Plane;
import org.papervision3d.view.BasicView;
public class BusinessCard extends ReflectionView
{
private const CARD_WIDTH:int = 178;
private const CARD_HEIGHT:int =300;
private var _shadow:Shadow;
private var _card:Card;
private var _isBack:Boolean=false;
/*======================================================================*//**
* constructor
*/
public function BusinessCard()
{
Security.loadPolicyFile("http://wonderfl.reinit.info/crossdomain.xml");
init();
addEventListener(Event.ENTER_FRAME, _onRendering);
}
private function init():void
{
viewport.buttonMode = true;
viewport.interactive = true;
camera.z = 3000;
camera.zoom = 1000;
camera.focus = 3;
_shadow = addChildAt(new Shadow(CARD_WIDTH-10, CARD_HEIGHT-10), 0) as Shadow;
_shadow.x = (stage.stageWidth - _shadow.width) / 2;
_shadow.y = (stage.stageHeight - _shadow.height) / 2;
_card = scene.addChild(new Card(CARD_WIDTH, CARD_HEIGHT)) as Card;
_card.addEventListener(InteractiveScene3DEvent.OBJECT_OVER, _onOver);
_card.addEventListener(InteractiveScene3DEvent.OBJECT_CLICK, _onClick);
_card.addEventListener(InteractiveScene3DEvent.OBJECT_OUT, _onOut);
surfaceHeight = -CARD_HEIGHT-20;
//viewportReflection.filters = [new BlurFilter(8,8,1)];
}
private function _onOver(e:InteractiveScene3DEvent):void
{
Tweener.addTween(_card, { z:100, time:0.8, transition:"easeOutQuart" } );
Tweener.addTween(_shadow, {alpha:_shadow.minAlpha, time:0.8, transition:"easeOutQuart" } );
}
private function _onClick(e:InteractiveScene3DEvent):void
{
Tweener.addTween(_card, {z:200,time:0.8,transition:"easeOutQuart" } );
Tweener.addTween(_card, {z:0,time:0.8,transition:"easeOutQuart",delay:0.8 } );
Tweener.addTween(_card, { rotationY:(!_isBack)?180:0, time:1.6, transition:"easeOutQuart" } );
Tweener.addTween(_shadow, {alpha:_shadow.minAlpha, time:0.4, transition:"easeOutQuart" } );
Tweener.addTween(_shadow, {alpha:_shadow.maxAlpha, time:0.8, transition:"easeOutQuart",delay:1.2} );
_isBack=(!_isBack)?true:false;
}
private function _onOut(e:InteractiveScene3DEvent):void
{
Tweener.addTween(_card, { z:0, time:0.5, transition:"easeOutQuart" } );
Tweener.addTween(_shadow, {alpha:_shadow.maxAlpha, time:0.8, transition:"easeOutQuart" } );
}
private function _onRendering(e:Event):void
{
singleRender();
}
}
}
import flash.display.Shape;
import flash.filters.BlurFilter;
import org.papervision3d.materials.BitmapFileMaterial;
import org.papervision3d.materials.ColorMaterial;
import org.papervision3d.materials.utils.MaterialsList;
import org.papervision3d.objects.primitives.Cube;
class Card extends Cube
{
private const FRONT_MATERIAL_URL:String = "http://wonderfl.reinit.info/businesscard/front.png";
private const BACK_MATERIAL_URL:String = "http://wonderfl.reinit.info/businesscard/back.png";
/*======================================================================*//**
* constructor
* @param cardWidth
* <p>カードの幅</p>
* @param cardHeight
* <p>カードの高さ</p>
*/
public function Card(cardWidth:int,cardHeight:int):void
{
var frontMaterial:BitmapFileMaterial = new BitmapFileMaterial(FRONT_MATERIAL_URL, false);
var backMaterial:BitmapFileMaterial = new BitmapFileMaterial(BACK_MATERIAL_URL, false);
var otherMaterial:ColorMaterial = new ColorMaterial(0xffffff);
frontMaterial.interactive = backMaterial.interactive = true;
frontMaterial.smooth = backMaterial.smooth = true;
var materials:MaterialsList = new MaterialsList(
{
front:frontMaterial,
back:backMaterial,
top:otherMaterial,
bottom:otherMaterial,
left:otherMaterial,
right:otherMaterial
});
super(materials, cardWidth, 1, cardHeight, 5, 5, 1);
}
}
class Shadow extends Shape
{
public function get maxAlpha():Number { return _maxAlpha; }
private var _maxAlpha:Number = 0.7;
public function get minAlpha():Number { return _minAlpha; }
private var _minAlpha:Number = 0.05;
/*======================================================================*//**
* constructor
* @param shadowWidth
* <p>影の幅</p>
* @param shadowHeight
* <p>影の高さ</p>
*/
public function Shadow(shadowWidth:int, shadowHeight:int):void
{
graphics.beginFill(0x00);
graphics.drawRect(0, 0, shadowWidth, shadowHeight);
graphics.endFill();
filters = [new BlurFilter(24, 24, 4)];
alpha = _maxAlpha;
}
}