• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

AS3 stop embedded .flv when page change

Guest
Mar 08, 2009 Mar 08, 2009

Copy link to clipboard

Copied

I decided to try and build a site with AS3 and am regretting it. What used to be simple in AS2 confounds me in AS3.
I have an embedded .flv on a page and when I navigate to another page, the video continues to play and in fact will duplicate and triplicate etc. if I go back and forth between pages.

What is the code to shut the video off when I navigate to new web page?

Thanks
TOPICS
ActionScript

Views

9.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

If you're using the video component:
myVideo.stop();

If you're using the netConnection / netStream method:

netStream.close();

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

I tried this on the frame of the new pages but it doesn't work. I gave it an instance name of video_mc and put video_mc.stop(); on the frames where I didn't want the video to play, however I get an error when I publish.

Can I add the code to the other page buttons and if so how. Thank you so much for your reply.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

What is the error you're getting?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index2_fla::MainTimeline/frame1()

I have a video that plays with a video component on frame 20. I put it in movie clip and gave it an instance name video_mc. I used the import video to put it on the stage; I did not drag a component and link the .flv to it.

I also have a video I put on frame 1 that I Imported to stage in a movie clip. I can stop it by the stop code you gave me but that code doesn't work with the video on frame 20.

Perhaps the error above will help.

Thank you...

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

That error means that something you are calling isn't available so therefore, flash can't access the null property or method.

So you have to name your movie clip and your video, then your target would be movieclipName.videoName.stop();

Once you redo your target this should clear up that error, unless you have something else happening.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

Okay code works on the frame the video is on so thank you I just learned something.

Now how do I get that video which I called video_mc.vid to stop playing when I hit a button which takes me to another page? I have all the pages on the time line and I am not calling a movie clip or a separate .swf file, but simply navigating to a different frame in the flash movie that represents a new page.

Do I need to create a MouseEvent to tell the video_mc.vid to stop playing? If so, how?

Thank you

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

You should be able to call movieclipName.videoName.stop(); from within the function that you're using to navigate to the next frame.

testButton.addEventListener(MouseEvent.CLICK,goToFrame):void
{
gotoAndPlay("frameName");
movieclipName.videoName.stop();
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

Sorry to jump in here but I've got a similar issue. I have a "back" button to return to frame 1. I can put the code in button to stop a particular flv e.g. my_mc.my_flv stop(); but what code would you use to stop ANY flv that is playing? If I list all the possible flv in the button code, I get the error that the method or property can't be accessed. Probably since only one of the flvs are playing. Is there a general "stop all flvs"
TIA
Dirk

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

Hi GreenFlasher,
I dont know if this is what you are referrring to, but I had a similar issue last week and what I used "SoundMixer.stopAll();" command on my nav buttons. This stops the currently playing movie before navigating somewhere else.

//Navigation button
buttonName.addEventListener(MouseEvent.CLICK, exitbutton);
function exitbutton(event:MouseEvent):void
{
SoundMixer.stopAll();
gotoAndStop(2);
}

I hope this helps.
Rafa.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

Referring to rafa@mediatech, I was having this same problem and added this code to my script...and bingo, it's all working. thanks for the help!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

Dirk,
Sounds like you're trying to call the actual .flv file and telling it to stop.? You just have to give your player an instance name and tell it what to do.

videoPlayerName.stop();

Then regardless of what video is playing, when you call the stop function it ends.

Let me know if I'm missing something in the translation.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

function aboutPage(e:MouseEvent):void
{
video_mc.vid.stop();
gotoAndPlay("about");
}

Fantastic! This code worked but now I have another problem :(.

If I hit the button that takes me to the page where the video plays and then I hit the button more than once, it plays the video on top of one another.

Current code for page with video:

coach_mc.addEventListener(MouseEvent.CLICK, coachPage);

function coachPage(e:MouseEvent):void
{
gotoAndPlay("coach");
}

How can I prevent this from happening?

Thanks for all the help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

I put an invisible movie clip over the button when on the video page of the website to prevent user from hitting button multiple times and playing the video on top of one another (hearing multiple audio files but only see one video).

However with the code I used, if I don't navigate to the page that plays the video, but hit one of the other buttons that tells the video to stop then I get the following error code. It never started so I am assuming that is the reason I get the following.

at index2_fla::MainTimeline/aboutPage()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index2_fla::MainTimeline/homePage()

Any ideas?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

So add the video stop method in your button function; this way whenever you hit your button, the first thing you do is stop the video, then once on the coach frame and your video starts to play, there is only one instance playing. Give that a try and see if you get the result your after.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

That works but if I never go to the coach frame, the stop function is also on my other buttons and then I get this error:

at index2_fla::MainTimeline/aboutPage()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at index2_fla::MainTimeline/homePage()

I am assuming this is because there is no video to stop. How can I avoid this error? Probably with an if else which I don't know how to write:
If video is playing - stop video, if video is not playing go to frame???

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

if(video_mc.vid..play == true)
{
trace("is playing");
} else {
trace("is not playing");
}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

I am glad you said that rafa@mediatech's advise worked. It didn't make complete sense to me but after you were successful, I added that simple line and it worked beautifully.

Thank you! What is the SoundMixer and how else can I use it?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Mar 09, 2009 Mar 09, 2009

Copy link to clipboard

Copied

Here's a soundmixer tutorial for you to look at:
http://www.communitymx.com/content/article.cfm?cid=8E9A0

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 05, 2011 Jan 05, 2011

Copy link to clipboard

Copied

the stop all sound just do that. but what if i want to stop the video, stop the download of the video. ? how do you stop the video when entering another frame?

the Video1.stop(); doesnt work.

is there anything like the stopp all sound to stopp al video?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 04, 2016 May 04, 2016

Copy link to clipboard

Copied

LATEST

I am having the same problem and I would like to stop video embedded into swf that is displayed into loader

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines