How can i get my UiLoader to random select SWF?
Hey,
So i want my UiLoader to random select a Swf.
I have 3 swf files and i can't seem to figure out how to make it select random just as a dice, wich i made to try and get random answer.
So here's my code, including the dice kinda thingi. I'm a starter and just can't figure it out lol, please any ideas / suggestions / answers? ![]()
Thanks
note: the 'knopLinks' and 'knopRechts' are mc buttons i use for the dice i want them to do the same but with swf in an uiloader
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.net.URLRequest;
//Declaring Variables
var dice:MovieClip = diceMc;
var knopLinks:MovieClip = knopLinks;
var knopRechts:MovieClip = knopRechts;
var currentRoll:uint = 0;
var urlRequest:URLRequest = new URLRequest();
var loader:UILoader = loaderMc;
//Number = 0.5 or - 0.5
//int = 1 or -1
//uint = >0
//Init
dice.stop ();
knopLinks.stop ();
knopRechts.stop ();
//Events
knopLinks. addEventListener ( MouseEvent.MOUSE_DOWN,knopLinksDown );
knopLinks. addEventListener ( MouseEvent.MOUSE_UP,knopLinksUp );
knopRechts. addEventListener ( MouseEvent.MOUSE_DOWN,knopRechtsDown );
knopRechts. addEventListener ( MouseEvent.MOUSE_UP,knopRechtsUp );
//Functions
function knopLinksDown(e:MouseEvent){
dice.play();
}
function knopLinksUp(e:MouseEvent){
currentRoll = 1 + Math.round(Math.floor(Math.random() * 3));
dice.gotoAndStop(currentRoll);
}
function knopRechtsDown(e:MouseEvent){
dice.play();
}
function knopRechtsUp(e:MouseEvent){
currentRoll = 1 + Math.round(Math.floor(Math.random() * 3));
dice.gotoAndStop(currentRoll);
}
function buttonDown(e:MouseEvent){
trace(e.currentTarget.swf);
urlRequest = new URLRequest('swf/' + e.currentTarget.swf)
loader.load(urlRequest);
SoundMixer.stopAll();
}
Message was edited by: KayKiffen
