PDA

Volledige versie bekijken : RemoveChild werkt niet


Krielkip
%Europe/Berlin %669 %2010, 17:04
Hallo mensen,

Ik zit met een probleem en dit moet met spoed verholpen zijn.
Ik wil graag een stuk in mijn flash verwijderen. Echter negeert hij het.

Het scriptje:

public function runWait () : void{
Denken.visible = true;
var v:simpleFlvWait = new simpleFlvWait();
v.playMyFlv('include/wait.flv', true, whichsound);
v.addEventListener("LOOKFORLOOP", LoppyLot);

Denken.addChild(v);

}

private function LoppyLot(e :Event) : void {

trace ( "Bij controle: De button is ingedrukt: " + btn_pressed );

if ( btn_pressed == true ) {
trace ( "De button is ingedrukt: " + btn_pressed + " en gevonden" );

Denken.removeChild(e.target as simpleFlvWait);
trace ( "RemoveChild hier." );

trace ( "De button was: " + btn_pressed );
btn_pressed = false;
trace ( "De button is nu: " + btn_pressed );
}

Het bestand simpleFlvWait:
package nl.avans.cmd.game {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.text.TextFieldAutoSize;
import flash.text.TextField;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.events.NetStatusEvent;
import flash.utils.Timer;

public class simpleFlvWait extends Sprite{
private var _video:Video;
private var _stream:NetStream;
private var _playbackTime:TextField;
private var _duration:uint;
private var _timer:Timer;
private var _loop:Boolean = false;
private var _file:String;
private var _soundnumber: uint;

public function simpleFlvWait(){
_duration = 0;

_playbackTime = new TextField();
_playbackTime.autoSize = TextFieldAutoSize.LEFT;
_playbackTime.y = 20;
_playbackTime.x = 20;
_playbackTime.text = "Buffering …";

_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, onTimer);
_timer.start();
}

public function playMyFlv(flvUrl:String, loop:Boolean, soundint: uint = 0) : void {
_video = new Video();

if (soundint > 0 ) {
_soundnumber = soundint;
}

_loop = loop;

_file = flvUrl;

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

_stream = new NetStream(connection);
_stream.play(flvUrl);


var Client:Object = new Object();
Client.onMetaData = onMetaData;
_stream.client = Client;
_video.attachNetStream(_stream);

_stream.addEventListener(NetStatusEvent.NET_STATUS , onNetStatus);

addChild(_video);
addChild(_playbackTime);
}

private function onMetaData(data:Object) : void {
_duration = data.duration;
}

private function onNetStatus(e:NetStatusEvent) : void{
//_video.width = _video.videoWidth;
//_video.height = _video.videoHeight;
_video.width = 720;
_video.height = 576;
var info: Object = e.info;

if ( _loop == true ) {
trace (' Still looping: ' + _soundnumber );
dispatchEvent(new Event("LOOKFORLOOP"));
}
if(info.code == "NetStream.Play.Stop"){
//next movie
if ( _loop == false )
{
// no loop
trace("End movie: " + _file);
dispatchEvent(new Event("NEXTMOVIE"));
}
else {
trace ('loop the movie: ' + _soundnumber);


removeChild(_video);
removeChild(_playbackTime);
playMyFlv(_file, true);
}
}
if(info.code == "NetStream.Play.Start"){
trace("START: " + _file);
}

// for(var i: * in info){
// trace(i);
// trace(info[i]);
// }

}

private function onTimer(t:TimerEvent) :void{
if( _duration > 0 && _stream.time > 0 ){
_playbackTime.text = Math.round(_stream.time) + " / " + Math.round(_duration);
}

}

public function destroy () : void {
parent.removeChild(this);
}
}
}
Hij laad het scriptje goed.
Hij roept runWait aan, waardoor het loop filmpje begint te lopen.
Als het filmpje naar het einde komt, dan wordt het opnieuw ingeladen.

Wanneer je op een knop drukt, wordt btn_pressed (die altijd false was) true.
Bij true moet hij het filmpje afkappen en zet hij het weer op false.
De knoppen reageren en gooien een nieuwe film in.
Echter het keuze filmpje verdwijnt niet en blijft op de achtergrond loopen.
Ik weet niet wat er mis is. Jullie misschien.

