I have been attemting to access a set of btns that I've placed on stage who are attached to a group of empty movieclips inside of another Movieclip.
Everything else is working (thanks silentweed). My main problem is trying to give these btns actions and am just going in circles. This code is inside movieclip q1 with a identifier of q1(on the first frame).
Array.prototype.randomize = function() {
var i = this.length;
if (i == 0) return;
while (--i) {
var j = Math.floor(Math.random()*(i+1));
var tmp1 = this[i];
var tmp2 = this[j];
this[i] = tmp2;
this[j] = tmp1;
}
return this;
}
var arr = new Array("q1_ans1","q1_ans2", "q1_ans3", "q1_ans4", "q1_ans5");
arr.randomize();
trace(arr[0]);
trace(arr[1]);
trace(arr[2]);
trace(arr[3]);
trace(arr[4]);
trace(arr.length);
//place randomized btns to existing empty mc's
this.empty1.attachMovie(arr[0],arr[0],1);
this.empty2.attachMovie(arr[1],arr[1],2);
this.empty3.attachMovie(arr[2],arr[2],3);
this.empty4.attachMovie(arr[3],arr[3],4);
this.empty5.attachMovie(arr[4],arr[4],5);
//btn actions
???
Array.prototype.randomize = function() {
var i = this.length;
if (i == 0) return;
while (--i) {
var j = Math.floor(Math.random()*(i+1));
var tmp1 = this[i];
var tmp2 = this[j];
this[i] = tmp2;
this[j] = tmp1;
}
return this;
}
When the btn is clicked it needs to goto frame two of the same timeline that that btn is on... dunno if I am overthinking this and/or maybe there is a easy way to just put script on the btn itself.
can't really send the file... it is a corporate client. The "q1_ans1", "q1_ans2", ect. ect. are btns that are dynamically placed randomly to 5 empty movieclips. These empty movieclips are inside another movieclip "q1". Which is dynamically placed on another movieclip on the main timeline.
Really sounds like a mess when you type it all out.
Array.prototype.randomize = function() {
var i = this.length;
if (i == 0) return;
while (--i) {
var j = Math.floor(Math.random()*(i+1));
var tmp1 = this[i];
var tmp2 = this[j];
this[i] = tmp2;
this[j] = tmp1;
}
return this;
}
var arr = new Array("q1_ans1","q1_ans2", "q1_ans3", "q1_ans4", "q1_ans5");
arr.randomize();
//place randomized btns to existing empty mc's
this.empty1.attachMovie(arr[0],arr[0],1);
this.empty2.attachMovie(arr[1],arr[1],2);
this.empty3.attachMovie(arr[2],arr[2],3);
this.empty4.attachMovie(arr[3],arr[3],4);
this.empty5.attachMovie(arr[4],arr[4],5);
Is this actionscript inside your .swf file or are you doing an include?
And aren't your instance names q1_ans1 - 5?
If you can't show your swf you may have to just type out your structure and layers so we can get a better idea of your layout. I am trying to reference items based off your code, which appears to not be working.
they are movieclips brought in dynamically so they don't have instance names... they have their linkage i.e. - attachMovie("symbol name", "new ID name", level);
the names in the array are just names... so I could create a randomized effect
Ok last thing I request of you to hopefully fix this:
(Please use this code and paste all of the trace data and all errors you recieve)
PHP Code:
Array.prototype.randomize = function() {
var i = this.length;
if (i == 0) return;
while (--i) {
var j = Math.floor(Math.random()*(i+1));
var tmp1 = this[i];
var tmp2 = this[j];
this[i] = tmp2;
this[j] = tmp1;
}
return this;
}
var arr = new Array("q1_ans1","q1_ans2", "q1_ans3", "q1_ans4", "q1_ans5");
arr.randomize();
//place randomized btns to existing empty mc's
this.empty1.attachMovie(arr[0],arr[0],1);
this.empty2.attachMovie(arr[1],arr[1],2);
this.empty3.attachMovie(arr[2],arr[2],3);
this.empty4.attachMovie(arr[3],arr[3],4);
this.empty5.attachMovie(arr[4],arr[4],5);
this chunk of trace functions helps out a ton.... thanks so much. I really appreciate the time you spent helping out. Finally starting grasping the whole AS language this past week and it is hard to keep in mind little tricks like this...