Zurück   Flashforum > Flash > ActionScript > ActionScript 1

Antwort
 
LinkBack Themen-Optionen Ansicht
Alt 13-03-2005, 17:54   #1 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
Unhappy soundsteuerung mit einem mc

ich lade einen sound, lasse ihn per stream abspielen;

dann gibt es da einen mc, der mit einem dynamischem textfeld bestückt ist;
dieser soll bei onPress erstmal den sound stoppen, das textfeld ändern , beim nächsten onPress wieder starten und das textfeld ändern, and so on, and so on......

i kriegs net hin.......

ActionScript:
  1. var bgSound = new Sound();
  2. bgSound.loadSound("backgroundsound.mp3");
  3. bgSound.onLoad = function(true) {
  4.     bgSound.start(0, 50);
  5. };
  6.  
  7. //ein wenig später dann
  8. var checker;
  9. MC_soundregler.T_soundregler.autoSize = "center";
  10. MC_soundregler.T_soundregler.text = "sound off";
  11. MC_soundregler.onPress = function() {
  12.     if (checker=false) {
  13.         bgSound.start(0, 50);
  14.         MC_soundregler.T_soundregler.text = "sound off";
  15.         checker = true;
  16.     }
  17.    
  18.     if (checker=true) {
  19.         bgSound.stop();
  20.         MC_soundregler.T_soundregler.text = "sound on";
  21.         checker = false;
  22.     }
  23. };
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary
andretti ist offline   Mit Zitat antworten
Alt 13-03-2005, 18:16   #2 (permalink)
mod_rewrite
 
Benutzerbild von sonar
 
Registriert seit: Feb 2003
Ort: München
Beiträge: 15.621
1. is das so kein Streaming-Sound (--> Flashhilfe lesen)
2. schreibt man Vergleiche so:
ActionScript:
  1. if(checker == true) {...}
3. reicht dann eigentlich auch ein else, wenn das Gegenteil geprüft werden soll
4. würde ich checker am Anfang richtig initialisieren
ActionScript:
  1. var checker = true;
...und vielleicht auch etwas schlauer benennen - "isPlaying" oder so... dann weißt nämlich auch später noch, was gemeint is
__________________
RTFM
Wie man Fragen richtig stellt.

Achim Bindannmalweg

Money makes the world go round, fear makes it turn much faster.
(New Model Army)

Geändert von sonar (13-03-2005 um 18:17 Uhr)
sonar ist offline   Mit Zitat antworten
Alt 13-03-2005, 18:52   #3 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
Thumbs up

aloha !

1. hast recht, habe mich vertan; da ich ja onLoad verwende...ist der nimmer streaming....oder?

2. warum bin i so schlampig? grrrrrrrr

3. diese version mit else hatt ich auch, aber eben mit falscher intialisierung und einem "=" zu wenig.....

4. aha...danke

...das mit dem benennen ist eine subjektive sache- ich habe immer überschriften....zb:
ActionScript:
  1. ///***CLICKSOUND BG-SOUND***///
  2. var clicker = new Sound();
  3. clicker.attachSound("click");
  4. var bgSound = new Sound();
  5. bgSound.loadSound("backgroundsound.mp3");
  6. bgSound.onLoad = function(true) {
  7.     bgSound.start(0, 50);
  8. };
  9. var isPlaying = true;
  10. MC_soundregler.T_soundregler.autoSize = "center";
  11. MC_soundregler.T_soundregler.text = "sound off";
  12. MC_soundregler.onPress = function() {
  13.     if (isPlaying == true) {
  14.         bgSound.stop();
  15.         MC_soundregler.T_soundregler.text = "sound on";
  16.         isPlaying = false;
  17.     } else {
  18.         MC_soundregler.T_soundregler.text = "sound off";
  19.         bgSound.start(0, 50);
  20.         isPlaying = true;
  21.     }
  22. };
  23. //**HEADER**//
  24. _root.attachMovie("header_rahmen", "header_rahmen", 50);
  25. header_rahmen._x = 384;
  26. header_rahmen._y = 11;
  27. var tl = this;
  28. var fadespeed = 8;
  29. var bildanzahl = 2;
  30. _global.old_conti;
  31. _global.ct = 1;
  32. function reload_x() {
  33.     clearInterval(SID);
  34.     tl.createEmptyMovieClip("container"+ct, ct+10);
  35.     tl["container"+ct]._x = 385;
  36.     tl["container"+ct]._y = 12;
  37.     tl["container"+ct].loadMovie("images/header"+ct+".jpg");
  38.     tl["container"+ct]._alpha = 0;
  39.     this.loader_funk = function() {
  40.         if (tl["container"+ct].getBytesLoaded()>=4) {
  41.             gesamt = tl["container"+ct].getBytesTotal();
  42.             bereits = tl["container"+ct].getBytesLoaded();
  43.             prozent = Math.ceil((bereits/gesamt)*100);
  44.             if (prozent>=100) {
  45.                 tl["container"+ct]._alpha += fadespeed;
  46.                 old_conti._alpha -= fadespeed;
  47.                 if (tl["container"+ct]._alpha>=100 && old_conti._alpha<=0) {
  48.                     old_conti.unloadMovie();
  49.                     _global.old_conti = tl["container"+ct];
  50.                     clearInterval(loadID);
  51.                     _global.ct++;
  52.                     SID = setInterval(reload_x, 10000);
  53.                 }
  54.                 if (ct == (bildanzahl+1)) {
  55.                     _global.ct = 1;
  56.                 }
  57.             }
  58.         }
  59.     };
  60.     loadID = setInterval(loader_funk, 40);
  61. }
  62. reload_x();
  63. //**UND SO WEITER UND SO WEITER**//
  64.  

...wie du siehst, habe ich aber deinen tipp umgesetzt, ist auch ästhetischer und für eventuelle nachahmer nachvollziehbarer;

5. herzlichen dank !
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary
andretti ist offline   Mit Zitat antworten
Alt 13-03-2005, 21:35   #4 (permalink)
kroate
 
Benutzerbild von xbass
 
Registriert seit: Jan 2003
Ort: Hannover
Beiträge: 360
bgSound.loadSound("backgroundsound.mp3", true); //<<< Streaming-Sound
bgSound.loadSound("backgroundsound.mp3", false); //<<< Ereignis-Sound
__________________
www.fresh-solutions.de
Fresh Flash For All.
xbass ist offline   Mit Zitat antworten
Alt 13-03-2005, 21:49   #5 (permalink)
tracer
 
Benutzerbild von andretti
 
Registriert seit: Jun 2004
Beiträge: 4.415
Zitat:
Zitat von xbass
bgSound.loadSound("backgroundsound.mp3", true); //<<< Streaming-Sound
bgSound.loadSound("backgroundsound.mp3", false); //<<< Ereignis-Sound
danke, nach der kopfwäsche von sonar habe ich eh gleich die hilfe durchforstet;
__________________
Viola per Sempre
Alle Angaben ohne Gewehr!
trace your open mind in variables !
andretti
ActionScript Dictionary
andretti ist offline   Mit Zitat antworten
Antwort

Lesezeichen

Themen-Optionen
Ansicht

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks sind an
Pingbacks sind an
Refbacks sind an



Alle Zeitangaben in WEZ +1. Es ist jetzt 07:21 Uhr.

Domains, Webhosting & Vserver von Host Europe
Unterstützt das Flashforum!
Adobe User Group


Copyright ©1999 – 2012 Marc Thiele