Soundobjekt Panoramasteuerung

intercorni

Erfahrenes Mitglied
Hallo,

ich möchte das Panorama eines Soundobjektes dynamisch per AS steuern.
Dazu erzeuge ich ein Soundobjekt und steuere es wie folgt an:

PHP:
//Soundobjekt
//Panning Variablen
var panorama = 100;
var speed = 5;
this.createEmptyMovieClip("carsoundobjekt",1) 
var front_sound:Sound = new Sound (this.carsoundobjekt);  
front_sound.attachSound("carsound");  
front_sound.stop();  
front_sound.setVolume(90); 
front_sound.setPan (panorama);
function soundPan(){ 
var panorama = 100;
front_sound.start();  
	//Panning definieren
    this.onEnterFrame = function () {  
    panorama > -100 ? panorama -= speed : delete this.onEnterFrame;  
    front_sound.setPan (panorama);
	
	
    } 
} 

this.stop();

Nun habe ich eine Panoramaregelung von Rechts nach Links. Wie erreiche ich es, dass das Panorama wieder nach Rechts geregelt wird, also: Rechts - Links - Rechts?

Danke,

Cornel
 
Hi,

ungetestet:
Code:
soundPan(100, 5, 3);

function soundPan(base, speed, amt){
    var cnt = 0;
    front_sound.start();
    front_sound.setPan(base);
    var speed = (base > 0)? -Math.abs(speed) : Math.abs(speed);
    this.onEnterFrame = function () {  
        front_sound.setPan(front_sound.getPan() + speed);
        if (Math.abs(front_sound.getPan()) >= 100) {
            cnt ++;
            if (cnt >= amt) delete this.onEnterFrame;
            speed = -speed;
        }
    } 
}
base ist das Startpanorama, speed die Geschwindigkeit und amt die Anzahl der Durchläufe (bei links - rechts - links wäre es z.B. 3).

Gruß
.
 

Neue Beiträge

Zurück