[as1] Random Loop
Ok, i trimmed down my code. The below code generates around 50 boxes with a loop statement. But loops are loops and they generate things in order. 4,5,6,7,....
What i want is, how can i change my code so the loop doesnt generate thing in order but randomly. ex. 4, 13, 20, 2.... It has to generate every number only once. Please help!
ActionScript Code: on (release) { function myFunction(mc) { for (var i = 4; i<53; i++) { _root["boxx"+i].holder.onEnterFrame = function() { with (this) { //earth if (this._currentframe>=57 && this._currentframe<=69) { if (this._currentframe>57) { prevFrame(); } else { gotoAndPlay(70); } } //fire if (this._currentframe>=83 && this._currentframe<=95) { if (this._currentframe>83) { prevFrame(); } else { gotoAndPlay(70); } } //light_off if (this._currentframe>=47 && this._currentframe<=56) { if (this._currentframe>47) { prevFrame(); } else { gotoAndStop(12); } } if (this._currentframe>=2 && this._currentframe<=12) { if (this._currentframe>2) { prevFrame(); } else { gotoAndPlay(70); delete this.onEnterFrame; } } } }; } } myFunction();}
Ultrashock Forums > Flash > ActionScript
Posted on: 2004-06-03
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Random 'for Loop'
is there a way to make a random 'for loop' like:
for (m = 0; m < max_entries; m++) {
i'm pulling stuff from an xml file and would like the loop to display all the entries, but in a random order rather than 0, 1, 2, 3.
if i used the random math function i'm not sure how to tell the loop which entries have been displayed and which have not.
any ideas/help would be greatly appreciated!
Random Time Before Loop
Ok, so It seems simple enough, I'm having trouble writing the script necessary to do this. I have a basic animation, that I want to loop, at random intervals. The Idea is simple, www.noxi0us.com/cs/header.swf its basically that, but instead of the "shimmer" effect every 8 seconds or whatever its set to, I want it to go every 8, 10, 9, somethin like that, but random. Anyone out there that can help me do this? Thanks in advance.
A Random Continuous Loop? HELP
I am trying to produce a continuous loop of 15-20 photos, scrolling from left to right with no spaces, that are randomly placed. The viewing area is 1000px wide by 100px high. The photos are each 100px high, but vary in width. I cannot find any information about this. Hopefully someone can help.
How 2 Make A Random Loop?
Hi group
I want flash to pick randomly any of the following numbers:2,3,4,5
Now if say flash picks the number 1 (which I dont want), how do I make it repeat the process until it picks a number from the said list.
Heres where I'm at so far
frame = int(Math.random()*5)+1;
if (frame==1){
// now what?
}
Any help would be greatly appreciated
Cheers
Vic
Just some background
What I want is for flash to pick a random number from that list, lets say 3 and then it will jump to frame labelled 3 in that movieclips timeline.
Creating Random Loop
Hi. I'm really green on actionscript. I'm trying to create a continuous looping animation that draws from random animations within a single movieclip. The basic idea of the animation is a guy answering several different phone calls. I want the phone calls to come in random order as you sit on the animation, which will be the front page of the website. This also involves leaving a 6 second pause between calls as well. The calls are different lengths. I plan to apply this method to actions that occur in the background as well but we'll start simple.
If someone could tell me how to set up some kind of "random draw" system that draws from a group of set keyframes within a movieclip that would be awesome.
Andy
How To Create Random Loop
i am trying to create a picture quiz what picks randomly 50 pictures from 500.
how can i do that i wont pick twice the same picture.
So how to code a random code what fist picks a number...stores it to variable..then
stores it to array? and next time when picking number it first checks is that number already in the array
and if it is then does another random untill finds a number what is "new" , not in the array?
How To Do A Random Non Repeating From For Loop?
Any body know how to generate a random non repeating number from FOR LOOP?
See attached code. I want to trace random non repeating number.
Attach Code
var total = 5;
for (i=0; i<total; i++){
var r = Math.round(Math.random(total)*total)
trace(r);
}
Random Image Loop?
I am building a project that loads 30 images in to empty movie clips. I want one of the images to apear on top randomly. What is happening now is that the first swf in my loop always shows up on top.
Here is a link to waht i am doing:
http://www.0-style.com/files/
Here is some code i am working with:
Code:
// Random range
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random()*(max-min))+min;
return randomNum;
}
// Load External files
for (i=1; i<=30; i++) {
createEmptyMovieClip("img"+i+"_mc", randRange(101, 99999));
loadMovie("images/"+i+".swf", "img"+i+"_mc");
}
Random Images In A Loop
i have been working with this file: http://www.kirupa.com/forum/showpost...34&postcount=3
I got the code working from a button from the .fla posted on other page I think now but sometimes the same image presents itself when clicking one after the other.
I simply want to loop through 10 images and have them appear randomly at the click of a button. Can you also make it that it loops through the 10 images before the images appear again? i.e image 1 3 2.....10...9 then another random order for the 10 images?
Was pointed to:
last_image_loaded = "img04"
when load the next image check:
if(load_image==last_image_loaded)
{
//generate other random number/image name
}else
{
last_image_loaded = the name of the image you are loading
//load image
}
I still can't get it to work when messing around with above idea
Any help is appreciated.
Thanks,
Using A Loop To Duplicate And Random X Pos
Hi people, got some code working to duplicate a movieclip, but what I'd really like to do is obviously randomise the movieclip's x position so that it spreads across the stage, rather than stacking in the same position as it is now. Any clues greatly apprciated
julie
x
Code:
for (i=1; i<11; i++){
duplicateMovieClip("alien", "alien_new_"+i, 22-10, i);
}
Random Image Loop?
I am building a project that loads 30 images in to empty movie clips. I want one of the images to apear on top randomly. What is happening now is that the first swf in my loop always shows up on top.
Here is a link to waht i am doing:
http://www.0-style.com/files/
Here is some code i am working with:
Code:
// Random range
function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.round(Math.random()*(max-min))+min;
return randomNum;
}
// Load External files
for (i=1; i<=30; i++) {
createEmptyMovieClip("img"+i+"_mc", randRange(101, 99999));
loadMovie("images/"+i+".swf", "img"+i+"_mc");
}
[as1] Random Loop Generation Help
i wanna modify this code so the loop generates the boxes randomly in random time intervals. Right now all the boxes appear at the same time. I want them to move randomly. Can anybody show how can i achieve that?? Thanks!
ActionScript Code:
on (release) {
function myFunction(mc) {
for (var i = 4; i<53; i++) {
_root["boxx"+i].holder.onEnterFrame = function() {
with (this) {
//earth
if (this._currentframe>=57 && this._currentframe<=69) {
if (this._currentframe>57) {
prevFrame();
} else {
gotoAndPlay(70);
}
}
//fire
if (this._currentframe>=83 && this._currentframe<=95) {
if (this._currentframe>83) {
prevFrame();
} else {
gotoAndPlay(70);
}
}
//light_off
if (this._currentframe>=47 && this._currentframe<=56) {
if (this._currentframe>47) {
prevFrame();
} else {
gotoAndStop(12);
}
}
if (this._currentframe>=2 && this._currentframe<=12) {
if (this._currentframe>2) {
prevFrame();
} else {
gotoAndPlay(70);
delete this.onEnterFrame;
}
}
}
};
}
}
myFunction();
}
Random Loop Through Movieclips
I have 19 movieclips on the stage each with a property named 'owner'. Now, I want to loop through all 19 movieclips at random. The first one picked will have it's 'owner' property set to 'me' and then the next one will be set to 'you', so on and so forth until all 19 movieclips have been assigned an 'owner'. How could I begin to set this up?
Also, each movieclip has a list of movieclips that it can interact with, say mc01 can only interact with mc02, mc03 and mc05. I was thinking about putting these lists into arrays, but if I do, how can I pull that info into an 'if' statement to check and compare a single value that is stored in the list?
Any help would be greatly appreciated. Thanks.
Make Random Sound Loop
i'm using this AS to load external mp3's and play a random one:
code:
mp3urllist1 = new Array("aphex_loop.mp3","boards_loop.mp3", "suv_loop.mp3");
mp3Player = new Sound(this); // create a sound object to hold mp3
// loads streaming mp3
function loadRandomMP3(sndlist){
// random number between 0 and highest array index
randomSoundNum = Math.round(Math.random() * (sndlist.length - 1));
mp3Player.loadSound(sndlist[randomSoundNum],true);
}
loadRandomMP3(mp3urllist1 );
This is all working fine but each of the sounds is a loop but i cant seem to be able to make them loop because the loadSound function seems to have a shed load of arguments already passed to it.
Could someone help me make the sounds loop please.
Random Loop And Flash Player 7
Hi all, hoping someone can help here. I've got this random loop function that was working perfectly. Unfortunately circumstances have changed, and I now need everything published for Flash Player 7 instead of 6. After publishing this for Flash Player 7, the animation that is played slowly begins to freak out. It appears that the interval is getting shorter and shorter with each loop, eventually freezing the browser. Is there some way to make this Flash Player 7 compatible? Thanks for any help.
code:
actionInt = setInterval(randomLoop, Math.round(Math.random()*45000+5000));
function randomLoop(){
gnav.gnavProjects_mc.ovals_mc.gotoAndPlay(1);
clearInterval(ActionInt);
actionInt = setInterval(randomLoop, Math.round(Math.random()*45000+5000));
//trace(Math.round(Math.random()*45000+5000) + " : ovals");
}
stop();
Random Flash Banner With Loop
Hi, it has been a while since I have done a flash project. The project is almost complete but getting hung up on the AS.
Here is the scenario: I have five swf promos that will be randomly played. After one promo is played it should loop back to the beginning to randomly play another.
This is what I have so far in a test file.
File Name - holder.swf -> this is the file that calls the random SWF file. This works fine as I can call a random swf file.
Frame one - Movie Clip named "MC"
Frame one AS -
filename = ["1.swf", "2.swf"];
i = filename.length;
k = Math.floor(Math.random()*i);
loadMovie(filename[k], MC);
==============
File Name - 1.swf
This is a basic swf file with the letter "A" as a graphic. It is 25 frames long. In frame 25, there is a script that should go back to the code above to pick a new random swf file.
Should it be something like: _root.gotoandplay(1).
This does not work and just sits in the loaded swf file.
===============
File Name - 2.swf
See above for functionality - same as 1.swf except letter "B" as graphic
Can someone please help figure this out.
Thanks!
JRWL
Random Numbers Into Variables With Loop?
hi some help on this would be greatly appreciated.
i have this code to generate 3 random numbers yeah.. and i want to pass them into var1 var 2 and var3. how do i do it?
n = 3;
for (r= 0; r < cards.length && n > 0; ++r){
if (random(cards.length-r) < n){
n--;
please help.
SwitchUp For Random Image Loop Q
Hey Im trying to find a way to have a mc trace to see if it hasn't loaded the same # as other children mc. The code below is pasted on the first frame of 4 different mc. So each randomly loads an image, but most of the time 2 or 3 load the same image.
HTML Code:
_level0.switchUp();
while (_root.selNumber==_root.lastNum){
trace("images are the same");
_level0.switchUp(); }
continue;
this.createEmptyMovieClip("q",0).loadMovie("images/"+_root.selNumber+".jpg", 1);
q._x=30;
q._y=100;
p=this;
function change(){
p[d++].onEnterFrame=function(){with(this) if(_alpha>0)_alpha-=2;else this.removeMovieClip()}
d%=3;
var newmc=p.createEmptyMovieClip(d,d);
newmc._x=30;
newmc._y=100;
_level0.switchUp();
while (_root.selNumber==_root.lastNum){
trace("images are the same");
_level0.switchUp();
}
continue;
newmc.loadMovie("images/"+_root.selNumber+".jpg", 0);
newmc._alpha=0;
p.onEnterFrame=function(){
if(newmc._width ){
newmc.onEnterFrame=function(){with(this) if(_alpha<100)_alpha+=2;else delete onEnterFrame}
delete this.onEnterFrame;
}
}
}
id = setInterval(change,8000)
this is the part Im wondering about
HTML Code:
_level0.switchUp();
while (_root.selNumber==_root.lastNum){
trace("images are the same");
_level0.switchUp(); }
continue;
Is there a way of having the mc check to see if it doesn't have the same # as other mc? Is there a way to use array in (_root.selNumber == [here] )
Random Movie Clips Loop
Hey there.
I have a question about randomizing Movie Clips:
I am attaching an example where 12 movie clips will be called into stage.
(movieA1, movieA2, movieA3....)
I am trying to create a situation where instead of triggering "movieA1" and so on, the code will trigger:
movieA1 OR movieB1
movieA2 OR movieB2
movieA3 OR movieB3 and so on......
can anyone help here with how to apply it?
Thanks!
note that the attached code triggers AllMovies (MovieA's), MovieB's are not in code yet, only in the library, because I am not sure how to code such a thing.
adamlewen
Attach Code
function makeAllMovies() {
for (var i=1; i<=12;i++) {
var allHolders:Array = _root["Movie"+i+"Holders"] = new Array();
var holder:MovieClip = _root["Movie"+i+"Holder"] =
_root.createEmptyMovieClip("Movie" + i + "Holder",
this.getNextHighestDepth());
var j = 0;
var Movie:MovieClip = _root["Movie"+i] =
holder.attachMovie("Movie"+i, "Movie"+i+"_"+j, holder.getNextHighestDepth());
_root["Movie"+i+"Array"][j] = Movie;
switch (i) {
case 1:
Movie._x = 80;
Movie._y = 35;
break;
case 2:
Movie._x = 155;
Movie._y = 52;
break;
case 3:
Movie._x = 62;
Movie._y = 122;
break; //and so on.....
[mx][onSoundComplete] Random Loop Problem...
hi !
i want to set up a random loop, and my problem is that i can't get a perfect loop with the onSoundComplete event..
i got 2 perfect loop and this is my code :
ActionScript Code:
masterVol = 100;
activeLoop = "lester_loop1";
loopArray = ["lester_loop1", "lester_loop2"];
lester_loop1 = new Sound();
lester_loop1.attachSound("main loop");
lester_loop2 = new Sound();
lester_loop2.attachSound("second loop");
function startLesterLoop() {
this[activeLoop].setVolume(this.masterVol);
this[activeLoop].start();
this[activeLoop].onSoundComplete = function() {
var a = random(2);
_root.activeLoop = _root.loopArray[a];
startLesterLoop();
};
}
startLesterLoop();
i get a small gap between the loop, does someone knows about that ?
Stop My Infinite Random Loop Code
I'm making a "magic 8 ball" Flash gadget and I'm having some problems getting the code to randomly select 1 of the 10 pre assigned answers and having it stay with that answer. It keeps renewing the code for some reason and resubmitting a new random entry.
here's the code theory i got running:
ActionScript Code:
onClipEvent (enterFrame) {
randomX = Math.ceil(Math.random()*10);
if (randomX == 1) {
gotoAndStop ("a1");
} else {
... etc...
My answers are in a 10 frame movie clip with labels "a1" through "a10"
So why wont it just goto and stop at one and stay with it?
A For Loop With Random Vairalbes - How Not To Get Duplicate Results
Hey All, I have a loop that runs through 5 times and each time calls a function that puts two variables together randomly:
CODE:
myname = [];
for (i=0; i<4; i++) {
createRandomName();
trace(diarytextvar);
myname[i] = randomname;
trace(myname[i]);
}
randomname is a random match of two variables (ie., ShortDog, CrazyChicken, etc.). How can I check if a duplicate has occured and if so run the function again. So that each of my variables (myname0, myname1, myname2, myname3, myname4) are not duplicates?
Thanks in advance, Dvl
Changing Random Colours Of A Sprite In A Loop
Hi
I am trying to create a loop that changes the colours of my dynamic vectors inside my sprite
however I am not sure if I putt the following var names in the right place in the end of my statement attached
or if i need another variable :
var cross : Sprite = new Sprite();
var crosses:Array = new Array();
crosses.push (cross);
or help is greatly appreciated!
mt
Attach Code
var rows:Number = 60;
var columns:Number = 70;
var crosses:Array = new Array();
for (var i = 0; i < rows; i++) {
for (var j = 0; j < columns; j++) {
var cross : Sprite = new Sprite();
addChild ( cross );
var g : Graphics = cross.graphics;
g.lineStyle( 1 , 0x000000 , 0.8 );
g.moveTo( 20 , 20 );
g.lineTo( 30 , 30 );
g.moveTo ( 20 , 30 );
g.lineTo ( 30 , 20 );
var startX = 70;
var startY = 10;
cross.x = startX + cross.width*j;
cross.y = startY + cross.height*i;
crosses.push (cross);
}
}
//TIMER EVENT The times is calls the changeColor() method every 10 milliseconds
var timer:Timer = new Timer(10 , 8000000);
timer.addEventListener (TimerEvent.TIMER, changeColor);
timer.start ();
//This function changes the color for random tiles
function changeColor (e:Event):void {
for (var i = 0; i < 2048; i++) {
//*****I am not sure if I have my var names in the right place here*****//
var randomIndex:int = Math.floor(Math.random() * crosses.length);
var cross:Sprite = (Sprite)(crosses[randomIndex]);
if (cross.currentFrame == cross.totalFrames) {
cross.prevFrame ();
}
else {
cross.nextFrame ();
}
}
}
Play Tween One At A Time Using Random Loop
I have 10 mc's on my page which I want to load from alpha = 0 to 100, one at a time, but in a random order each time the page is loaded. I have code which uses an array to loop the mc's and I can then load the array into a tween using as2, but I don't know how to randomly create an array, then load these answers into a tween and play them one after another until the loop is complete. HELP!
Simple Random Script. I'm Missing The Loop Part. Please Help.
Hi guys, I'm trying to achieve a random music effect in my game. When you go to the keyframe, i want the script to choose a random number from 1 to 3. If the number is 1, it tells the Movieclip, Music1 to go to Frame 2 (Which has the music loop).
Here is my code
Code:
m = Math.Round(Math.Random(3)+1);
if (m == 1) {
tellTarget ("_root.music") {
gotoAndStop (2);
}
} else if (m == 2) {
tellTarget ("_root.music2") {
gotoAndStop (2);
}
} else if (m == 3) {
tellTarget ("_root.music3") {
gotoAndStop (2);
}
}
Now as I recall, you need to incorporate a loop into that somehow, I looked at the tutorials and they weren't much help. This isn't working correctly so I need some help. Thanks.
Cant Find A Solution To Stop Random Sound Loop
I have a sound movie clip in a movie and it has on/off buttons. The sound that isnt in the function stops as it should when a button is pressed and the movie goes to the stop frame. But the random sound clip function keeps playing. I cant get it to stop. Any ideas? Below is the scripting I currently have for the stop/paly frames.
Here is the actionscript that runs in the "play" frame:
Code:
stop();
mainsound = new Sound(this);
mainsound.attachSound("beatloop.wav");
mainsound.start(0,3);
var count = 0;
function plyrndsnd() {
soundPlay = new Sound();
max = 6;
min = 1;
rndClip = Math.round(Math.random()*(max-min))+min;
soundPlay.attachSound(rndClip);
soundPlay.start();
count++;
if (count == 5) {
clearInterval(myTimer);
}
}
myTimer = setInterval (plyrndsnd,4000)
Here is the actionscript that runs in the "stop" frame:
Code:
stopAllSounds();
stop();
How Do I Define The Greatest _x Position Based On A Loop, Assuming I Know The Last Element Of The Loop?
Hello,
This may be complicated,
I've a loop that creates emptyMovieClips
then I use one function to onRollOver _xscale them += 10
Now I want to move another movieClip based on the greatest _x position of my previously _xscaled elements, how do I do that?
example
for (var i = 0; i<my_array.length; i++) {
_root.menu_.createEmptyMovieClip("btn"+i, i+1);
}
//
_root.menu_["btn"+i].onRollOver = function() {
this._xscale += 10;
//
MY_DRAGER._x = HIGHT._x;
}
Can this be done?
Thanks,
I Would Like My Sound Loop To Continously Loop Without Looping Over Itself When I Repeat My Images.
I have a sound loop moving along with my flash images. When the flash images finish and I send it back to frame 1, my sound doubles. How can I play my sound loop once, but allow my images to continously loop.
Is there away to just run one loop of sound, and let the image aspect continue to loop.
I would like my sound loop to continously loop without looping over itself when I repeat my images.
Make One Element Loop Without Making Enitre Movie Loop?
i'm trying to make one element continue looping without making the entire movie loop... here's what i mean..
i have a layer that i've name actions which i've asigned a stop(); to at the end of the animation. but i want the red pulsating dot to continue looping/ animating ... to give you an even better idea, here's the swf file...
http://www.push1.com/roster_art_gal.swf
cheers!
LoadVars In A For Loop Not Executing .load Function Until For Loop Completed?
Ok so I have a simply for loop: ID[i] is a global array
Code:
for (i=0;i<12;i++)
{
var loadInfo:LoadVars = new LoadVars();
loadInfo.onLoad=function(success:Boolean)
{
if (success)
{
trace("whatever:"+loadInfo.myname);
}
else
{
trace("Nope");
}
loadInfo.load(ID[i]+".txt");
}
the problem I'm having is that the function doesn't execute until the for loop completes and then it executes 12 times in a row. Output is 'whatever: undefined' 11 times and then 'whatever: Bobble' (which corresponeds to the last .myname value as it should). Why is this? And how can I fix it? To be continued...
~NH
Random Random Random Timer... Problems
Heyy guys. I know you guys know this stuff backwards & forwards so maybe you can help.
This is a 2 part problem. Part 1 is Im trying to create a timer that functions at random intervals, the function in this case is playing a MC of a car driving on a freeway in 1 to 10 second intervals to give the feeling of, well, randomness. (I've attatched the .fla file if that'll help).
So it works, but not quite as it will generate intervals only twice before it repeats the second interval over and over. So the car will 'drive' in say, 7 seconds the first time and then it will drive in 3 seconds, then again in 3, and in 3 and in 3 seconds. Ive tested it so much I know its not coinsidence.
Here's the code Im using (located in the freeway MC):
var interval:Number = random(10)+1;
function someCodeToRun() {
_root.freeway.diffcars.drive01.gotoAndPlay(2);
}
setInterval(this, "someCodeToRun", interval*1000);
Part 2 is I also wanted the cars to be different colors, which is why there is a diffcars MC with different frames of cars, but now Im not even sure I was headed in the right direction with that.
Ultimately Id love to have different colored cars driving on the freeway at different intervals. Can anyone figure this out?
Loop Inside Loop... Why Doesn't Work Properly?
In order to cause a delay, I have put a loop inside another loop. Here it is:
for (a=1; a<6; a++) {
for (b=1; b<10000; b++) {
}
}
Flash delays to show the page but in the end I just see both variables with the maximun value. The point was to see variable "a" growing with delay. What have I done wrong?
Thank you
Function Inside For Loop; How To Give It Parameters Of The Loop
Hey!
This is the code:
Code:
for (i=0; i<5; i++) {
_root.createEmptyMovieClip("temp"+i, 1+i);
_root["temp"+i].beginFill(0xFF0000, 20 + (20*i));
_root["temp"+i].moveTo(0+(60*i), 0+(67*i));
_root["temp"+i].lineTo(100+(60*i), 0+(61*i));
_root["temp"+i].lineTo(100+(64*i), 100+(65*i));
_root["temp"+i].lineTo(0+(55*i), 100+(80*i));
_root["temp"+i].endFill();
_root["temp"+i].onRelease = function() {
trace("button Number = " +i);
}
}
So I made butttons and assigned each one an onRelease function. But each one needs to have assigned a variabile by the value "i" in the for loop.
When I write it like this the function itself is defined only after I click it and it ofcourse asigns all the buttons the same "i", the last value of "i" in the for loop.
How do I do it so I get first button with variable 1, second with 2,... ?
Thx.
Pausing Execution Of Code In A For Loop Between Each Loop. Howto?
I have a for loop which runs x amount of times and between each loop i'd like to implement a small pause of execution of the code. How would i do that? Can something like that only be done using a timer? If so how would i go about doing that and what things should i import? (Trying to do this in a class) ...
Loop Help: XML Attribute Doesnt Stay On Each Object Of The Loop
Hi, i'm working on a gallery that loads thumbnails from an xml file into 3 columns and when you click on a thumbnail it opens a new window with the fullsized image in.
I have modified code from a gallery tutorial to load the thumbnails from a xml file. They are going in 3 columns at the moment (I don't understand why but they are) but only the last image has a hand cursor when you rollover it, and then when you click on it, it traces "undefined" into the output box.
I have put
Code:
trace(images_arr[i].attributes.fullsize);
just below the bit where it loads the thumbnails and it traces the right path from the xml file for each image.
Can someone help me get it to trace the right path from the xml file when you click on ALL the thumbnails, not just the last one.
Thank you so much in advance!
Code:
function GenerateThumbs() {
images_arr = images_xml.firstChild.childNodes;
gap = 10;
this.createEmptyMovieClip("thumb_mc",100000);
thumb_mc._y = 10;
thumb_mc._x = 10;
for (var i = 0; i<images_arr.length; i++) {
trace('generating thumbs'+i);
this.thumb_mc.createEmptyMovieClip("thumb"+i+"_mc", i);
this.thumb_mc.createEmptyMovieClip("thumb"+i+"_tmp_mc", 300);
this.thumb_mc["thumb"+i+"_mc"]._x = ((i%3)*(67+gap));
this.thumb_mc["thumb"+i+"_mc"]._y = Math.floor(i/3)*(67+gap);
this.thumb_mc["thumb"+i+"_mc"].loadMovie(images_arr[i].attributes.thumb);
this.thumb_mc["thumb"+i+"_tmp_mc"].no = i;
this.thumb_mc["thumb"+i+"_tmp_mc"].onEnterFrame = function() {
var _mc = this._parent["thumb"+this.no+"_mc"];
var l = _mc.getBytesLoaded();
var t = _mc.getBytesTotal();
if ((l>=t) && (t>1) && (_mc._width>1)) {
_mc.onRelease = function() {
trace(images_arr[i].attributes.fullsize);
};
}
};
}
}
var images_xml = new XML();
images_xml.ignoreWhite = true;
images_xml.onLoad = function(success) {
if (success) {
GenerateThumbs();
} else {
trace("Error loading XML file");
}
};
images_xml.load("gallery.xml");
Pausing Execution Of Code In A For Loop Between Each Loop. Howto?
I have a for loop which runs x amount of times and between each loop i'd like to implement a small pause of execution of the code. How would i do that? Can something like that only be done using a timer? If so how would i go about doing that and what things should i import? (Trying to do this in a class)
Though i'm wondering if there's an easier way than timers to be able to do something like that, like C's sleep() function for example.
My Sound Loop Is Repeating Itself Ontop Of Previous Loop
Here is a link to a movie that I am working on:
LINK-
http://blue-title.com/v2/
My client says that when you first start the movie, the loop starts fine but when he clicks on one of the three buttons at the bottom (Home, Florida, Alabama) the initial first loop continues to play and a new loop is beginning to repeat while the first one is still playing.
It works fine for me in Firefox and Safari on a Mac.
Any solutions?
Todd Temple
Movie Clips In For Loop Onlydisplaying In 1st Loop
Hi there! I'm new at this so excuse if I'm being stupid.
I'm creating a game which I'm looping through an array and inside the loop I'm playing clips. The clips display only the first time the loop is being run. Here is the actionscript. PLEASE SOMEONE HELP ME... I'M DESPERATE!!!
code:
on (release) {
var myClips = new Array("Fletter", "Lletter", "Aletter", "Mletter", "Eletter");
var myClipsNewName = new Array("mov2", "mov3", "mov4", "mov5", "mov6");
var myClipsValue = new Array (10, 11, 12, 13, 14);
var cnt = 0;
for (var t = 0; t<4; t++) {
for (var i = 0; i if (cnt == -1) {
cnt = 0;
}
var temp = myClips[cnt];
attachMovie(myClips[cnt],myClipsNewName[cnt], myClipsValue[cnt]);
updateAfterEvent();
trace(myClips[cnt]);
if (i == Total-1) {
myClips.splice(cnt, 1);
myClipsNewName.splice(cnt,1);
myClipsValue.splice(cnt,1);
if (cnt == myClips.length) {
cnt = 0;
}
break;
}
cnt = cnt+1;
if (cnt == myClips.length) {
cnt = 0;
}
}
}
}
edit: jbum added as tags
PLEASE HELP - URGENT Load Random Swfs From Individual Random Sets
I have two target mcs I would like to load different random swfs into
I have eight folders (a-h), each with 12 swfs (001-012)
I need to load a random swf (001-012) from a random folder (a-h) into the "card1" mc
I have figured out how to specify which one I want:
loadMovie("a/a001.swf","card1")
stop();
however, I need it randomized....
then, I need to load another random swf into my "card2" mc (001-012) from another random folder (a-h, ...except for the folder from which the first swf was loaded)
can somebody please help??????
Random Movie Clips To Play For Random Amount Of Time
hi,
i am loading external movieclips randomly into 4 seperate emptymovies, i now need a way to get these random clips that i am loading to play for a random amount of time and then load the next clip.
i need some help with the code...
how do i get the clips to loop, then assign each a random number and have flash check if the random num is = to current frame...if it is, have that clip stop and a new one load?
i have no idea how to write the code for this
any help would be great
thanks
this is what i was given so far..but don't know what to do with it.
Code:
var rnd = Math.round(Math.random(mc._totalframes));
mc.onEnterFrame = function() {
this._currentframe >= this._parent.rnd ? unloadMovie(this) : null;
}
Script Needed: Random Picture On Random Place By Click
I have a small question about a script I'm trying to find. I don't have a lot of experience with Flash, but I have to do this thing for school for which I need this script for my website.
I need a script which does the following: When you click on a button (or just on any place if the first is not possible) with you mouse, there appears a random picture (one out of ten or something) on a random place in a field (so not the whole page).
I hope you understand what I mean. I don't know the script, I only know that it's supposed to exist :) Does anybody know this script or where I can find such a script?
Thanks for helping me!
Elfie
Help: Multipule Random Positioned Duplicate Random Movie
Does anyone know a way that i can produce a button that when rolled over will duplicate x amount of movies each with random _x and _y positions? Basically i have a movieclip that will
gotoandPlay(math.Round((math.Random()*10)+1)
which randomises that frame that is played. This instance will then do some form of tweening and then gotoandPlay(1) again. I need a script that will then keep generating more duplicate movie clips whilst a button is moused over. i tried the following
on(mouseover){
i = 0;
rand_num = math.Round((math.Random()*29)+1);
while(i<20) {
duplicateMovieClip(_root.movie, "movie"+i,i);
setProperty("movie"+i, _x, _root.movie._x+(rand_num*5);
setProperty("movie"+i, _y, _root.movie._y+(rand_num*5);
i++
}
}
where movie = movieclip name
but this seems to generate all the clips on top of each other @ different depths. I want movies that are all in different positions. Can you help?
Random Movieclip @ A Random Partly Defined Position
Ok I´ve searched this forum to death but i didn´t REALLY
find the answer to my question! I think it can´t be that
difficult but i´m new to action-script and so i gotta hope
u´ll know the answer :
I´ve got an movie. (uh yeah ^^) in this movie there are
many movieclips that contain animations. now i want these
mcs to appear randomly @ a random position of a few defined
positions.
I really got NO idea how to do this !*prayinforyahelp*
ok thx 8]
Detecting Which Random AttachMovie Loaded From Random Array
I'm building a Freecell type card game. I've got an array that loads all of the cards (actually, the linkage names for each card loaded from the library with attachMovie). I randomize the array before I "deal the cards" onto the stage.
Here's a little code snipet where "deal" starts off equaling 0 and "cardDeck" is the value from my array (for example, c5 equals 5 of Clubs):
Code:
if (deal<52) {
_root.createEmptyMovieClip("card"+deal, deal);
_root["card" + deal].attachMovie(cardDeck[deal],cardDeck[deal],deal);
deal++
}
There's more, of course. My problem is - How can I detect which card loaded into which movie? For example, I know I have a movie called _root.card6 at the bottom of the first column, how can I know what card is loaded into _root.card6?
Movieclip Showen In Random Places At Random Time
How can I make my movieclip appeare in diffirent places at diffirent time? And the movie clip is this flying mobilephones(you can see it in swf http://www.hot.ee/at03/flying-mobs.swf).
Thanx in advance!
Random Rotation To Equal Random Movement Direstion?
k i finally got it so that my things randomly move around the screen and have walls etc etc.. anyways now i wanna know how to make it so that my randomly moving ship will rotate to face there direction if you want i can post the code i am using for random movement and thanks in advance
Load Random Swfs From Two Differnet Random Sources
I am in the process of creating a VS Card game in Flash. It is basically a game where you can choose either one card or another, each randomly pulled from one of the eight different sets. The first card (or swf) can be pulled from any of the 8 sets (out of a total of 12 cards in each set))..and will load into a targetMC, and the second must be pulled randomly from any of the 8 sets except from the folder where the first card was chosen and load onto the second targetMC.
after the winning card is chosen, it will display winning animation (and send data off to a dynamic bargraph program), and then the main movie will reload two random cards from differnt sets.
can anybody help me on how to set this up??
|