De trace:
START: include/wait.flv
Still looping: 0
Bij controle: De button is ingedrukt: false
De button is ingedrukt: true
START: include/1-goed.flv
Still looping: 0
Bij controle: De button is ingedrukt: true
De button is ingedrukt: true en gevonden
RemoveChild hier.
De button was: true
De button is nu: false
Still looping: 0
Bij controle: De button is ingedrukt: false

Zoals je ziet zegt hij nog steeds still looping na verwijderen. Hij draait ook door.

Dauntless
%Europe/Berlin %679 %2010, 17:18
Het is niet omdat je de movie verwijdert van de DisplayList (en dus niet meer zichtbaar is), dat hij stopt met spelen. Je moet de movie zelf ook nog echt stoppen.

Maak in je classe een methode stop() aan die de Video/Netstream stopt en roep die op na de removeChild.

Krielkip
%Europe/Berlin %684 %2010, 17:25
Als ik v.destroy wil aanroepen, kan hij mijn ingeladen spullen niet vinden.

Moet het dan zijn:

Denken.stop(e.target as simpleFlvWait );

Dauntless
%Europe/Berlin %687 %2010, 17:30
Destroy verwijdert hem enkel van de DisplayList waardoor hij onzichtbaar is, maar hij loopt nog steeds. Je moet echt expliciet _stream.close oproepen.

Krielkip
%Europe/Berlin %529 %2010, 13:42
Thanks iedergeval.
Maar ik hoef nu niet meer de film verwijderen, want het komt 9x terug en dus kan het op de achtergrond doorgaan.

Alleen nu krijg ik het volgende probleem.
Het eerste filmpje na de keuze laad goed:
http://www.krielkip.nl/flash/
maar daarna skipt hij elke filmpje. hoe komt dit?

