View Full Version : AS query- how to incorporate random load
cmart
March 21st, 2005, 04:49 PM
HI all...this is the fourth version of this question (previous posts were not answered) so hopefully, it's clear this time.
I have this script assigned to a button.
homebutton.onRelease = function() {
if (_root.section != "home.swf") {
_root.section = "home.swf";
_root.transition.gotoAndPlay("closing");
}
I'd like the "home.swf" to be a random clip chosen out of three .swf's. Is there a way to expand this script to include a random choice script?
Thanks.
virusescu
March 21st, 2005, 05:01 PM
really quick and simple way would be if you had 3 swfs name home1.swf home2.swf and home3.swf
then your script would look like
homebutton.onRelease = function() {
if (_root.section.substr(0,4) != "home") {
_root.section = "home"+Math.ceil(Math.random*3)+".swf";
_root.transition.gotoAndPlay("closing");
}
Good luck this time :)
cmart
March 21st, 2005, 09:04 PM
really quick and simple way would be if you had 3 swfs name home1.swf home2.swf and home3.swf
then your script would look like
homebutton.onRelease = function() {
if (_root.section.substr(0,4) != "home") {
_root.section = "home"+Math.ceil(Math.random*3)+".swf";
_root.transition.gotoAndPlay("closing");
}
Good luck this time :)hey thanks! I'll give it a try in the morning.
MichaelxxOA
March 21st, 2005, 09:14 PM
[B]
cmart
March 22nd, 2005, 05:11 PM
hey thanks again- it worked after a little bit of finessing. final AS:
homebutton.onRelease = function() {
if (_root.section.substr(0,4) != "home") {
_root.section = "home"+Math.ceil(Math.round(Math.random()*3))+".swf";
_root.transition.gotoAndPlay("closing");
}
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.