# PROBLEM with variables

**URL:** <https://forum.kirupa.com/t/problem-with-variables/269247>\
**Category:** Uncategorized\
**Created:** [August 25, 2008, 10:07am UTC](https://forum.kirupa.com/t/problem-with-variables/269247 "2008-08-25T10:07:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmantzar](https://avatars.discourse-cdn.com/v4/letter/p/e274bd/32.png) [@pmantzar](https://forum.kirupa.com/u/pmantzar)\
**Post date:** [August 25, 2008, 10:07am UTC](https://forum.kirupa.com/t/problem-with-variables/269247/1 "2008-08-25T10:07:53Z")

</div>

# 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&lt;=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();

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