|
-
picking a random mc
ok i have 100 movieclips and i need to randomly pick out 5 of them and change their frame...
Code:
function starts(c=0) {
do {
num = Math.random (100);
gotoandstop ("_root." & num, c);
c++;
} while (c < 6);
}
that doesn't seem to work... the 100 MCs are all named from 1-100. they each have 5 frames.
-
I'm not exactly sure but i think the problem is caused by this line
Code:
gotoandstop ("_root." & num, c);
try using
Code:
_root[num]gotoAndStop(c);
you might also want to change
Code:
num = Math.random (100);
to
Code:
num = Math.random(99)+1;
that will prevent the change of the variable being equal to 0 which would prevent a tile being changed.
Hope that helps.
-Mizike
Bajillion: An arbitrary number, the
value of which is set by the Bajillion Master
-
here's what I used:
Code:
function starts () {
c = 2;
while (c<=6) {
num = Math.round(random(99))+1;
tellTarget (_root.num) {
gotoAndStop (_root.c);
}
c = c+1;
}
;
}
starts();
and it works, but now i have a new question...
I'm trying to get the mouse pointer to send me information about the movieclip it's hovering over...
Code:
onClipEvent (load) {
startDrag (this, true);
Mouse.hide();
function getter () {
ter1 = Math.round((this._x-20)/40);
ter10 = Math.round((this._y-20)/40);
ter = ((ter10*10)+ter1)+1;
}
function getemp () {
this.emp = [ter].emp;
}
}
onClipEvent (enterFrame) {
getter();
getemp();
}
Thats the code inside of the pointer that I drew. I'm having trouble with the getemp function. All 100 movieclips are in a grid, and getter() tells me which one I'm hovering over. Inside each MC is code that makes a variable called "emp" = to the MCs current frame. But, the thing is, Flash doesn't want me to use a variable to refer to the MC's name. Is there any way to get around this?
-
When using brackets [] to put a variable into a target path, you don't use a . before or after so...
Code:
this.emp = [ter].emp;
should be
Code:
this.emp = [ter]emp;
that should be it, hope it works.
-Mizike
Bajillion: An arbitrary number, the
value of which is set by the Bajillion Master
-
flash doesn't want to do that...
keeps saying it expects an ";"
emp = _root[ter] works, but thats not what I want...
Is there another way around it?
-
Ok, I just went through and did some test code and it looks like i was wrong, you do need a period after, just not before.
Assuming all of your tiles are on the root the code should look like this
Code:
emp = _root[ter].emp
You dont need the "this", it works with it, but its just extra code because the AS is already pointing to the current clip. The reason it wasnt working was because flash was looking for the clip designated by the variable "ter" inside of the pointer clip, the _root just sets it on the right path. If all of your tiles aren't on the root just tack on the path to get to them before the [ter].
-Mizike
Bajillion: An arbitrary number, the
value of which is set by the Bajillion Master
-
thank you so much Mizike!!
-
could do it this way too:
Code:
mc = new Array();
mc[0] = mov1
mc[1] = mov2;
mc[2] = mov3;
_root[mc[random(mc.length)]].play();
Bring Back The Flash Footers Goddammit.
-
No problem Wattz. And just so you know, it's just Mike. Mizike (Miz-ike) is a joke between me and Tyler/GameDev
-Mizike
Last edited by BajillionMaster; 03-10-2003 at 07:41 PM.
Bajillion: An arbitrary number, the
value of which is set by the Bajillion Master
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
|