flash on 2011-2-5
♥0 |
Line 52 |
Modified 2011-02-07 21:43:07 |
MIT License
archived:2017-03-20 17:33:24
ActionScript3 source code
/**
* Copyright autumngoodluck ( http://wonderfl.net/user/autumngoodluck )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/tIgY
*/
package {
import flash.display.MovieClip;
import flash.display.Loader;
import flash.events.Event;
import flash.geom.Rectangle;
import org.papervision3d.materials.MovieMaterial;
import org.papervision3d.view.BasicView;
import org.papervision3d.objects.primitives.Plane;
public class FlashTest extends BasicView {
public function FlashTest() {
var player:YouTubePlayer = new YouTubePlayer("4l_jiJu4Lfg");
var material:MovieMaterial = new MovieMaterial(player);
material.doubleSided = true;
material.precise = true;
material.rect = new Rectangle(0, 0, 640, 480);
plane = new Plane(material);
scene.addChild(plane);
startRendering();
addEventListener(Event.ENTER_FRAME, loop);
}
private var plane:Plane;
private function loop(event:Event):void
{
plane.rotationY += 1;
}
}
}
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.system.SecurityDomain;
class YouTubePlayer extends Loader
{
public function YouTubePlayer(videoId:String)
{
_videoId = videoId;
var loaderContext:LoaderContext = new LoaderContext(true);
contentLoaderInfo.addEventListener(Event.INIT, loaderInitHandler);
load(new URLRequest("http://www.youtube.com/apiplayer?version=3"), loaderContext);
}
private var _videoId:String;
private function loaderInitHandler(event:Event):void
{
content.addEventListener("onReady", readyHandler);
}
private function readyHandler(event:Event):void
{
Object(content).loadVideoById(_videoId);
}
}