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

Stop video embedded into swf that is displayed into loader when clicking next and previous

New Here ,
May 04, 2016 May 04, 2016

I am having a problem with embedded flv

I am having a main page with Next and Previous buttons, I am loading swf into this main page using addchild(loader), this swf contains flv embedded into it

The next and previous code contains the following code to remove child before adding the new child

SoundMixer.stopAll();
if(loader != null)
{
if(stage.contains(loader))
{
removeChild(loader);
}
loader.unloadAndStop();
loader = null;
}
fnLoadNext();

The problem appears when I am quickly clicking on Next or Previous Buttons, One of the old videos still working with the new one (If I click 10 times quickly on next button, video interference occurs)

Any advice for that?

TOPICS
ActionScript
527
Translate
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
Community Expert ,
May 04, 2016 May 04, 2016

insert a frame loop delay between your unloadAndStop and the start of the next video.

Translate
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

What do you mean?

Please clarify

Translate
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
Community Expert ,
May 04, 2016 May 04, 2016

use:

SoundMixer.stopAll();
if(loader != null)
{
if(stage.contains(loader))
{
removeChild(loader);
}
loader.unloadAndStop();

loader = null;

this.addEventListener(Event.ENTER_FRAME,delayF);

}

function delayF(e:Event):void{

fnLoadNext();

this.removeEventListener(Event.ENTER_FRAME,delayF);

}

Translate
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

Nothing happened; the same problem exists. Two different videos are still playing together when I am quickly clicking on next button, again, the problem happens only when I am clicking very fast on the Next button (10 clicks per a second) but if I am clicking in normal way, no problem occurs

Any idea?

Translate
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
Community Expert ,
May 04, 2016 May 04, 2016

did you add similar code every place/frame where you leave a frame with a loader?

Translate
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

Yes and I don't know what is wrong

The problem is that one old video still in background and is not killed

Isn't there any function kills all videos? such as SoundMixer.stopAll(); that kills are working sound?

Here is my full code

loadNextCharacter.addEventListener(MouseEvent.MOUSE_UP, loadNext);

function loadNext(e:MouseEvent):void

{

  SoundMixer.stopAll();

  if(loader != null)

  {

  if(stage.contains(loader))

  {

  removeChild(loader);

  }

  loader.unloadAndStop();

  loader = null;

  this.addEventListener(Event.ENTER_FRAME,delayF);

  }

}

function delayF(e:Event):void

{

  fnLoadNext();

  this.removeEventListener(Event.ENTER_FRAME,delayF);

}

function fnLoadNext():void

{

  currentPage = currentPage + 1;

  if(currentPage <= letters.length - 1)

  {

  loadPreviousCharacter.visible = true;

  loadNextCharacter.visible = true;

  if(currentPage == letters.length - 1)

  {

  loadNextCharacter.visible = false;

  }

  loader = new Loader();

  loader.x=0;

  loader.y=0;

  loader.load(new URLRequest("Letters/" + letters[currentPage] + ".swf"));

  addChild(loader);

  }

}

Translate
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
Community Expert ,
May 06, 2016 May 06, 2016

i don't see any problem with rapid clicking of b where load1 and load2 each have flv's embedded in their timelines:

var loader:Loader = new Loader();

var counter:int = 0;

b.addEventListener(MouseEvent.CLICK,f);

function f(e:MouseEvent):void{

    if(loader.content){

        loader.unloadAndStop();

    }

    if(counter%2==0){

        loader.load(new URLRequest('load1.swf'));

    } else {

        loader.load(new URLRequest('load2.swf'));

    }

    counter++;

}

Translate
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 06, 2016 May 06, 2016

What do you mean by this code?

Actually I am using MouseEvent.MOUSE_UP not MouseEvent.CLICK, can this be the problem? I don't think so. I feel that as it is not native, so that it is slow somehow

Translate
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
Community Expert ,
May 06, 2016 May 06, 2016

the mouse event is not the problem.

Translate
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 07, 2016 May 07, 2016

But the problem still exists and the video sound still working at the same time from more than one swf

Translate
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
Community Expert ,
May 07, 2016 May 07, 2016

you have some problem not explained in this thread.  ie, rapidly loading swfs that contain embedded flvs does not cause a problem when using code similar to the code i used in message 7.

Translate
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 13, 2016 May 13, 2016
LATEST

I found a work arround

I solved it by making the following:

1- Make Next and Prev. visibility = false

2- adding EventListener to loader (Event.COMPLETE) and make them visible when this event fires

Translate
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