setting alpha on a loader
Hi all,
I've been struggling for days to set the alpha on a loader which is inside a class Portrait. I've got 27 pictures I load through a class. I can set the alpha for 23 pictures. But when I try to set the alpha for 27 pictures the alpha for the first 4 pictures cannot be set. I can set it only to 1. They've been loaded and when I trace the alpha value it states 0.5 for example but nothing is displayed. The strange thing is that this is only so for the first 4 pictures when there are more then 23 pictures to load. I've tried replacing the pictures but that doesn't make a difference.
Here is the Portrait class:
Code:
package
{
import flash.display.*;
import flash.net.URLRequest;
import flash.events.*;
public class Portrait extends Sprite
{
private var _day_nr:int;
private var _alpha_val:Number;
private var _x_pos:int;
private var _y_pos:int;
public var my_loader:Loader = new Loader();
public function Portrait(day_nr:int, alpha_val:Number)
{
_day_nr = day_nr;
_alpha_val = alpha_val;
load_pict(day_nr);
}
public function load_pict(day_nr:int):void
{
addChild(my_loader);
day_nr = day_nr+1;
my_loader.load(new URLRequest("portretten/day_"+day_nr+".jpg"));
my_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, load_complete);
}
private function load_complete(e:Event):void
{
trace("complete "+e.target.url); // all image files are loaded
trace("_a: "+_alpha_val); // traces the right value
alpha = _alpha_val;
}
}
}
This is the code in the main time line for creating the Portrait objects:
Code:
import Portrait;
import flash.display.Graphics;
var film_width:int = 980;
var days:int = 27;
var test_portrait:Portrait;
var portrait_array:Array = [];
var p_button_array:Array = [];
var portrait_y:int = 30;
var portrait_x:Number = (film_width/2)-(240);
// containers
var stack_button_container:Sprite = new Sprite();
var stack_container:Sprite = new Sprite();
addChild(stack_container);
stack_container.y = portrait_y;
stack_container.x = portrait_x;
addChild(stack_button_container);
function make_layers():void
{
for(var i:int = 0; i<days; i++)
{
if(i==0)
test_portrait = new Portrait(i, 0.5);
else
test_portrait = new Portrait(i, 0);
stack_container.addChild(test_portrait);
portrait_array.push(test_portrait);
}
}
make_layers();
When I change if(i==0) to if(i==6) that is, anything higher than 3 it works fine. What is wrong here? I'm I setting the alpha in the right way/place? I'm becoming really desperate with this problem.
Any help is greatly appreciated! Here you can download a zip with the fla, class and pictures: www.numuseum.nl/diversen/28_days.zip
TIA.