PDA

Volledige versie bekijken : simpele preloader eigenschap veranderen


chrisdegrote
%Europe/Berlin %072 %2009, 02:45
Beste mensen,

Ik heb een preloader gekocht op flashden. Helaas is de functie van de preloader om een externe swf in te laden.
Wat ik wil is dat wanneer het laden compleet is het niet naar een externe swf gaat maar naar een frame/label in dezelfde .fla.

dit is de code nu

// create a new Loader
var loader:Loader = new Loader();

// add the progress event to the loader that calls the "loading" function
loader.contentLoaderInfo.addEventListener(Progress Event.PROGRESS, loading);

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

// 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("main.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;

}


Alvast bedankt voor je tijd

Bartj3
%Europe/Berlin %353 %2009, 09:29
addChild(loader);
deze addChild voegt de loader toe aan je stage, aangezien je dat niet wilt moet je deze regel dus weglaten.

function loadContent(event:Event):void
deze functie word uitgevoerd als het bestand is ingeladen, dus in deze functie wil je je aangeven dat hij naar het frame moet gaan.