FORUMS: list search recent posts

NetConnection Question

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
shawn eyre
NetConnection Question
on Jan 9, 2009 at 7:18:02 pm

Ok I know I use this action to load external video. How do I do it? Does the button get

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

or is the button called Null?

And where do I put this code?

var ns:NetStream = new NetStream(nc);
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, asyncErrorHandler);
ns.play("video.flv");
function asyncErrorHandler(event:AsyncErrorEvent):void
{

var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);

I need my hand held on the step by step process. I have the video as an external flv already. The file is 11:30min in length so i cant embed the video I need to to link to it. It's all going to be on the same cd, not at a url.

Thanks





Return to posts index

Amy Lee Walton
Re: NetConnection Question
on Jan 11, 2009 at 5:26:20 am

Hi there,

Null is the value you always use unless you're using a Flash Media Server, has nothing to do with the button.

On the stage, just have your button and have it named appropriately... mine is playBtn. In this code I basically open the net connection, put in a netstream, set the client to stage, plug in the flv, attach it to a video object, then to stage, then pause it and add an event that detects when the button is click and plays the movie. you may want to add a still image of the movie to represent it and make that the button or something cool like that. either way the below code should work.

Good luck!
Amy Lee


-----------------

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

var ns:NetStream = new NetStream(nc);
ns.client = this;
ns.play("videos/yourvideoname.flv");

var vid:Video = new Video();
vid.attachNetStream(ns);
addChild(vid);
vid.x = 110;
vid.y = 90;

playBtn.addEventListener(MouseEvent.CLICK, playHandler);
ns.pause();

function playHandler(e:MouseEvent):void {
ns.resume();
}



Return to posts index

shawn eyre
Re: NetConnection Question
on Jan 12, 2009 at 4:56:37 pm

Ok I kind of understand, but now Im having problems assigning actions to my button. I have a background video with audio that plays when the swf loads. I have 3 text links at the bottom. 2 of them are dynamic text that link to web adresses. The 3rd one i want to make link to the movie in question. So I make it a button, but i still cant add actions to it. I have totally forgotten how to do this. All I need is the text link to load the video. Not hard, but it sure is kicking my butt. The video file on my hard drive is called BEE Program wo adress. Do i name my button then make a new actions layer to direct the on release action??????? PLEASE HELP. Keep it simple, I'm stupid.



Return to posts index


Amy Lee Walton
Re: NetConnection Question
on Jan 12, 2009 at 6:44:06 pm

Yes, you must name your button. You must name everything to be able to control it with AS.

I thought you wanted to load the page with the video stopped and then have a button that starts the video. In that case, on the same central actionscript layer you used for the video code add:

yourbuttonname.addEventListener(MouseEvent.CLICK, playVideoFunction);

function playVideoFunction(e:MouseEvent):void {
ns.resume();
}

you can use that code for all the buttons with that same format... you just need different functions for each with their approriate code. Make sense?



Return to posts index

shawn eyre
Re: NetConnection Question
on Jan 12, 2009 at 7:49:07 pm

Closer. I made an actions layer. I copied the code you sent. What I don't understand is how does the code reference the video if it is not embedded in the timeline? The video is too long to embed so I want it to reference it from the HD. Do i use a call action? And your are correct I want the button to play the video when clicked, but not untill then.



Return to posts index

shawn eyre
Re: NetConnection Question
on Jan 12, 2009 at 10:20:32 pm

Ok. I used this code and the video plays. Great! Now a few more questions. The way I have my project set, it has an embedded video on layer 1 with some background music. This is the menu screen. Is there a way I can have that stop when the other video plays? Also the referenced video in the action script is 720x486 pixels. When I click the button to play the video it plays it at 320x240. Do i need to use a flv playback component?



Return to posts index


Amy Lee Walton
Re: NetConnection Question
on Jan 14, 2009 at 3:33:25 am

Give the embedded the menu an instance name on the stage, then you can control it with AS. Add in the function to play the new video a line telling the bg video to stop. Set the width and heigh of that video in AS... look at my code earlier in this post for an example. you dont' need an flv playback for that since you're using netconnect for it.



Return to posts index

shawn eyre
Re: NetConnection Question
on Jan 15, 2009 at 3:33:21 pm

Ok I used this code and it works great. Now how do I make a button play it. I know I use the on release or on click AS, but that's all i know. I want it so when the button is clicked, it plays the video. Please help and Thank you for ll of your help so far.



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]