Skip to main content
Arioman
Inspiring
May 29, 2013
Answered

How Stop sound of Flvplayer or close Video after Skip

  • May 29, 2013
  • 1 reply
  • 1438 views

hi , i have a FLvplayer to play an intro in first frame of my project

i put a skip button in first frame too for users that dont want to see intro , an when i click on this button i use simple "gotoAndPlay(2);" 

but i have problem with sound , cause the sound of my video still playing in frame 2 ( after click skip )

i try to add "SoundMixer.stopAll();" function to my skip button and this work for stop sound of flvplayback but it cause conflict to my mp3 player in frame 2 ( the script

i dont know why this happend ....

my video have instance name "intro" and i have

intro.addEventListener(Event.COMPLETE, instancecomplete);

function instancecomplete(event:Event):void {

    gotoAndStop(2)

}

to simply force to gotostop frame 2 after Intro video end ...

in other means  have two script :

1- Event.COMPLETE to say when intro video end then go to another frame (2) ...

2-simple goto script in my skip button on the same frame as intro movie is to say go to another frame (2)

the problem come when i use skip button and it seems the video still played in background and when end the Event.COMPLETE run too !!

so what script i need to use for close this video for my skip button ? this may solve my sound of flv player too

thanks

This topic has been closed for replies.
Correct answer moccamaximum

thanks again ; but i get error when i use

Scene 1, Layer 'preloader1', Frame 2, Line 11120: Access of undefined property VideoEvent.

here my script ( video instance name is "intro" and my skip button instance name is "skipbt" :

intro.addEventListener (VideoEvent.COMPLETE, instancecomplete);

function instancecomplete(event:Event):void {

    gotoAndStop(3);

   

}

skipbt.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame);

function fl_ClickToGoToAndStopAtFrame(event:MouseEvent):void

{

    gotoAndPlay(3);

    intro.stop();

   

    }

where is wrong ?  why sound not stop and intro.stop(); not work in skipbt ?


at the beginning of your code in the first frame write:

import fl.video.VideoEvent

then change

function instancecomplete(event:Event):void {

    gotoAndStop(3);

   

}

to

function instancecomplete(event:VideoEvent):void {

    gotoAndStop(3);

   

}


1 reply

Inspiring
May 29, 2013

you have to explicitly call videoplayer.stop() // assuming the instance name of your flvPlaybackcomp is "videoplayer"

Arioman
AriomanAuthor
Inspiring
May 29, 2013

thanks so much

this works well in my project but i get some line of errors in output after test movie :

at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::FLVPlayback/http://www.adobe.com/2007/flash/flvplayback/internal::handleVideoEvent()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::httpDoStopAtEnd()
at fl.video::VideoPlayer/http://www.adobe.com/2007/flash/flvplayback/internal::doUpdateTime()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()

this can be happend for when i click on skip button Event.Complete cant be run and i really dont need to run ,i dont feel any error in running my swf .

is this ok to ignore this errors ?

Inspiring
May 29, 2013

Make sure you use the right type of complete event.

you wrote:

(Event.COMPLETE, instancecomplete);

where it should say

(VideoEvent.COMPLETE, instancecomplete);

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/video/FLVPlayback.html#event:complete