[Flash] Probleem met ActionScript en movie loop

Pagina: 1
Acties:

Acties:
  • 0 Henk 'm!

Verwijderd

Topicstarter
Ha,

Deze middag heb ik mijn eerste babystapjes op het gebied van ActionScript gezet en ik heb mijn doel bijna bereikt. Wat ik wil is simpelweg een geluidje muten als er op een knopje gedrukt wordt en indien er nog een keer gedrukt wordt, moet dit geluidje weer gaan spelen. So far so good.

Nu... als het filmpje is afgelopen, begint deze weer opnieuw en het probleem hierbij is dat de ActionsScript-code die bepaalt of het geluidje moet gaan spelen of niet, ook opnieuw wordt uitgevoerd. Als het geluid dus handmatig is gestopt en het de animatie is op zijn eind, begint het geluid weer te spelen zodra de animatie weer opnieuw begint.

Mijn vraag is of er een manier bestaat om de ActionScript-code op een of andere manier los te koppelen. Onderstaand de betreffende code. All help is welcome :)


Flash ActionScript:
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
40
OceanSound = new Sound(this);
OceanSound.attachSound('oceansound');

// Init code
if (isOceanSoundPlaying()) {
    b_sound_start._visible = false;
    b_sound_stop._visible = true;
    OceanSound.start(0, true);
} else {
    b_sound_start._visible = true;
    b_sound_stop._visible = false;
    OceanSound.stop();
}

// Returnt voorlopig alleen nog 'true'
// Check cookie for sound on/off status
function isOceanSoundPlaying() {

}

// Set the cookie value (on/off)
function setOceanSoundCookie(sSoundStatus) {
    return true;
}

// Manual start sound + cookie set
b_sound_start.onRelease = function() {
    _root.b_sound_start._visible = false;
    _root.b_sound_stop._visible = true;
    OceanSound.start(0, true);
    setOceanSoundCookie('on');
}

// Manual stop sound + cookie set
b_sound_stop.onRelease = function() {
    _root.b_sound_start._visible = true;
    _root.b_sound_stop._visible = false;
    OceanSound.stop();
    setOceanSoundCookie('off');
}

Acties:
  • 0 Henk 'm!

Verwijderd

Je kan het pauseren namaken door de 'position' property te gebruiken van het geluid.
Ik heb dit zelf ontdekt op een filmpje over pauseren en afspelen: video tutorial pausing and resuming sound.html