Bron code:
(GAME.AS)
package nl.avans.cmd.game {
import nl.avans.cmd.CMDBase;

import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.text.TextField;
import flash.utils.Timer;
import flash.utils.setTimeout;
import flash.events.*;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.events.NetStatusEvent;
import flash.media.*;
import flash.media.Video;
import flash.net.URLRequest;
import flash.net.NetConnection;
import flash.net.NetStream;


/**
* Simple quiz example.
* Features
* arrays, conditional statements, mouse interaction,
* functions with parameters, a Question object,
* text input and text output, manipulating of visibility of movieclips, holding state in this class and some TODO's for practicing
* @author rolf
*/
public class Game extends CMDBase {

/**
* public var declaration of stage instances
*/

// Do the buttons (WHOEOEOE)
public var Start_btn : SimpleButton;

public var knop1_btn : SimpleButton;
public var knop2_btn : SimpleButton;
public var knop3_btn : SimpleButton;

/*
public var btn1 : Btn_style;
public var btn2 : Btn_style;
public var btn3 : Btn_style;

*
*/
public var btn_pressed : Boolean = false;

// En wat anders
private var timer : Timer;
private var timedone : int = 0;
private var onestart : Boolean = false;

private var Inround : int;
private var score : uint;

public var Rules_mc : MovieClip;

// Sound
private var urlSound : String = "testsound.mp3";
private var snd : Sound = new Sound();
private var channel : SoundChannel;

//holds the movies instances
private var Goedevragen : Array;
private var Foutevragen : Array;
private var Tussenvragen : Array;

private var _SoundCacheGood:Array = new Array();
private var _SoundCacheBad:Array = new Array();
private var _SoundCacheTussen:Array = new Array();

private var playing :String ;

var vid:Video = new Video();

//var v:simpleFlv = new simpleFlv();

// Video toch?


// -----------------------------------
//holds the question instances
private var questions : Array;//questions[0], questions[questions.length - 1 ] = 5476

//which question are we asking?
private var whichsound : int = 0;

//how many correct answers
private var correctAnswers : int = 0;

//time in milliseconds between questions
private const ROUND_TIME : int = 3000;
public var Denken : MovieClip;
// public var myPreloader : MovieClip;
public var preloader : MovieClip;
public var Begin_btn : SimpleButton;
public var waitforit : Boolean;

public var WaitWhat : Array;
private var MadeWaitWhat : Boolean;



/**
* constructor, sets up what we are doing for this lesson
*/
public function Game() {
trace("start.Game()");
setUpVisuals();
createGood();
createBad();
createBetween();
createHandlers();
startFlash();
//startQuiz();
}

/**
* sets up visuals
*/
private function setUpVisuals() : void {
Start_btn.visible = false;
Rules_mc.visible = false;

knop1_btn.visible = false;
knop2_btn.visible = false;
knop3_btn.visible = false;


}

private function startFlash () : void {
// addEventListener(Event.ENTER_FRAME, onTick);
// timer = new Timer(30);
// timer.addEventListener(TimerEvent.TIMER, onTick);
// timer.start();

Denken.visible = false;

// preloader.addEventListener ( Event.COMPLETE , completeHandler );
// preloader.source = this.root.loaderInfo;



// Run intro movie:
//dointro();
}

// function completeHandler ( e:Event ) :void
// {
// trace ('Complete');
// //nextFrame ();
// }
//

/**
* start the quiz
*/
private function startQuiz() : void {
nextq();
}

public function doneclick ( which : String ) {
trace ( 'got this: ' + String);

}


/**
* event handlers are created here
*/
private function createHandlers() : void {
Start_btn.addEventListener(MouseEvent.CLICK, onStart);
Begin_btn.addEventListener(MouseEvent.CLICK, dointro);

knop1_btn.addEventListener(MouseEvent.MOUSE_OVER, over1);
knop2_btn.addEventListener(MouseEvent.MOUSE_OVER, over2);
knop3_btn.addEventListener(MouseEvent.MOUSE_OVER, over3);

knop1_btn.addEventListener(MouseEvent.MOUSE_OUT, outofknop);
knop2_btn.addEventListener(MouseEvent.MOUSE_OUT, outofknop);
knop3_btn.addEventListener(MouseEvent.MOUSE_OUT, outofknop);


knop1_btn.addEventListener(MouseEvent.CLICK, on1);
knop2_btn.addEventListener(MouseEvent.CLICK, on2);
knop3_btn.addEventListener(MouseEvent.CLICK, on3);
//TODO, group other handlers here for the button that makes it possible to start over again
}

private function nextq () {
btn_pressed = false;

runWait ();

knop1_btn.visible = true;
knop2_btn.visible = true;
knop3_btn.visible = true;

// btn1.make_btn ( 100, 200, 10, 0);

}

private function WeAreDone () {

}


// To do: maak deze knoppen in een willekeurige volorde!
private function over1 (event:MouseEvent): void {
playSoundGood(whichsound);
}
private function over2 (event:MouseEvent): void {
playSoundTussen(whichsound);
}
private function over3 (event:MouseEvent): void {
playSoundBad(whichsound);
}

//private function on1 (event : MouseEvent) : void {
private function on1 (event : MouseEvent) : void {
score += 3;
mouseclick ( 'knop1');

}
private function on2(event : MouseEvent) : void {
score += 2;
mouseclick ( 'knop2');

}
private function on3(event : MouseEvent) : void {
score += 1;
mouseclick ( 'knop3');

}

private function mouseclick ( what : String):void {
// var monster : simpleFlv;
// monster = WaitWhat[whichsound] as simpleFlv;
// monster.destroy();
btn_pressed = true;
trace ( "De button is ingedrukt: " + btn_pressed );
waitforit = false;
knop1_btn.visible = false;
knop2_btn.visible = false;
knop3_btn.visible = false;
var answerthis : String;

if ( what == 'knop1' )
{
var goodone : goedmovies = Goedevragen[whichsound] as goedmovies;
answerthis = goodone.getMovie ();
}
else if ( what == 'knop2' )
{
var tussenone : neutraalmovies = Tussenvragen[whichsound] as neutraalmovies;
answerthis = tussenone.getMovie ();
}
else if ( what == 'knop3' )
{
var foutone : foutmovies = Foutevragen[whichsound] as foutmovies;
answerthis = foutone.getMovie ();
}

loadfilm ( answerthis );
}


private function onStart(event : MouseEvent) : void {
startQuiz();
Start_btn.visible = false;
Rules_mc.visible = false;
}

private function outofknop (event:MouseEvent): void {
channel.stop();
trace ("Stop sound channel");
}

public function loadAudioGood(requestUrl:String):int {

var req:URLRequest = new URLRequest(requestUrl);
var snd:Sound = new Sound();
snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

try {
snd.load(req);

//snd.play();
}
catch (err:Error) {
trace(err.message);
return -1;
}


this._SoundCacheGood.push(snd);

return this._SoundCacheGood.length-1;

}

public function loadAudioBad(requestUrl:String):int {

var req:URLRequest = new URLRequest(requestUrl);
var snd:Sound = new Sound();
snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

try {
snd.load(req);

//snd.play();
}
catch (err:Error) {
trace(err.message);
return -1;
}


this._SoundCacheBad.push(snd);

return this._SoundCacheBad.length-1;

}

public function loadAudioTussen(requestUrl:String):int {

var req:URLRequest = new URLRequest(requestUrl);
var snd:Sound = new Sound();
snd.addEventListener(IOErrorEvent.IO_ERROR, errorHandler);

try {
snd.load(req);

//snd.play();
}
catch (err:Error) {
trace(err.message);
return -1;
}


this._SoundCacheTussen.push(snd);

return this._SoundCacheTussen.length-1;

}

public function playSoundGood(id:int):void {
channel = this._SoundCacheGood[id].play();
playing = "good";
}
public function playSoundBad(id:int):void {
channel = this._SoundCacheBad[id].play();
playing = "bad";
}
public function playSoundTussen(id:int):void {
channel = this._SoundCacheTussen[id].play();
playing = "tussen";
}


private function errorHandler(errorEvent:IOErrorEvent):void {
trace("The sound could not be loaded: " + errorEvent.text);
}

// FROM HERE WE DO MOVIES =D
function asyncErrorHandler(event:AsyncErrorEvent):void
{
// ignore error
trace("The film could not be loaded: " + event.text);
}

public function loadfilm ( film:String) :void {
trace (score);

var v:simpleFlv = new simpleFlv();
v.playMyFlv(film, false);
v.addEventListener("NEXTMOVIE", onNextMovie);
addChild(v);
}

public function dointro (event : MouseEvent) : void {


var v:simpleFlv = new simpleFlv();

preloader.visible = false;
Begin_btn.visible = false;

v.playMyFlv('include/intro.flv', false);
v.addEventListener("NEXTMOVIE", onStartThaMovie);
addChild(v);
}

public function runWait () : void{
if ( whichsound < 1 ) {
Denken.visible = true;
var v:simpleFlv = new simpleFlv();
v.playMyFlv('include/wait.flv', true, whichsound);
v.addEventListener("LOOKFORLOOP", LoppyLot);
// // waitforit = true;

// if (MadeWaitWhat == false){
// MadeWaitWhat = true;
// WaitWhat = new Array ();
// }

//WaitWhat.push(v);
Denken.addChild(v);
}
}

private function LoppyLot(e :Event) : void {

trace ( "Bij controle: De button is ingedrukt: " + btn_pressed );

if ( btn_pressed == true ) {
trace ( "De button is ingedrukt: " + btn_pressed + " en gevonden" );

//Denken.removeChild(e.target as simpleFlvWait);
//Denken.close();
// trace ( "RemoveChild hier." );

trace ( "De button was: " + btn_pressed );
btn_pressed = false;
trace ( "De button is nu: " + btn_pressed );
}

// removeChild ( Denken );
// trace ( v );
}

// private function CheckLoopStillNeeded (e: Event) : void {
// if (waitforit == false ) {
// removeChild(e.target as simpleFlv);
// }
// }

private function onNextMovie(e: Event) : void {
removeChild(e.target as simpleFlv);

whichsound = whichsound + 1;
trace ( 'Ronde: ' + (whichsound+1) );
nextq ( );
/*
trace("testing onNextMovie");
var v:simpleFlv = new simpleFlv();
v.playMyFlv('include/intro.flv');
v.addEventListener("NEXTMOVIE", onNextMovie);
addChild(v);
*
*/
}

private function onStartThaMovie(e: Event) : void {
trace ( e );
// trace ( v );
removeChild(e.target as simpleFlv);
showRules ();
}

private function showRules() : void {
Start_btn.visible = true;
Rules_mc.visible = true;
}


/**
* define antwoorden hier
*/
private function createGood() : void {
//create the array that holds all antwoord objects
Goedevragen = new Array();
//declare the antwoord variable
var Goedantwoord : goedmovies;

//create a new antwoord
Goedantwoord = new goedmovies("include/1-goed.flv", "include/1-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);

//create a new antwoord
Goedantwoord = new goedmovies("include/2-goed.flv", "include/2-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);

//create a new antwoord
Goedantwoord = new goedmovies("include/3-goed.flv", "include/3-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);

//create a new antwoord
Goedantwoord = new goedmovies("include/4-goed.flv", "include/4-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);

//create a new antwoord
Goedantwoord = new goedmovies("include/5-goed.flv", "include/5-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);


//create a new antwoord
Goedantwoord = new goedmovies("include/6-goed.flv", "include/6-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);


//create a new antwoord
Goedantwoord = new goedmovies("include/7-goed.flv", "include/7-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);


//create a new antwoord
Goedantwoord = new goedmovies("include/8-goed.flv", "include/8-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);

//create a new antwoord
Goedantwoord = new goedmovies("include/9-goed.flv", "include/9-goed.mp3");
//add to the antwoord array
Goedevragen.push(Goedantwoord);



loadAudioGood( "include/1-goed.mp3");
loadAudioGood( "include/2-goed.mp3");
loadAudioGood( "include/3-goed.mp3");
loadAudioGood( "include/4-goed.mp3");
loadAudioGood( "include/5-goed.mp3");
loadAudioGood( "include/6-goed.mp3");
loadAudioGood( "include/7-goed.mp3");
loadAudioGood( "include/8-goed.mp3");
loadAudioGood( "include/9-goed.mp3");
//questions.reverse();


}

private function createBad() : void {
//create the array that holds all antwoord objects
Foutevragen = new Array();
//declare the antwoord variable
var Foutantwoord : foutmovies;

//create a new antwoord
Foutantwoord = new foutmovies("include/1-fout.flv", "include/1-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/2-fout.flv", "include/2-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/3-fout.flv", "include/3-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/4-fout.flv", "include/4-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/5-fout.flv", "include/5-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/6-fout.flv", "include/6-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/7-fout.flv", "include/7-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/8-fout.flv", "include/8-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

//create a new antwoord
Foutantwoord = new foutmovies("include/9-fout.flv", "include/9-fout.mp3");
//add to the antwoord array
Foutevragen.push(Foutantwoord);

loadAudioBad( "include/1-fout.mp3");
loadAudioBad( "include/2-fout.mp3");
loadAudioBad( "include/3-fout.mp3");
loadAudioBad( "include/4-fout.mp3");
loadAudioBad( "include/5-fout.mp3");
loadAudioBad( "include/6-fout.mp3");
loadAudioBad( "include/7-fout.mp3");
loadAudioBad( "include/8-fout.mp3");
loadAudioBad( "include/9-fout.mp3");

//questions.reverse();
}

private function createBetween() : void {
//create the array that holds all antwoord objects
Tussenvragen = new Array();
//declare the antwoord variable
var Tussenantwoord : neutraalmovies;

//create a new antwoord
Tussenantwoord = new neutraalmovies ("include/1-neutral.flv", "include/1-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/2-neutral.flv", "include/2-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/3-neutral.flv", "include/3-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/4-neutral.flv", "include/4-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/5-neutral.flv", "include/5-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/6-neutral.flv", "include/6-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/7-neutral.flv", "include/7-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/8-neutral.flv", "include/8-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

//create a new antwoord
Tussenantwoord = new neutraalmovies("include/9-neutral.flv", "include/9-neutral.mp3");
//add to the antwoord array
Tussenvragen.push(Tussenantwoord);

loadAudioTussen( "include/1-neutral.mp3");
loadAudioTussen( "include/2-neutral.mp3");
loadAudioTussen( "include/3-neutral.mp3");
loadAudioTussen( "include/4-neutral.mp3");
loadAudioTussen( "include/5-neutral.mp3");
loadAudioTussen( "include/6-neutral.mp3");
loadAudioTussen( "include/7-neutral.mp3");
loadAudioTussen( "include/8-neutral.mp3");
loadAudioTussen( "include/9-neutral.mp3");

//questions.reverse();
}

}
}


SimpleFlv.AS
package nl.avans.cmd.game {
import flash.display.Sprite;
import flash.net.NetConnection;
import flash.net.NetStream;
import flash.media.Video;
import flash.text.TextFieldAutoSize;
import flash.text.TextField;
import flash.events.Event;
import flash.events.TimerEvent;
import flash.events.NetStatusEvent;
import flash.utils.Timer;

public class simpleFlv extends Sprite{
private var _video:Video;
private var _stream:NetStream;
private var _playbackTime:TextField;
private var _duration:uint;
private var _timer:Timer;
private var _loop:Boolean = false;
private var _rollit:Boolean = false;
private var _file:String;
private var _soundnumber: uint;

public function simpleFlv(){
_duration = 0;

_playbackTime = new TextField();
_playbackTime.autoSize = TextFieldAutoSize.LEFT;
_playbackTime.y = 20;
_playbackTime.x = 20;
_playbackTime.text = "Buffering …";

_timer = new Timer(1000);
_timer.addEventListener(TimerEvent.TIMER, onTimer);
_timer.start();
}

public function playMyFlv(flvUrl:String, loop:Boolean, soundint: uint = 0) : void {
_video = new Video();

if (soundint > 0 ) {
_soundnumber = soundint;
}

_loop = loop;

_file = flvUrl;

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

_stream = new NetStream(connection);
_stream.play(flvUrl);


var Client:Object = new Object();
Client.onMetaData = onMetaData;
_stream.client = Client;
_video.attachNetStream(_stream);

_stream.addEventListener(NetStatusEvent.NET_STATUS , onNetStatus);

addChild(_video);
addChild(_playbackTime);
}

private function onMetaData(data:Object) : void {
_duration = data.duration;
}

private function onNetStatus(e:NetStatusEvent) : void{
//_video.width = _video.videoWidth;
//_video.height = _video.videoHeight;
_video.width = 720;
_video.height = 576;
var info: Object = e.info;

if ( _loop == true ) {
trace (' Still looping: ' + _soundnumber );
dispatchEvent(new Event("LOOKFORLOOP"));
}
if(info.code == "NetStream.Play.Stop"){
if (_rollit == true ) {
//next movie
if ( _loop == false )
{
// no loop
trace("End movie: " + _file);
_stream.close ();
dispatchEvent(new Event("NEXTMOVIE"));
}
else {
trace ('loop the movie: ' + _soundnumber);

_stream.close ();
removeChild(_video);
removeChild(_playbackTime);
playMyFlv(_file, true);
}
}
}
if(info.code == "NetStream.Play.Start"){
trace("START: " + _file);
_rollit = true;
}

// for(var i: * in info){
// trace(i);
// trace(info[i]);
// }

}

private function onTimer(t:TimerEvent) :void{
if( _duration > 0 && _stream.time > 0 ){
_playbackTime.text = Math.round(_stream.time) + " / " + Math.round(_duration);
}

// if ( _loop == true ) {
// trace ('loop!');
//
// dispatchEvent(new Event("CHECKEND"));
// }
}

public function destroy () : void {
parent.removeChild(this);
}
}
}

Jan
%Europe/Berlin %898 %2010, 22:34
Het eerste filmpje na de keuze laad goed.
maar daarna skipt hij elke filmpje.
hoe komt dit?
Toon het relevante gedeelte van je code ook even. Het script dat je plaatst is bijna 1000 lijnen lang. Weinigen zullen tijd hebben om dat helemaal te gaan uitpluizen.
Van al je traces zie ik enkel

loop the movie: 0
START: include/wait.flv
loop the movie: 0
START: include/wait.flv
loop the movie: 0
START: include/wait.flv
loop the movie: 0
START: include/wait.flv
loop the movie: 0
START: include/wait.flv

In liveHTTPHeader zie ik je die wait.flv voortdurend laden, tientallen keren achter elkaar. Dus zou ik daar alvast als eerste naar kijken want je geraakt blijkbaar niet uit die herhaling.

Jan