Code that worked under version 2_1_0 & 2_2_0 no longer seems to work
under version 3_0_0 (fresh from the SVN repo).
The class below opens a flash video source and maps it onto a plane -
to use it, just

var myvid:videoPlane;
myVid = new videoPlane("/path/to/flvfile");
view.scene.addChild(myVid);


myVid.updateVideo();  //run to update frame



The initial frame is mapped in the constructor and displays OK (when
the movie is run in an external player (flash 9)) but when the
updateVideo() function is called (every Event.ENTER_FRAME) I can see
the pixel values in the plane changing as the video animates but the
updated frame is never re-rendered (by a view.render() call).

Has something changed in the latest build that I should worry about?

package
{
        import away3d.primitives.Plane;
        import away3d.materials.BitmapMaterial;
        import flash.geom.Point;
        import flash.geom.Rectangle;

        import flash.display.*;
        import flash.events.*;
        import flash.net.*;
        import flash.media.Video;

        /**
        * ...
        * @author DefaultUser (Tools -> Custom Arguments...)
        */
        public class videoPlane extends Plane
        {
                private var video: DisplayObject;
                private var videoURL:String;
                private var videoBitmapData: BitmapData;
                private var videomaterial: BitmapMaterial;

                private var alphaMap:BitmapData;

                private var vidConnection:NetConnection;
                private var vidStream:NetStream;
                private var vid:Video;
                private var infoClient:Object;
                private var alphax:Number;
                private var alphay:Number;
                private var asset:String;
                private var alphaBool:Boolean;

                //private var pix:Number;

                private var aspectRatio:Number;



                public function videoPlane(assetLocation:String)
                {


                        asset = assetLocation;

                        alphaBool = true;

                        trace("videoPlane()");
                        this.segmentsH = 8; //increases the number of triangles 
in the
plane, and hence improves the accuracy of
                        this.segmentsW = 8; //the mean z algorithm used to 
determine Z-
depth when rendering


                        vidConnection = new NetConnection();
                        vidConnection.connect(null);
                        vidStream = new NetStream(vidConnection);

                        infoClient = new Object();
                        vidStream.client = infoClient;

                        vid = new Video();
                        vid.attachNetStream(vidStream);

                        vidStream.play(asset);

                        this.videoBitmapData = new BitmapData(vid.width, 
vid.height, true,
0xFF00ce);

                        videomaterial = new 
BitmapMaterial(this.videoBitmapData);
                        videomaterial.precision = 5;

                        this.material = videomaterial;
                        this.bothsides = true;
                        this.videoBitmapData.draw(vid);

                        aspectRatio = 1024 / 576;

                        this.height = 50;
                        //trace(vid.videoWidth + " " + vid.videoHeight + " " +
aspectRatio);
                        this.width = this.height * aspectRatio;


                        alphaMap = new BitmapData(vid.width, vid.height, true,
0x7F000000);

                        vidStream.addEventListener(NetStatusEvent.NET_STATUS,
vidStreamCompleteHandler);


                }

                private function 
vidStreamCompleteHandler(ns:NetStatusEvent):void
                {
                        //TODO: add functionality to restart video stream here
                //      vidStream.play(asset);
                }

                public function adjustAlphaMap():void
                {
                        trace("adjustAlpha" + alphaBool);

                        if (alphaBool)
                        {
                                alphaMap = new BitmapData(vid.width, 
vid.height, true,
0xFF000000);
                        }
                        else
                        {
                                        alphaMap = new BitmapData(vid.width, 
vid.height, true,
0x7F000000);
                        }

                        alphaBool = !alphaBool;
                }

                public function updateVideo():void
                {
                        //trace("updateVideo");
                        if(vid != null)
                        {
                                //trace("vid");
                                this.videoBitmapData.draw(vid);
                                videoBitmapData.copyChannel(alphaMap, new 
Rectangle(0, 0,
vid.width, vid.height), new Point(0, 0), 8, 8);

                                trace(videoBitmapData.getPixel(100, 
100).toString());
                        }
                }
        }
}

Reply via email to