actionscript help plz
- Started
- Last post
- 8 Responses
- jakeyj
ok, i need some quick help.
i'm trying to build an array using rollovers in flash, but my array seems to reset everytime. i want it to add to the array on every rollover. here's what i have:
stop ();
var countRollover = new Array();
menu_btn.onRollOver = function () {
gotoAndStop(2);
countRollover.push("menu_btn");
};menu_btn.onRollOut = function () {
gotoAndStop(1);
};
- blaw0
everytime you gotoAndStop(1) you're resetting the array.
you can move everything out one frame, declaring the array on one.
are you just using it to count? if so, why not try
menu_btn.onRollOver = function(){
count++;
}
- jakeyj0
i'm doing this thing where a button won't be activated until all of the rollovers are...rolled over.
any ideas for that instead of what i'm doing
thx
- jakeyj0
that worked by the way
- blaw0
i think i understand now and that sounds like a logical approach.
i typically try to keep the main timeline on a single frame and have any gotoAndPlay calls associated with this MCs' timelines.
- jakeyj0
need a little more help...
i can't get the variable length from frame 1 into frame 2. what the heck?
i've got this in frame 1 actions:
var countRollover = [];
this function is in frame2 actions:
a = countRollover.length;
function addToRollover (c) {
for (i = 0; i < a; i++) {
if (countRollover[i] == c){
trace ("done");
}
else {
countRollover.push(c);
trace (countRollover);
}
}
}
- blaw0
hey, jake, you have a couple of problems there.
first there isn't a stop action on frame two, so it keeps looping back and clearing out the array value.
a bigger issue is with the for loop. it will only return "done" if you're rolling over the first value.
i posted a better way of doing this here:
http://rafb.net/paste/results/xs…paste that into frame one; put four buttons on the stage and name them testBtn1, testBtn2, testBtn3, testBtn4.
hope this helps.
- blaw0
er... "put four buttons on the stage and name them testBtn1, testBtn2, testBtn3, testBtn4."...
... i mean, put four movieclips with those instance names on the stage.
- blaw0
bah! sorry...
at the top, replace:
var countRollover:Array;with:
var countRollover:Array = [];