Hej Alle,

Jeg sidder med et projekt hvor vi skal have nogle flash annoncer på et site. Annoncerne er delt op i 3 flash filer, men skal fungere som en.

se eks. http://adalberth.dk/sandbox/jacob/lcflash/

Jeg har brugt Local Connection, og det jeg gør er, at den ene flash afventer på signal fra de andre, og når de så alle er klar til at blive afspillet, sender jeg et signal ud med at de alle kan afspille..

se kode fra hovedfil.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import flash.net.LocalConnection;
import fl.video.*
import flash.events.Event;
 
 
var masterConnection01:LocalConnection = new LocalConnection()
masterConnection01.connect("MASTER_CONNECTION_1");
masterConnection01.client = this;
masterConnection01.allowDomain('*');
 
var masterConnection02:LocalConnection = new LocalConnection()
masterConnection02.connect("MASTER_CONNECTION_2");
masterConnection02.client = this;
masterConnection02.allowDomain('*');
 
var childConnection01:LocalConnection = new LocalConnection();
var childConnection02:LocalConnection = new LocalConnection();
 
var counter:uint = 0;
 
video.source = "vid/fuel_mid.flv";
video.addEventListener(VideoEvent.READY, isAllReady);
 
function isAllReady(e:VideoEvent = null):void{
  counter++
  if(counter == 3){
    video.play();
    childConnection01.send("CHILD_CONNECTION_1","startVideo");
    childConnection02.send("CHILD_CONNECTION_2","startVideo");
    counter = 0;
  }
}
 
video.autoRewind = true;
video.addEventListener(Event.COMPLETE, restartVideo);
function restartVideo(e:Event):void{
  //video.play(); 
  isAllReady();
}

kode fra "underfil".

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import flash.net.LocalConnection;
import fl.video.*;
import flash.net.*;
 
var chConnect:String = "CHILD_CONNECTION_1";
var maConnect:String = "MASTER_CONNECTION_1";
 
var childConnection:LocalConnection = new LocalConnection()
childConnection.connect(chConnect);
childConnection.client = this;
childConnection.allowDomain('*');
 
var masterConnection:LocalConnection = new LocalConnection()
 
function videoReady(e:VideoEvent):void{
  masterConnection.send(maConnect,"isAllReady");
}
 
function startVideo():void{
  video.play();
}
 
video.source = "vid/fuel_left.flv";
video.addEventListener(VideoEvent.READY, videoReady);
 
video.autoRewind = true;
video.addEventListener(Event.COMPLETE, restartVideo);
function restartVideo(e:Event):void{
  //video.play(); 
  masterConnection.send(maConnect,"isAllReady");
}

Jeg bruger flv componentet til at afspille filerne. Og hver gang filerne er færdig med at afspille, tjekker jeg om de alle er klar, og afspiller dem igen.

Men mit problem er, at der altid er en af dem der er usynkron. Og det skifter lidt, og jeg kan ikke finde noget mønster.

Er der nogen der har en løsning til hvordan jeg for dem totalt synkront?

(Ps. jeg har osse prøvet med unix timestamp, hvor man for dem til at afspille efter en local tid på severen)

Mvh David