A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: clearing a video frame the stage

  1. #1
    Member
    Join Date
    May 2005
    Location
    San Francisco
    Posts
    55

    clearing a video frame the stage

    I have a script that loads in an external flv file.

    i can remove the instance of _video from the stage, however i cant seem to reference it properly in order to clear its NetStream.

    Here's the code:

    Code:
    package {

    import flash.display.*;
    import flash.net.*;
    import flash.display.*;
    import flash.text.*;
    import flash.events.*;
    import flash.media.*;
    import flash.geom.*;

    public class MainStageDocCLass extends MovieClip {


    private var _localConnection:LocalConnection;
    public var myLoader:Loader = new Loader();
    var nc:NetConnection = new NetConnection();
    private var _video:Video = new Video(532,272);





    public function MainStageDocCLass() {

    try {
    _localConnection = new LocalConnection;
    _localConnection.connect( "sfgovChannel");
    _localConnection.client = this;
    } catch (err:Error) {/*NULL*/
    }

    loadHomeNav();
    trace("MainStageDocCLass.as has loaded");
    }

    public function loadItems(clip:String, xpos:uint, ypos:uint):void {
    var myLoader:Loader = new Loader();
    addChild(myLoader);
    myLoader.load(new URLRequest(clip));
    myLoader.x = xpos;
    myLoader.y = ypos;
    }

    public function loadVideo() {
    loadItems("AgencyContent/OfficeContent/Topic1/SectionA/CloseMovieClip.swf", 0, 325);
    addChild(_video);
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    ns.addEventListener(NetStatusEvent.NET_STATUS, onStatusEvent);
    function onStatusEvent(stat:Object):void {
    trace(stat.info.code);
    }
    var meta:Object = new Object();
    meta.onMetaData = function(meta:Object)
    {
    trace(meta.duration);
    };
    ns.client = meta;
    _video.attachNetStream(ns);
    ns.play("example.flv");

    }

    public function closeMovies() {
    _video.clear();
    nc.close();
    removeChild(_video);
    trace("closeMovies success");
    }


    }
    }
    im pretty sure i need to issue ns.close(); but i dont know how to access it from a different method.

    ns.close(); gives me Access of undefined property ns
    Last edited by paragonc; 03-18-2008 at 07:57 PM.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    Declare ns as a private var in the beginning, since you have it as a local variable.

    private var ns:NetStream;
    ns = new NetStream(nc);
    - The right of the People to create Flash movies shall not be infringed. -

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center