-
weird while() loop
for whatever reason, my while loop will not work.
well, kind of.
it only attaches one lstar object.
Any help would be appreciated.
Code:
class Background extends MovieClip {
var i;
function onLoad() {
i = 0;
while (i<40) {
i += 1;
attachMovie("bstar", "bstar"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
}
i = 0;
while (i<40) {
i += 1;
attachMovie("star", "star"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
}
i = 0;
while (i<40) {
i += 1;
attachMovie("lstar", "lstar"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
}
}
}
oh yea,
I'm using flash pro. 8
AS2
Last edited by Aslai; 11-17-2008 at 05:53 AM.
-
No idea why you have 3 of the same exact loops, but try this:
PHP Code:
class Background extends MovieClip { var i:Number; function onLoad() { i = 0; while (i<40) { attachMovie("bstar", "bstar"+i, _root.getNextHighestDepth()); attachMovie("star", "star"+i, _root.getNextHighestDepth()); attachMovie("lstar", "lstar"+i, _root.getNextHighestDepth()); i++;// Move this down here, otherwise you will only get 39 stars } } }
-
Originally Posted by sstalder
No idea why you have 3 of the same exact loops, but try this:
PHP Code:
class Background extends MovieClip {
var i:Number;
function onLoad() {
i = 0;
while (i<40) {
attachMovie("bstar", "bstar"+i, _root.getNextHighestDepth());
attachMovie("star", "star"+i, _root.getNextHighestDepth());
attachMovie("lstar", "lstar"+i, _root.getNextHighestDepth());
i++;// Move this down here, otherwise you will only get 39 stars
}
}
}
it still fails to produce more than one star.
and the multiple loops were to control the density of the stars.
-
Senior Member
When you attach a movie it automatically places it at 0,0. So they are going to all be placed on top of each other.
You need to insert some code to place them apart instead on top of each other.
Whoever taught EVERYONE to put all their code on movie clips needs to be shot...
-
the bstar, star, and lstar have as script to jump onto a random position in the screen. and I figured it out.
it has to be "_root.attatchmovie()" instead of "attatchmovie()"
thanks for the help though. I forgot about i++
stupid BASIC
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|