So this is my problem I have two classes:
First class: MINIATURKA which loads all img by URLRequest
Second class: MINIATURKI which loads a XML file and creates an Array of class MINIATURKA(loaded jpg)
The img have different widths, and i want to place them in a row, one next to the another, so the code of the Array in class MINIATURKI should look like this:
[COLOR=#000000]xml1 = new XML(URLLoader(event.target).data);
var i:Number;
var currentX:Number = 0;
mini = new Array(xml1.obrazek.length());
count = xml1.obrazek.length();
for (i=0; i<count; i++)
{
mini* = new Miniaturka(xml1.obrazek*.attribute("id"),i);
addChild(mini*);
mini*.x = currentX;
currentX += mini*.width;
}[/COLOR]
The problem is that when i trace the mini*.width value it traces the same value [COLOR=#000000]as this value [/COLOR][889] [COLOR=#000000]in the code of class [/COLOR]MINIATURKA[COLOR=#000000]: [/COLOR]**button.graphics.drawRect(0, 0, 889, 500);
**
HERE IS THE CODE OF CLASS MINIATURKA
[COLOR=#000000]public function Miniaturka(id:String, index:Number):void {
var je:JPGSizeExtractor = new JPGSizeExtractor();
this.id = id;
this.index = index;
tryb = false;
var loader:Loader = new Loader();
loader.load(new URLRequest("images/" + id + "m.jpg"));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, nLoadComplete);
je.addEventListener( JPGSizeExtractor.PARSE_COMPLETE, sizeHandler);
je.extractSize("images/" + id + "m.jpg");
function sizeHandler( e : Event ) : void {
trace(je.width);
}
button = new Sprite();
button.graphics.beginFill(0x000000, 0);
button.graphics.drawRect(0, 0, 889, 500);
button.graphics.endFill();
button.buttonMode = true;
addChild(button);
button.addEventListener(MouseEvent.MOUSE_OVER, onOver);
button.addEventListener(MouseEvent.MOUSE_OUT, onOut);
button.addEventListener(MouseEvent.CLICK, onClick);
}[/COLOR]
[LEFT][COLOR=#000000]I can’t put the creation of button sprite into the** sizeHandler **function, because the *mini.width **will trace as 0
[/COLOR][COLOR=#000000]The proper value traces the: **trace(je.width); **from the above code.
How to make the: je.width value work in this line as: button.graphics.drawRect(0, 0, je.width, 500);[/COLOR][COLOR=#000000]
Is it even possible?
[/COLOR][COLOR=#000000]Or is there another way to send the value direct to the another class?
[/COLOR][/LEFT]
I wan’t to crate a galery like on this website: http://www.adartis.pl/#portfolio