/**
* Copyright leonardo.sgoulart ( http://wonderfl.net/user/leonardo.sgoulart )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/jMZL
*/
// forked from nasajun's forked from: forked from: [BetweenAS3] Papervision Matrix3D Tween
// forked from nitoyon's [BetweenAS3] Random Text Tween
package {
import flash.text.TextField;
import flash.events.MouseEvent;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.*;
import caurina.transitions.*;
import org.papervision3d.lights.PointLight3D;
import org.papervision3d.materials.shadematerials.FlatShadeMaterial;
import org.papervision3d.objects.DisplayObject3D;
import org.papervision3d.objects.primitives.PaperPlane;
import org.papervision3d.view.BasicView;
[SWF (backgroundColor="0x000000")]
public class FlashTest extends BasicView
{
public var main: Number = 0;
public var planes:Array = [];
public var total: Number = 30
public var tf: TextField = new TextField();
public function FlashTest()
{
_camera.zoom = 60;
var light:PointLight3D;
light = new PointLight3D(false);
light.y = 1000;
tf.text = "CLICK"
tf.x = stage.stageWidth /2;
tf.y = 20;
tf.textColor = 0xFFFFFF
addChild(tf);
var mats:Array = [];
mats.push(new FlatShadeMaterial(light, 0x0c6867));
mats.push(new FlatShadeMaterial(light, 0x6677FF));
mats.push(new FlatShadeMaterial(light, 0x222222));
mats.push(new FlatShadeMaterial(light, 0xe88b12));
mats.forEach( function(item:*, ...rest):void {item.doubleSided = true;} );
for(var i:uint=0; i < total; i++)
{
var p:PaperPlane = new PaperPlane(mats[i%mats.length]);
scene.addChild(p);
// p.x = 100 * i;
planes.push(p);
p.rotationX = -15
p.x = stage.stageWidth;
stage.addEventListener(MouseEvent.CLICK, incrementa);
if( i == 63)
{
doTweens();
}
}
startRendering();
}
public function doTweens():void
{
try
{
Tweener.addTween(planes[main], {x: 0, y: 50, z: -300, rotationY: 0, rotationX: -100, time:0.5, transition:"easeoutback"});
}
catch(e:Error)
{
}
try
{
Tweener.addTween(planes[main+1], {x: 130, y: 0, z: -100, rotationY: 20, rotationX: -15, time:0.5, transition:"easeoutback"});
}
catch(e:Error)
{
}
try
{
Tweener.addTween(planes[main+2], {x: 260, y: 0, z: -200, rotationY: 40, rotationX: -15, time:0.5, transition:"easeoutback"});
}
catch(e:Error)
{
}
try
{
Tweener.addTween(planes[main-1], {x: -150, y: 0, z: -100, rotationY: -20, rotationX: -15, time:0.5, transition:"easeoutback"});
}
catch(e:Error)
{
}
try
{
Tweener.addTween(planes[main-2], {x: -300, y: 0, z: -200, rotationY: -40, rotationX: -15, time:0.5, transition:"easeoutback"});
}
catch(e:Error)
{
}
var i: Number = main + 3;
while (i<total)
{
try
{
Tweener.addTween(planes[i], {x: stage.stageWidth, y: 0, z: -100, rotationY: 20, rotationX: -15, time:0.5, transition:"easeoutback"});
}
catch (e:Error)
{
trace("left");
}
i++;
}
i = main - 3;
//Nao aparecem
while (i>=0)
{
try
{
Tweener.addTween(planes[i], {x: -1000, y: 0, z: -100, rotationY: 20, rotationX: -15, time:0.5, transition:"easeoutback"});
}
catch (e:Error)
{
trace("right");
}
i--;
}
}
public function incrementa(e:MouseEvent):void
{
if(main < (total-1))
{
main++
doTweens();
}
else
{
main = 0;
doTweens();
}
}
}
}