<?php
$someVar = count(scandir("bilder/") - 2);
?>
I need to import $someVar in to my .fla-file, I only need its value.:
var timer:Timer = new Timer(1000);
timer.addEventListener(TimerEvent.TIMER, nextSlide2);
timer.start();
var ld:Loader = new Loader();
var bildeArr = [];
var backend: String = 'backend.php';
var loader: URLLoader = new URLLoader;
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.load( new URLRequest(backend));
trace(loader.data);
ld.x = 20;
ld.y = 20;
for(var i:int = 1; i<9; i++) {
bildeArr.push("bilde" + String(i));
}
i = 0;
function nextSlide2(evt:TimerEvent):void {
trace(i);
ld.load(new URLRequest("bilder/" + bildeArr[i] + ".png"));
addChild(ld);
if(i > 6) {
i = -1;
}
i++;
}
How?
You need to add a listener to the loader. It will call a function when the data has loaded.
the important thing to know is that loading data from a server is asynchronous. It does not happen immediately, and flash does not stop running while it is waiting to get the next data. So you need to make sure you do not call any code that requires the data before the data is loaded.
This code will continue to call the loop at the bottom before the data has loaded. If you want to use the data in your loop, you will need to move that code into a function and call that function from the onDataReady function.