I have a section of code in my $(document).ready(function() {} that reads: 
getInitial(len); 
Where len is an integer.  
function getInitial(number){
    number--;
    if(number < 0) return
    var $items = $(balls()); 
    $items.imagesLoaded(function(){
        $container
        .masonry('reloadItems')
        .append( $items ).masonry( 'appended', $items, true );
    });
    getInitial(number);
}
Notice the line that reads: var $items = $balls(());  
That is defined as:
function balls(){
    $iterator -= 1;
    if($iterator < 0){
        var $boxes = $( '<div class="box">No more games!</div>' );
        $container.append( $boxes ).masonry( 'appended', $boxes, false );   
        return; 
    }
    var imgPreload = new Image();
    var ret; 
    imgPreload.src = 'scripts/php/timthumb.php?src='+$test[$iterator][2]+'&q=100&w=300';
    $(".imgHolder").append('<img src="'+imgPreload.src+'"/>');
    //console.log(imgPreload);
    $(".imgHolder").imagesLoaded(function(){
        ret = '<div class="box" style="width:18%;">'
            +'<p>'+$test[$iterator][1][2]['name']+'</p>'
            +'<img src="'+imgPreload.src+'"/>'//Replace this with the one below when timthumb is whitelisted
            +'<div id=boxBottom>'+Math.floor($test[$iterator][0]*100)+'%</div>'
            +'</div>';
    });
    console.log(ret);
    return ret;
}
My question is how can I get ret from the imagesLoaded() method inside of the balls() function to return to the $items inside of getInitial()?  
I hope there's no more confusion.
imagesLoadedis asynchronous, in which case you can't return the value immediately.