Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
insert a frame loop delay between your unloadAndStop and the start of the next video.
Copy link to clipboard
Copied
What do you mean?
Please clarify
Copy link to clipboard
Copied
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);
}
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
did you add similar code every place/frame where you leave a frame with a loader?
Copy link to clipboard
Copied
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);
}
}
Copy link to clipboard
Copied
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++;
}
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
the mouse event is not the problem.
Copy link to clipboard
Copied
But the problem still exists and the video sound still working at the same time from more than one swf
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now