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

Popular posts from this blog

Joomal 3.6.3 update error - PHP temporary folder is not set - Joomla! Forum - community, help and support

Upgrade 3.4.8 to 3.5.1 failed "download package failed" - Joomla! Forum - community, help and support

Fatal error during instalation - Joomla! Forum - community, help and support