Skip to main content
Inspiring
June 23, 2009
Question

Error #1010: A term is undefined and has no properties

  • June 23, 2009
  • 2 replies
  • 1759 views

Hi guys,

          i am creating AS3 video player.i got this error. Any body can help me.

          Error #1010: A term is undefined and has no properties

Thanks &Regards

E.Kamalakkannan

This topic has been closed for replies.

2 replies

Inspiring
June 24, 2009

Thank you guys ....

i am clear the error......

Known Participant
April 6, 2010

getting same error

TypeError: Error #1010: A term is undefined and has no properties.
    at newsemfinal30_Scene1_fla::MainTimeline/frame1()[newsemfinal30_Scene1_fla.MainTimeline::frame1:2]

1 playBtn.addEventListener(MouseEvent.CLICK,playF);
2 semVideo.playButton.addEventListener(MouseEvent.CLICK,playF);
3 semVideo.source = "SEMfinal-half.f4v";
4
5 function playF(e:MouseEvent) :void{
6 playBtn.visible=false;
7 semVideo.play();

8

9 }

June 23, 2009

Um... some code would be helpful.

Inspiring
June 23, 2009

package com{
    import com.*;
    import flash.display.*;
    import flash.events.*;
    import flash.display.SimpleButton;
    //Video
    import flash.net.NetConnection;
    import flash.events.NetStatusEvent;
    import flash.events.AsyncErrorEvent;
    import flash.net.NetStream;
    import flash.media.Video;
    //Timer
    import flash.utils.Timer;
    import flash.utils.setInterval;
    import flash.utils.clearInterval;
    //Rectangle
    import flash.geom.Rectangle;
    //Sound
    import flash.media.Sound;
    import flash.media.SoundTransform;
    //XML
    import flash.xml.XMLDocument;
    import flash.events.ErrorEvent;
    import flash.net.URLRequest;
    import flash.net.URLLoader;

    public class Main extends Sprite {
        //Movieclip loader
        private var control_mc:control_mc_load=new control_mc_load;
       
        private var nc:NetConnection;
        private var ns:NetStream;
        private var video:Video;
        //Number
        private var totalTimer:Number;
        private var vidwidth:Number;
        private var vidheight:Number;
        private var default_timer:uint;
        private var vidposition:Number=0;
        //Boolean
        private var bolProgressScrub:Boolean=false;
        //Rectangle
        private var volumeBound:Rectangle;
        private var soundBound:Rectangle;
        //volume
        private var videoVolumeTransform:SoundTransform = new SoundTransform();
        //XML
        private var datalist:XML = new XML ();
        private var xmlFileLoc:String="videoplayer.xml";
        private var urlLoader:URLLoader;
        //Array
        private var videoname:Array=new Array;
         public var client:Object=new Object();

        public function Main() {
            //NetConnection
            nc = new NetConnection();
            nc.connect(null);
            nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            video = new Video();
            addChild(video);
            addChild(control_mc);
            xmlLoader();
            stage.showDefaultContextMenu=false;
            //scalemode
            stage.scaleMode = StageScaleMode.NO_SCALE;
            stage.align = StageAlign.TOP_LEFT;
            stage.displayState = StageDisplayState.NORMAL;
            stage.addEventListener(Event.RESIZE, resizeHandler);
            //ActivateHandler();
           
            /*video.width = stage.stageWidth;
            video.height =stage.stageHeight-control_mc.height-1.5;// (video.width*aspect2);
            video.x = ((stage.stageWidth-video.width)/2);
            video.y = 0;*/
            //play/pause button Event
            control_mc.play_btn.addEventListener(MouseEvent.MOUSE_UP, onPlay);
            control_mc.pause_btn.addEventListener(MouseEvent.MOUSE_UP, onPause);
            control_mc.stop_btn.addEventListener(MouseEvent.MOUSE_UP, onStop);

            //fullscreen button event
            control_mc.max_btn.addEventListener(MouseEvent.MOUSE_UP, onMaxevent);
            control_mc.min_btn.addEventListener(MouseEvent.MOUSE_UP, onMinevent);
            //Vbar
            control_mc.vBar.addEventListener(MouseEvent.MOUSE_DOWN,seekMouseDown);
            control_mc.vBar.mcProgressScrubber.x=0;
            stage.addEventListener(MouseEvent.MOUSE_UP,seekMouseUp);
            //Volume Bar.
            control_mc.volume_mc.volume_slider.addEventListener(MouseEvent.MOUSE_DOWN, volumeMouseDown);
            control_mc.volume_mc.speaker_mc.addEventListener(MouseEvent.MOUSE_DOWN, onspeakerEvent);
            stage.addEventListener(MouseEvent.MOUSE_UP,volumeMouseUp);
            //
            control_mc.firstRewind_btn.addEventListener(MouseEvent.MOUSE_UP, onfirstRewind);
            control_mc.lastForward_btn.addEventListener(MouseEvent.MOUSE_UP, onlastForward);
            ActivateHandler();
            //volumeBound=new Rectangle(0,control_mc.vBar.mcProgressScrubber.y,control_mc.vBar.vBarBg.width,control_mc.vBar.mcProgressScrubber.y);
        }
        private function xmlLoader():void {
            var URL:String=xmlFileLoc;
            var urlRequest:URLRequest=new URLRequest(URL);
            urlLoader=new URLLoader  ;
            urlLoader.addEventListener("complete",onLoaded);
            urlLoader.addEventListener("ioerror",ifFailed);
            urlLoader.load(urlRequest);
        }
        private function onLoaded(evt:Event):void {
            datalist = new XML(evt.target.data);
            Parsexml(datalist);
        }
        private function Parsexml(video:XML) {
            var imagelist:XMLList = video.vidname.children();
            //nc.connect("rtmp://localhost/mediaplayer");
            nc.connect(null);

            //if (video.controladmin.playpas == 'off') {
                showButton('playpause', true);
            /*} else {
                showButton('playpause', false);
            }*/
            for (var i:Number=0; i<imagelist.length(); i++) {
                videoname.push(video.vidname.vid);
            }
            //trace(videoname)
            videoname_url(0);
        }
        private function ifFailed(errorEvent:ErrorEvent):void {
            //txtDisplay.text="XML Load Fail";
        }
        private function resizeHandler(event:Event):void {
            if (stage.displayState == StageDisplayState.NORMAL) {
                video.smoothing = true;
            } else {
                video.smoothing = false;
            }
            ActivateHandler();
        }
        //ActivateHandler
        private function ActivateHandler():void {
            //Preloader
            preloader_mc.x=(stage.stageWidth/2)-preloader_mc.width;
            preloader_mc.y=(stage.stageHeight/2)-preloader_mc.height;

            control_mc.x=.2;
            control_mc.y=stage.stageHeight-control_mc.height-1;
            control_mc.bg_mc.width=stage.stageWidth-1;
            control_mc.max_btn.x=stage.stageWidth-control_mc.min_btn.width-1;
            control_mc.min_btn.x=control_mc.max_btn.x-control_mc.min_btn.width;

            control_mc.volume_mc.x=control_mc.min_btn.x-(control_mc.volume_mc.width+4);
            control_mc.total_txt.x=control_mc.volume_mc.x-control_mc.total_txt.width;
            /*video.width = stage.stageWidth;
            video.height =stage.stageHeight-control_mc.height-1.5;// (video.width*aspect2);
            video.x = ((stage.stageWidth-video.width)/2);
            video.y = 0;*/
            videopos();
            //VBar
            //control_mc.vBar.x = 260;
            //control_mc.vBar.y =  stage.stageHeight- 100;
            control_mc.vBar.vBarBgcolor.width=stage.stageWidth-365;
            control_mc.vBar.vBarBg.width=stage.stageWidth-365;
            control_mc.vBar.seek_fill.width = 0;
            volumeBound=new Rectangle(0,control_mc.vBar.mcProgressScrubber.y,(control_mc.vBar.vBarBg.width-control_mc.vBar.mcProgressScrubber.width),control_mc.vBar.mcProgressScrubber.y);
            //Volume Controls
            soundBound=new Rectangle(control_mc.volume_mc.volume_slider.sBarBg.x,control_mc.volume_mc.volume_slider.sBarKnob.y,(control_mc.volume_mc.volume_slider.sBarBg.width-control_mc.volume_mc.volume_slider.sBarKnob.width),0);
        }
        private function videopos():void {
            var aspect1:Number = (stage.stageWidth/vidwidth);
            var aspect2:Number = (stage.stageHeight/vidheight);
            //if (aspect1<aspect2) {
            video.width = stage.stageWidth;
            video.height = (vidheight*aspect1)-control_mc.height;
            video.x = 0;
            video.y = ((stage.stageHeight-video.height-control_mc.height)/2);
            /*} else {
            video.height = stage.stageHeight;
            video.width = (video.width*aspect2);
            video.x = ((vidwidth-video.width)/2);
            video.y = 0;
            }*/
        }
        //onlastForward
        private function onlastForward(event:Event):void {
            NextTrack();
        }
        private function NextTrack() {
            if (vidposition > videoname.length-1) {
                vidposition = 0;
            } else {
                vidposition++;
            }
            videoname_url(vidposition);
        }
        //onfirstRewind
        private function onfirstRewind(event:Event):void {
            if (vidposition <=0) {
                vidposition =  videoname.length-1;
            } else {
                vidposition--;
            }
            videoname_url(vidposition);
        }
        //ShowButton
        private function showButton(str:String, flag:Boolean):void {
            if (str=='playpause') {
                control_mc.pause_btn.visible = (flag)?true:false;
                control_mc.play_btn.visible = (flag)?false:true;
            }
        }
        //Play
        private function onPlay(event:MouseEvent):void {
            ns.resume();
            showButton('playpause',true);
            //clearInterval(default_timer);
            //default_timer=setInterval(oncurTime, 10);
        }
        //Pause
        private function onPause(event:MouseEvent):void {
            ns.pause();
            showButton('playpause',false);
        }
        //Stop
        private function onStop(event:MouseEvent):void {
            ns.pause();
            ns.seek(0);
            showButton('playpause',false);
        }
        // Seek scrubber down
        private function seekMouseDown(evt:Event):void {
            bolProgressScrub =true;
            //showButton('playpause',true);
            control_mc.vBar.mcProgressScrubber.startDrag(true,volumeBound);
        }
        // Seek scrubber up
        private function seekMouseUp(evt:Event):void {
            //Vbar
            bolProgressScrub =false;
            control_mc.vBar.mcProgressScrubber.stopDrag();
        }
        //Speaker Event
        private function onspeakerEvent(E:Event):void {
            trace("SPPPPPPPPPKKKKKKKK");
        }
        //volume control down button
        private function volumeMouseDown(E:Event):void {
            control_mc.volume_mc.volume_slider.sBarKnob.startDrag(true, soundBound);
        }
        //Volume Control Bar
        private function volumeMouseUp(E:Event):void {
            control_mc.volume_mc.volume_slider.sBarKnob.stopDrag();
            var control_value:Number= (control_mc.volume_mc.volume_slider.sBarKnob.x) / (control_mc.volume_mc.volume_slider.sBarBg.width-control_mc.volume_mc.volume_slider.sBarKnob.width);
            videoVolumeTransform.volume = (control_mc.volume_mc.volume_slider.sBarKnob.x-control_mc.volume_mc.volume_slider.sBarKnob.width) / (control_mc.volume_mc.volume_slider.sBarBg.width);
            ns.soundTransform = videoVolumeTransform;
            update_speaker(control_value);
        }
        private function update_speaker(nVol:Number) {
            control_mc.volume_mc.speaker_mc.v1.visible = (nVol>=0.25) ? true : false;
            control_mc.volume_mc.speaker_mc.v2.visible = (nVol>=0.60) ? true : false;
            control_mc.volume_mc.speaker_mc.v3.visible = (nVol>=0.96) ? true : false;
        }
        //MaxEvent
        private function onMaxevent(event:MouseEvent):void {
            stage.displayState = StageDisplayState.FULL_SCREEN;
        }
        //MinEvent
        private function onMinevent(event:MouseEvent):void {
            stage.displayState = StageDisplayState.NORMAL;
        }
        //Current Timer
        private function oncurTime():void {
            if (bolProgressScrub == false) {
                control_mc.vBar.mcProgressScrubber.x=ns.time *(control_mc.vBar.vBarBg.width-control_mc.vBar.mcProgressScrubber.width)/(totalTimer);
            } else {
                ns.seek(Math.round(control_mc.vBar.mcProgressScrubber.x * totalTimer/(control_mc.vBar.vBarBg.width-control_mc.vBar.mcProgressScrubber.width)));
            }
            control_mc.vBar.seek_fill.width=control_mc.vBar.mcProgressScrubber.x;
            control_mc.current_txt.text=videoTimeConvert(ns.time);
        }
        //NetStatusEvent
        private function netStatusHandler(event:NetStatusEvent):void {
            switch (event.info.code) {
                case "NetConnection.Connect.Success" :
                    // Call doPlaylist() or doVideo() here.
                    doPlaylist(nc);
                    break;
                case "NetConnection.Connect.Failed" :
                    break;
                case "NetConnection.Connect.Rejected" :
                    break;
                case "NetStream.Play.Stop" :
                    break;
                case "NetStream.Play.StreamNotFound" :
                    break;
                case "NetStream.Publish.BadName" :
                    trace("The stream name is already used");
                    break;
                case "NetStream.Buffer.Empty" :
                    //ns.bufferTime = 2;
                    //trace("Reduced buffer to 2");
                    preloader_mc.visible=true;
                    break;
                case "NetStream.Buffer.Full" :
                    //ns.bufferTime = 10;
                    //trace("Expanded buffer to 10");
                    preloader_mc.visible=false;
                    break;
                case "NetStream.Buffer.Flush" :
                    trace("flush");
                    NextTrack();
                    break;
            }
        }
        // create a playlist on the server
        private function doPlaylist(nc:NetConnection):void {
            ns = new NetStream(nc);
            ns.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
            videoname_url(vidposition);
        }
        private function videoname_url(vidpos:Number) {
            //var client:Object = new Object();
            client.onMetaData = metaDataHandler;
            ns.client = client;
            video.attachNetStream(ns);
            //trace(videoname[0])
            ns.play(videoname[vidpos].toString())
            //ns.play(videoname[vidpos].toString(), 0, totalTimer, true );
            clearInterval(default_timer);
            default_timer=setInterval(oncurTime, 10);
        }
        //metaDataHandler
        private function metaDataHandler(infoObject:Object):void {
            //trace("metadata: duration=" + infoObject.duration + " width=" + infoObject.width + " height=" + infoObject.height + " framerate=" + infoObject.framerate);
            totalTimer = infoObject.duration;
            vidwidth = infoObject.width;
            vidheight = infoObject.height;
            control_mc.total_txt.text=videoTimeConvert(totalTimer);
            videopos();
            /*video.x = (stage.stageWidth - vidxpos)/2;
            video.y = (stage.stageHeight -vidypos)/2;
            video.width = vidxpos;
            video.height = vidypos;*/
            //var aspect2:Number = ((stage.stageWidth)/vidheight);
            /*for (var i:String in infoObject) {
            trace("metadata "+i+" : " + infoObject);
            }*/
        }
        //Timer convertion.
        private function videoTimeConvert(myTime):String {
            var minutes:Number = Math.floor(myTime / 60);
            var seconds:Number = Math.floor(myTime - (minutes * 60));
            var sec:String;
            var min:String;
            if (seconds < 10) {
                sec = "0" + seconds.toString();
            } else {
                sec = seconds.toString();
            }
            if (minutes < 10) {
                min = "0" + minutes.toString();
            } else {
                min = minutes.toString();
            }
            return min + ":" + sec;
        }
    }
}

June 23, 2009

Cute. Get your code down to the actual problem and you might get some help.