Skip to main content
Participant
May 21, 2011
Question

Access of undefined property theVideo!

  • May 21, 2011
  • 2 replies
  • 637 views

Guys am tottaly new in action script.and i have flash cs5 and i want to ask how to recover this error i asked in title.

i got this error while i execute this script.

import flash.net.NetConnection;
import flash.net.NetStream;

var nc:NetConnection = new NetConnection();
nc.connect(null);

var ns:NetStream = new NetStream(nc);

theVideo.attachVideo(ns);

ns.play("video.flv");

This topic has been closed for replies.

2 replies

relaxatraja
Inspiring
May 23, 2011

import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.events.NetStatusEvent;

var connection:NetConnection;
var video:Video;
video = new Video();
video.width = 480;
video.height = 320;

connection = new NetConnection();
connection.addEventListener(NetStatusEvent.NET_STATUS, netConnectionEvent);
connection.connect(null);

function netConnectionEvent(event:NetStatusEvent):void {
    event.target.removeEventListener(NetStatusEvent.NET_STATUS,netConnectionEvent);
    if (event.info.code == "NetConnection.Connect.Success") {
        var stream:NetStream = new NetStream(connection);
        stream.addEventListener(NetStatusEvent.NET_STATUS, netStreamEvent);
        var client:Object = new Object();
        client.onMetaData = onMetaData;
        stream.client = client;
        // attach the stream to the video to display
        video.attachNetStream(stream);
        stream.play("ColoristCuremq.flv");
        addChild(video);
    }
}

function onMetaData(info:Object):void {
}
function netStreamEvent(event:NetStatusEvent):void{
   
}

Copy and paste the code and give your video name

Ned Murphy
Legend
May 21, 2011

As far as the code shows, there is nothing that declares theVideo anywhere, so it is an unknown unless it is some object on the stage (which I doubt).  Chances are it would have involved something in the way of...

var theVideo:Video = new Video();

But aside from that, as far as I can tell, attachVideo is an AS2 method, not an AS3 method, so you probably need to either swicth the version of AS your file is trying to publish with, or stick with AS3 publishing and look thru the help documentation or Google for examples on implementing the NetConnection class with AS3.