View Full Version : Basic Rectangle Transparency

04-13-2008, 09:33 PM
Hi. I'm trying to do an assignment, and I can't seem to figure out how to get the last part. Here are the directions:

"Using a for loop, fill the array with 10 rectangles. Then using forEach, change the alpha value of each rectangle so that the rectangle on the left is solid and the last rectangle on the right is transparent"

Here is what I have:

public function forEachArray():void {
var flArray2:Array = new Array();
for (var i:int=0; i<10; i++) {
var xpos:int = 30 + (i*30);
var mySprite:Sprite = new Sprite();
mySprite.graphics.drawRect(xpos, 30, 30, 85);
function arrayAlpha(element:Sprite, index:int, a:Array):void {
element.alpha = (index*.25);


Yes, it must be done in this ridiculous way, and all I have left to do is make it solid on the left, fading to transparent. I have it opposite. Any help please?

04-14-2008, 02:16 AM
This is AS3 right?

04-14-2008, 02:36 AM
Were you required to use AS3? Some things in AS3 are easier and some are easier in AS2. In this case it might be easier in AS2 as its not so object oriented.