# Dinamicaly Loading Images

**URL:** <https://forum.kirupa.com/t/dinamicaly-loading-images/14615>\
**Category:** flash\
**Created:** [February 28, 2003, 1:48pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615 "2003-02-28T13:48:28Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![tstefan](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tstefan](https://forum.kirupa.com/u/tstefan)\
**Post date:** [February 28, 2003, 1:48pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/1 "2003-02-28T13:48:28Z")

</div>

I have a little problem.  
Loading external .jpg file in to the movie clip is not the problem,  
butt geting picture size is.  
It looks like the size of the movie clip, in which I am loading image, is not changing at all, it stays 100×100 pix no mather what size is the picture.  
I would like to know how can I get picture or movieclip size (\_xscale,\_yscale) so I can manipulate with it.  
Help  
(-: (-: :q: :q:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 28, 2003, 2:32pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/2 "2003-02-28T14:32:06Z")

</div>

the \_xscale and \_yscale are percentages of the actual width/height of the movieclip. The movieclip could start out being 10x10 and then jump to 200x400 if you load a movie into it, but its \_xscale and \_yscale will stay the same (most likely 100 unless it was changed) because it represents a percentage of the original. when it was 10x10 then it was 100% its original size, which is 10x10. Once that movieclip gets a 200x400 image loaded into it, its still 100% its original size because now its original size is 200x400. To get the actual dimensions, you’d use \_width and \_height, they are the properties which reflect either 10x10 or 200x400. once you load an image into an unadjusted movieclip, it will take on the size of the actual image. From there you can adjust the \_xscale or \_yscale or the \_height or \_width to change it to whatever you want.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 28, 2003, 5:15pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/3 "2003-02-28T17:15:57Z")

</div>

I had the same problem, look at the following thread it will explain everything and give you exactly what you want.

[http://www.kirupaforum.com/showthread.php?threadid=11567](http://www.kirupaforum.com/showthread.php?threadid=11567)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [February 28, 2003, 8:24pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/4 "2003-02-28T20:24:18Z")

</div>

Thank guys, but a need one more thing.

How can I get \_xscale and \_yscale of loaded picture.  
I am loading pictures in the movie clips (created with creatEmptyMovieClip) which are alined in one row like in the infinite menu, but dinamicaly.  
I need \_xscale of container in witch are this movie clips with loaded pictures so I can set boudaries for moving container clip like in infinite menu.  
Boudaries must be dinamicaly set too so I can load as many pictures as I want in my menue.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 1, 2003, 5:45am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/5 "2003-03-01T05:45:56Z")

</div>

Howdy…

When you dynamically load image files into the empty movieclip in Flash, \_xscale and \_yscale resets to 100 when the image is fully loaded… Now, I don’t think this is what you want… Maybe you want to know \_width and \_height of the movieclip instead to resize the border???

Try this code… This code WILL NOT get the image dimension before the loading… It checks if the external image is loaded or not and when it is FULLY loaded, it will trace out the dimension of the loaded image file… If you need to know the dimension before you actually load the image file, you will have to use server side script to return you the dimension…

```php
_level0.createEmptyMovieClip("tester", 1);
_level0.tester.loadMovie("testOnLoad.jpg");
_level0.onEnterFrame = function ()
{
	if (_level0.tester._width)
	{
		trace("_level0.tester._width = " + _level0.tester._width);
		trace("_level0.tester._height = " + _level0.tester._height);
		delete _level0.onEnterFrame;
	}
}

```

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 1, 2003, 9:23pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/6 "2003-03-01T21:23:00Z")

</div>

This is what I was looking for.  
When I finish my dinamicaly created infinite menu I will post the source.  
Thanks again.  
=) =) =) =)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 2, 2003, 5:55am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/7 "2003-03-02T05:55:26Z")

</div>

:rambo:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 5, 2003, 11:40am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/8 "2003-03-05T11:40:54Z")

</div>

Here is the finished menu.

[Dinamicaly xml menu](http://www.inet.hr/~tstefan/posao/gallery.html)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 11, 2003, 11:42am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/9 "2003-03-11T11:42:36Z")

</div>

Well I am thinking about writing a tutorial bout my FLA file and the use of XML.  
Here are those two files sou you can download them and take a look inside.

[FLA](http://www.inet.hr/~tstefan/posao/gallery.fla)  
[XML](http://www.inet.hr/~tstefan/posao/Mymenue.xml)  
🙂 🙂 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 11, 2003, 6:45pm UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/10 "2003-03-11T18:45:39Z")

</div>

Hi tstefan,

Can you please explain what this line of code is doing. Especially the “\_root.container=\_width”, is the \_width from the container or  
barimg?

thanks.

if (\_root.container=\_width){  
\_root.barimg.onEnterFrame = function() {  
bytes\_loaded = \_root.slika.getBytesLoaded();  
bytes\_total = \_root.slika.getBytesTotal();  
getPercent = Math.round(bytes\_loaded/bytes\_total_100);  
getPercenttext=getPercent+"%";  
this.\_width=getPercent_1.91;

};  
}

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 1:44am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/11 "2003-03-12T01:44:27Z")

</div>

Oopsie…

That line should be read  
if (\_root.container == \_width){  
Double equals(==), not single equal(=) within the if statement to check the condition…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 4:23am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/12 "2003-03-12T04:23:58Z")

</div>

is the \_width from the container or  
barimg?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 6:19am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/13 "2003-03-12T06:19:06Z")

</div>

\_width in that case aplies to the object that this code is placed on.

PS - tstefan: Nice. Clean and functional. And welcome to Kirupa from me. Love the Croatians. (Im dating a grand daughter of your country.)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [March 12, 2003, 8:21am UTC](https://forum.kirupa.com/t/dinamicaly-loading-images/14615/14 "2003-03-12T08:21:39Z")

</div>

I am glad that you like my work, and I will try to post more of my work.

PS.  
Send my hello to grand daugther of Croatia, David.

=) =) =) =) :beam:
