Skip to main content
Inspiring
December 7, 2011
Question

Need help putting NetConnection Video into empty mc with controls

  • December 7, 2011
  • 1 reply
  • 445 views

I am not sure how to accomplish what I need. I'm developing an iOS video app. I will package ALL videos with the ipa.  I created a net connection and net stream successfully. I'm importing them into an array. They play perfectly. However, I need a way to mask out the main interface. Ideally, I'd like to drop that video into a dynamically called movie clip that has the controls in it. I made one called holder_mc. (There are no controls in it yet.) I cannot seem to get that on screen at the right z-index (not sure if that's the right term). I tried creating an empty movie clip and putting the video in it. That did not work either. This has to be simple. I must be overlooking something! Please help? [NOTE: This is my final project for a scripting class. I am using videos that I purchased. I will NOT publish them for any reason.]

 

This topic has been closed for replies.

1 reply

Inspiring
December 7, 2011

//HERE'S THE CODE:

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

stage.align= StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;

var video:Video = new Video;

//puts the close button on the screen, "closeBtn" is the class name given when exported to actionscript
    var newcloseBtn:backBtn=new backBtn();
   
    newcloseBtn.x = stage.stageWidth - 60;
    newcloseBtn.y = 45;



//accelerometer orientation code goes here
    video.x = (stage.stageWidth- video.width) / 2;
    video.y = (stage.stageHeight- video.height) / 2;

    video.width = stage.stageWidth;// Resize video instance.
    //video.height = (stage.stageHeight - video.height) / 2;
   
   

var NC:NetConnection = new NetConnection();
NC.connect(null);// starts a connection; null is used unless using Flash Media Server

var NS:NetStream = new NetStream(NC);
var meta:Object = new Object();

meta.onMetaData = function(meta:Object){
    trace(meta.duration);
}

NS.client = meta;
video.attachNetStream(NS);

var vidArray:Array = new Array("SFN1/intro.flv", "SFN1/Stance.flv","SFN1/Safety_Fun_Learning.flv", "SFN1/Strapping In.flv", "SFN1/ Skating.flv");

introBtn.addEventListener(MouseEvent.CLICK, goIntro);

function goIntro(event:MouseEvent):void
{
    trace(vidArray[0]);
    NS.play(vidArray[0]);
    addChild(video);
    //video.height = stage.stageHeight;
    addChild(newcloseBtn);

}

stanceBtn.addEventListener(MouseEvent.CLICK, goStance);

function goStance(event:MouseEvent):void
{
    trace(vidArray[1]);
    NS.play(vidArray[1]);
    addChild(video);
    addChild(newcloseBtn);
   
   

}

safetyBtn.addEventListener(MouseEvent.CLICK, goSafety);

function goSafety(event:MouseEvent):void
{
    trace(vidArray[2]);
    NS.play(vidArray[2]);
    addChild(video);
    //video.height = stage.stageHeight;
    addChild(newcloseBtn);
}

strapBtn.addEventListener(MouseEvent.CLICK, goStrap);

function goStrap(event:MouseEvent):void
{
    trace(vidArray[3]);
    NS.play(vidArray[3]);
    addChild(video);
    //video.height = stage.stageHeight;
    addChild(newcloseBtn);
}

skatingBtn.addEventListener(MouseEvent.CLICK, goSkating);

function goSkating(event:MouseEvent):void
{
    trace(vidArray[4]);
    NS.play(vidArray[4]);
    addChild(video);
    //video.height = stage.stageHeight;
    addChild(newcloseBtn);
}

    //adds the listener for the close button
    newcloseBtn.addEventListener(MouseEvent.CLICK, closeWindow);
    //tells flash to remove the opened window (makes the close button work as it should
    function closeWindow(e:MouseEvent):void
        {
            removeChild(video);
            removeChild(newcloseBtn);
            SoundMixer.stopAll();
        }