How can i get my UiLoader to random select SWF?
hey,
so want uiloader random select swf.
i have 3 swf files , can't seem figure out how make select random dice, wich made try , random answer.
so here's code, including dice kinda thingi. i'm starter , can't figure out lol, please ideas / suggestions / answers?
thanks
note: 'knoplinks' , 'knoprechts' mc buttons use dice want them same swf in 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 edited by: kaykiffen
the easiest way list 3 swfs in array , randomly select array element:
var swfa:array=['swf/swfname1.swf','swf/swfname2.swf','swf/swfname3.swf'];
yourbutton.addeventlistener(mouseevent.click,clickf);
function clickf(e:mouseevent):void{
loader.load(new urlrequest(swfa[math.floor(swfa.length*math.random())]));
}
More discussions in ActionScript 3
adobe
Comments
Post a Comment