# Using outside variable to get image from unprotected directory

**URL:** <https://forum.kirupa.com/t/using-outside-variable-to-get-image-from-unprotected-directory/275175>\
**Category:** Uncategorized\
**Created:** [November 10, 2008, 9:05pm UTC](https://forum.kirupa.com/t/using-outside-variable-to-get-image-from-unprotected-directory/275175 "2008-11-10T21:05:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![maximillion511](https://avatars.discourse-cdn.com/v4/letter/m/0ea827/32.png) [@maximillion511](https://forum.kirupa.com/u/maximillion511)\
**Post date:** [November 10, 2008, 9:05pm UTC](https://forum.kirupa.com/t/using-outside-variable-to-get-image-from-unprotected-directory/275175/1 "2008-11-10T21:05:11Z")

</div>

hello guys,

have a new question for ya. I have a variable that i finally got from my php.  
so i need some help. I have a movie clip in my fla called prods. I need to be able to get the variable which is placed in a text box called item\_id and use it along with a URL to get an image.

example.

item\_id = 12345  
baseUrl = ‘[http://www.mysite.com/images/](http://www.mysite.com/images/)’ + item\_id.text + ‘.jpg’;

this was my attempt at getting it to show up

```auto

prods.addEventListener(Event.INIT, _changeImg);
function _changeImg(evt:Event):void{
var idStr:String = item_id.text;
var BaseUrl = 'http://www.mysite.com/images/' + item_id.text + '.jpg' ;
    if(item_id.text != null){
        prods.addChild(BaseUrl);
        }
    }

```

this is where i am confused… would i have to put an event listener on the movie clip where i want the image to be placed? or would i put it on the text box which gets this variable? further more what kind of Event Listener would i need to accomplish this?

any code snippets would be greatly appreciated as i am totally confused on this…
