For loop acting up, images scale and are missplaced
- August 4, 2009
- 2 replies
- 766 views
I have an image which i am attaching, it is the white portion of the image( i saved it on a black background so it is easy to see, but it is on a transparent background saved as a gif and imported to flash). When my for loop runs, i am trying to position this image on stage programatically, but it seems as it is not doing it right. It scales the image, and positions some all over the place
I wanted the images (8 of them) to appear in 2 colums each one spaced out evenly, but it fails to do that. The movie clip holds the image below. Also since it is a irregular shape, it seems to make the edges look really rought.
1) Why is the for loop generating these images all over the place like that?
2) Would it be more ideal to draw this shape with flash, rather then using a gif image? Is such a shape even possible to draw?
This is the code:
import fl.transitions.*;
import fl.transitions.easing.*;
import flash.events.TimerEvent;
var imageLoader:Loader;
var xmlData:XML;
var bucketItem:MovieClip; //These hold the image attached below
var bucketHor:MovieClip;
placeBuckets();
function set loadedXML(xml:XML):void {
xmlData = xml;
}
function placeBuckets():void {
var firstY:Number = 50;
var secondY:Number = 115;
var bucketCount:XMLList = xmlData.product;
for (var u:uint = 0; u < bucketCount.length(); u++) {
bucketItem = new bucket();
bucketHor = new bucketr();
if (bucketCount.country.text() == "USA") {
bucketItem.y = firstY;
bucketItem.x = 100;
//var bucketTween:Tween = new Tween(bucketItem, "x", Regular.easeOut, 0, bucketItem.x, 0.5, true);
} else {
bucketHor.y = secondY;
bucketHor.x = 300;
//bucketItem.scaleX = -1;
//var buckettwoTween:Tween = new Tween(bucketItem, "x", Regular.easeOut, 0, bucketItem.x, 0.5, true);
}
var bucketImgTrans = new TransitionManager(bucketItem);
bucketImgTrans.startTransition({type:Zoom, direction:Transition.IN, duration:3, easing:Strong.easeOut});
var bucketImgTransH = new TransitionManager(bucketHor);
bucketImgTransH.startTransition({type:Zoom, direction:Transition.IN, duration:3, easing:Strong.easeOut});
trace(bucketItem.y);
trace(bucketHor.y);
addChildAt(bucketItem, 0);
addChildAt(bucketHor, 0);
secondY = (secondY + 200) - 115;
firstY = (firstY + 130) - 50;
}
}
This is the trace Stmt for both Bucket y position
0
115
0
200
0
285
0
370
370
0
450
0
530
0
610
0
