HI - My monkeying hasn’t worked here but I imagine it’s a simple fix, just didn’t hit on it yet.
I have an array with 8 items, and I want them to be randomly placed on the stage with each load, or when a “shuffle” button is pressed. Just a simple puzzle where the pieces are to be scrambled and then dragged and dropped by the user.
Current code that isn’t working:
var myArray:Array = new Array();
myArray[0] = puzzle1;
myArray[1] = puzzle2;
myArray[2] = puzzle3;
myArray[3] = puzzle4;
myArray[4] = puzzle5;
myArray[5] = puzzle6;
myArray[6] = puzzle7;
myArray[7] = puzzle8;
for (var i = 0; i < myArray.length; i++){
trace(i);//returns 0-7 correctly
myArray*.onLoad = function() {
//initial positions
width = 330;
height = 226;
x = Math.random() * width + 330;
y = Math.random() * height + 226;
//math may be goofy. I'm trying to place items randomly in
//lower right quarter of stage, stage is actually 660 x 452.
//Nonetheless trace returns no value here.
this._x = x;
this._y = y;
}
//start and stop drag below works.
myArray*.onPress = function() {
this.startDrag ();
}
myArray*.onRelease = function() {
this.stopDrag ();
}
}
Thanks for your help.