Pagina 1 di 3 1 2 3 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 21

Discussione: preload

  1. #1
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929

    preload

    ciao a tutti,

    devo caricare un file mp3 con il preload
    ho fatto cosi, ma sembra non funzionare
    codice:
    // creo un prototype per il preloading
    MovieClip.prototype.preload = function(file) {
        this.onEnterFrame = function() {
    		//_root.createClassObject(mx.controls.ProgressBar, "pBar", 1);
    		pBar._width = 120
    		pBar._visible = true
            car = clip.getBytesLoaded();
            tot = clip.getBytesTotal();
            perc = Math.round((car/tot)*100);
    		pBar.setProgress(car, tot);
    		pBar.label = "LOAD "+perc+"%";
    		pBar.indeterminate = true;
    		pBar._width = 110
            if (car>=tot && tot>24) {
    			pBar._visible = false
                delete this.onEnterFrame;
    			gotoAndPlay(2);
    		}else{
    			trace (perc)
    			stop();
            }
        };
    };
    
    preload("loop_01.mp3");

    dove sbaglio?

    grazie mille

  2. #2
    Utente di HTML.it L'avatar di byaur
    Registrato dal
    Aug 2004
    Messaggi
    1,061
    così a spanne ti direi innanzi tutto, visto che preload è un prototype relativo ad Un MovieClip di chiamare preload su un mc..

    cioè

    _root.tuomc.preload("tuomp3.mp3");

    poi ci sono altre cose da vedere, ma sto tornando a casa a disintossicarmi... da flash naturalemente!!!

    Chi di noi non vorrebbe
    sollevare il velo sotto cui sta nascosto il
    futuro...
    David Hilbert

  3. #3
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    sopratutto il preload di un mp3 esterno non si fa così va fatto sul'oggetto Sound che carica l'mp3 esterno, di cui non c'è traccia di inizializzazione nella proto

    prova con questo, bisogna vedere come va nel tuo caso, ho ricalcato il codice che avevi scritto senza conoscere esattamente la situazione

    codice:
    MovieClip.prototype.loadMP3 = function(file) {
    	var mySound = new Sound(this);
    	mySound.loadSound(file, false);
    	_root.createClassObject(mx.controls.ProgressBar, "pBar", 1);
    	pBar._width = 120
    	pBar._visible = true
    	this.onEnterFrame = function(){
    		mySound.stop();
    		var car = mySound.getBytesLoaded();
    		var tot = mySound.getBytesTotal();
    		var perc = Math.floor((car/tot)*100);
    		if(!isNaN(perc)){
    			pBar.setProgress(car, tot);
    			pBar.label = "LOAD "+perc+"%";
    			pBar.indeterminate = true;
    		}
    		if(car >= tot && tot > perc && perc == 100){
    			mySound.start(0, 1);
    			pBar._visible = false;
    		        delete this.onEnterFrame;
    			gotoAndPlay(2);
    		}
    	}
    }
    myClip.loadMP3("loop_01.mp3");

  4. #4
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    è il primo frame sulla root io vorrei prima caricare il file mp3 e poi avviare il filmato...

    cosi il preload del file mp3 funziona solo che il filmato parte subito...
    codice:
    _root.loadMP3("loop_01.mp3");


  5. #5
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    ok fatto, grazie mille!

    codice:
    MovieClip.prototype.loadMP3 = function(file) {
    	var mySound = new Sound(this);
    	mySound.loadSound(file, false);
    	_root.createClassObject(mx.controls.ProgressBar, "pBar", 1);
    	pBar._width = 120
    	pBar._visible = true
    	this.onEnterFrame = function(){
    		mySound.stop();
    		var car = mySound.getBytesLoaded();
    		var tot = mySound.getBytesTotal();
    		var perc = Math.floor((car/tot)*100);
    		if(!isNaN(perc)){
    			pBar.setProgress(car, tot);
    			pBar.label = "LOAD "+perc+"%";
    			pBar.indeterminate = true;
    		}
    		if(car >= tot && tot > perc && perc == 100){
    			mySound.start(0, 1);
    			pBar._visible = false;
    		        delete this.onEnterFrame;
    			_root.gotoAndPlay(2);
    		}
    	}
    }
    _root.loadMP3("loop_01.mp3");
    stop();


  6. #6
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    scusa ma per creare un tasto play e uno stop o fatto cosi ma non funziona...

    PLAY:
    codice:
    on(release){
    mySound.loadSound("loop_01.mp3", true);
    }

    STOP:
    codice:
    on(release){
    mySound.loadSound("loop_01.mp3", false);
    }

    :master:

  7. #7
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    era più semplice

    on(release){
    mySound.start();
    }

    on(release){
    mySound.stop();
    }


  8. #8
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    mmm... non funziona

    ho provato come hai detto ma non và ho anche provato cosi
    codice:
    on(release){
    _root.mySound.stop();
    }
    ma niente .... :master:

  9. #9
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    prova a fare un trace di mySound lì dove c'è il preload per vedere che percorso ti da...

  10. #10
    Utente di HTML.it
    Registrato dal
    May 2002
    Messaggi
    2,929
    codice:
    MovieClip.prototype.loadMP3 = function(file) {
    	var mySound = new Sound(this);
    	mySound.loadSound(file, false);
    	_root.createClassObject(mx.controls.ProgressBar, "pBar", 1);
    	pBar._width = 150.0;
    	pBar._x = 200;
    	pBar._y = 20;
    	pBar._visible = true
    	this.onEnterFrame = function(){
    		mySound.stop();
    		var car = mySound.getBytesLoaded();
    		var tot = mySound.getBytesTotal();
    		var perc = Math.floor((car/tot)*100);
    		trace (mySound)
    		if(!isNaN(perc)){
    			pBar.setProgress(car, tot);
    			pBar.label = "LOAD "+perc+"%";
    			pBar.indeterminate = true;
    		}
    		if(car >= tot && tot > perc && perc == 100){
    			mySound.start(0, 1);
    			pBar._visible = false;
    		        delete this.onEnterFrame;
    			_root.gotoAndPlay(2);
    		}
    	}
    }
    _root.loadMP3("loop_01.mp3");
    stop();

    se lo metto qui mi dà
    codice:
    [object Object]
    mentre se lo metto al tasto
    codice:
    on(release){
    _root.mySound.start();
    trace(mySound)
    }
    mi dà
    codice:
    undefined
    :master:

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.