PROBLEM with variables

I have a problem with some variables. I set a variable in a function and it cjange values inside the function but outside the function it has the default value.

var num_photo1:int;
var xmlLoader_photos_sel:URLLoader = new URLLoader();
xmlLoader_photos_sel.addEventListener(Event.COMPLETE, showXML_photos_sel);
xmlLoader_photos_sel.load(new URLRequest(“photos.xml”));
function showXML_photos_sel(e:Event):void {
XML.ignoreWhitespace = true;
var photos_sel:XML = new XML(e.target.data);

var filenames:Array=new Array();

var i:Number;
var id_to_show:int;
for(i=0;i<=photos_sel.photo.length();i++){
    filenames[num_photo1]="";
    if((this.parent as MovieClip).epixeirisi_kastoria_id==photos_sel.photo*.etaireia){
        filenames[num_photo1]=photos_sel.photo*.filename;
        this.num_photo1++;    
        trace(num_photo1);

//num_photos=num_photo1;

    }

}

//num_photos=this.parent.num_photos_show();
//num_22.text=num_photos.toString();

}

//num_photos=this.parent.num_photos_show();
num_22.text=this.num_photo1.toString();

======================================================