Copy link to clipboard
Copied
Hi all, i have this code:
imgContainer.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, function(){loadProgress(loader)});
function loadProgress(aa):void{
var percentLoaded:Number = Math.round((event.bytesLoaded/event.bytesTotal) * 100);
trace("Loading: "+percentLoaded+"%");
percentCar=percentLoaded*3;
aa.width=percentCar;
aa.x=-percentCar/2;
}
but doesnt work because of in this way in loadProgress there's no event to calculate bytesLoaded ecc...
how can i pass variables in this formula?
thanks a lot
use:
imgContainer.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS , loadProgress);
function loadProgress(event:ProgressEvent):void{
var percentLoaded:Number = Math.round((event.bytesLoaded/event.bytesTotal) * 100);
trace("Loading: "+percentLoaded+"%");
percentCar=percentLoaded*3;
loader.width=percentCar;
loader.x=-percentCar/2;
}
or, if there's some really good reason to pass loader into your loadProgress function use:
imgContainer.contentLoaderInfo.addEven |
Copy link to clipboard
Copied
use:
imgContainer.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS , loadProgress);
function loadProgress(event:ProgressEvent):void{
var percentLoaded:Number = Math.round((event.bytesLoaded/event.bytesTotal) * 100);
trace("Loading: "+percentLoaded+"%");
percentCar=percentLoaded*3;
loader.width=percentCar;
loader.x=-percentCar/2;
}
or, if there's some really good reason to pass loader into your loadProgress function use:
imgContainer.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, function(e:ProgressEvent) { |
loadProgress(e,loader)
});
Copy link to clipboard
Copied
but in this way the variable "loader" doesnt't pass into loadProgress ?!?
Copy link to clipboard
Copied
there's no reason to do that but if you think you know better, use:
imgContainer.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, function(e:ProgressEvent) { |
loadProgress(e,loader)
});
Copy link to clipboard
Copied
thanks a lot, really helpful!
have a nice week-end!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now