I have a set of high resolution pictures. Each of these pictures shows a car on a different angle. The idea is to switch from one picture to the next so it gives the user the impression the car is turning.
Flex takes to much time to render the picture. Therefore the switch happens with a lagging effect instead of smooth like its suppose to.
First I add the images on a View calling initLeftRightModel
onCreateChildren:
protected function initLeftRightModel():void
{
if(containerLeftRight && definitionLeftRight)
{
for(var i:int = 0; i<36;i++)
{
var img:Image = new Image();
img.height = 1068 * scaleFactor;
img.width = 2048 * scaleFactor;
img.contentLoader = ldr;
img.contentLoaderGrouping = 'gr1';
if(i < 10 ) img.source = modelPath+'/0'+i.toString()+'.png';
else img.source = modelPath+'/'+i.toString()+'.png';
containerLeftRight.addElement(img);
if(i>0)img.visible=false;
}
}
I call the function turnModelTo
to switche the visibility of the last picture to false and the next to true:
/**Turns the model in the direction of the finger according to the variation of X.**/
protected function turnModelTo(newX:Number):void
{
var val:int = 0;
direction = (oldX != newX)?oldX - newX:direction;
if(oldX > newX) val = (oldValue+1<36)?oldValue+1:0;
else if(oldX < newX) val = (oldValue-1>0)?oldValue-1:35;
else if(oldX == newX) val = oldValue;
oldX = newX;
containerLeftRight.getElementAt(oldValue).visible = false;
oldValue = val;
containerLeftRight.getElementAt(val).visible = true;
}
The images are loaded only one time and I am using caching. The problem is with the rendering of images.
The resolution of the images is 2048x1068. This is a mobile project and I am currently testing on iPad Air. I appreciate any help or ideas about how to best code this functionality.
Thanks