Visualizzazione dei risultati da 1 a 4 su 4

Discussione: Loading As3

  1. #1

    Loading As3

    Salve a tutti!
    Ma i preload in AS3 caricano tutti un file esterno??
    è possibile mettere tutto su di un unico file?

    Ecco lo script che fa il preload e chiama il file swf contenete il filmato
    Codice PHP:
    // create a new Loader
    var loader:Loader = new Loader();

    // add the progress event to the loader that calls the "loading" function
    loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESSloading);

    // add the complete event to the loader so that when it finishes loading
    // calls the "loadContent" function
    loader.contentLoaderInfo.addEventListener(Event.COMPLETEloadContent);

    // add the loader on the stage
    addChild(loader);

    // set the url to be loaded inside the loader once the "loadContent"
    // function is called
    loader.load(new URLRequest("baianomarmi.swf"));

    // this function checks the loading progress
    function loading(event:ProgressEvent):void
    {
        
        
    // this variable is equal to the loaded bytes divided by the total bytes
        // returns a number between 0 and 1
        
    var loaded:Number event.bytesLoaded event.bytesTotal;
        
        
    // set the progress bar x scale to be equal to the "loaded" variable
        
    progress_bar.bar.scaleX loaded;
        
        
    // set the dynamic text field text "perc_txt" to be equal to the
        // "loaded" variable multiplied by 100 -> returns a round number
        // between 0 and 100
        
    loading_info.perc_txt.text Math.round(loaded*100).toString()+"%";
    }

    // this function is called when the loaded bytes are equal to the total bytes
    function loadContent(event:Event):void
    {
        
    // remove the loading_info movie clip from the stage
        
    removeChild(loading_info);
        
        
    // set the dynamic text field perc_txt value to null
        
    loading_info.perc_txt null;
        

    e possibile inserire un gotoAndPlay al fotogramma 2??

    Grazie
    Scusate sto imparando!

  2. #2
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Se ti serve il preload per il filmato principale, lo puoi fare in altra maniera, senza bisogno del Loader. Se fai una ricerca dovresti trovare qualcosa su questo forum.

    [edit] il codice comunque in generale è questo:

    Codice PHP:
    stop();
    addEventListener(Event.ENTER_FRAMEenterFrame);
    function 
    enterFrame (e:Event) {
        var 
    c:uint loaderInfo.bytesLoaded;
        var 
    t:uint loaderInfo.bytesTotal;
        var 
    p:uint Math.floor((c/t)*100);
        if (!
    isNaN(p)) {
            
    trace("Caricamento "+p+"%");
        }
        if (
    >= && && == 100) {
            
    removeEventListener(Event.ENTER_FRAMEenterFrame);
            
    gotoAndStop(2);
        }

    metti questo codice sul primo frame e il filmato inizia dal secondo frame

  3. #3
    Qualche link piu nello specifico?
    Scusate sto imparando!

  4. #4
    Utente di HTML.it L'avatar di and80
    Registrato dal
    Mar 2003
    Messaggi
    15,182
    Ho modificato il mio messaggio precedente, devi solo copiare e provare

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.