# Can't get mc's width and height

**URL:** <https://forum.kirupa.com/t/cant-get-mcs-width-and-height/202925>\
**Category:** flash\
**Created:** [October 5, 2006, 9:14pm UTC](https://forum.kirupa.com/t/cant-get-mcs-width-and-height/202925 "2006-10-05T21:14:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Almonimus](https://avatars.discourse-cdn.com/v4/letter/a/b782af/32.png) [@Almonimus](https://forum.kirupa.com/u/Almonimus)\
**Post date:** [October 5, 2006, 9:14pm UTC](https://forum.kirupa.com/t/cant-get-mcs-width-and-height/202925/1 "2006-10-05T21:14:06Z")

</div>

[FONT=Fixedsys][SIZE=1][SIZE=2][FONT=Arial]I’m a student for design and want to build myself a portfolio, showing pictures and being able to jump between fit\_to\_screen mode to actual\_pixel\_size mode. The following code is just the beginning.

I’ve wrote the code [/FONT][/SIZE][/SIZE][/FONT][FONT=Fixedsys][SIZE=1][SIZE=2][FONT=Arial]mixing some tutorials [/FONT][/SIZE][/SIZE][/FONT][FONT=Fixedsys][SIZE=1][SIZE=2][FONT=Arial](sorry, but I didn’t find a good way to clean it so it’ll be more focused) - I’m a really new about action script.

[/FONT][/SIZE][/SIZE][/FONT][FONT=Fixedsys][SIZE=1][SIZE=2][FONT=Arial] \*\*myFile \*\*is a mc waiting for an external parameter **run\_url** - a string contains something like “/projects/illustration/alice\_in\_wonderland.jpg”[/FONT][/SIZE][/SIZE][/FONT]  
[FONT=Fixedsys][SIZE=1][SIZE=2][FONT=Arial]  
You can see the \*\*trace \*\*command marked as **red**. I’d expect it to give me a number of the movie clip’s width, yet i get “ **undefined** ” - Where is my mistake?[/FONT][/SIZE]

[COLOR=Blue]import mx[/COLOR].utils.Delegate;

[COLOR=Blue]var [/COLOR]streamingID:[COLOR=Blue]Number[/COLOR];  
[COLOR=Blue]var [/COLOR]fileLoaded:[COLOR=Blue]Boolean[/COLOR];  
[COLOR=Blue]var [/COLOR]dBar:[COLOR=Blue]MovieClip[/COLOR] = [COLOR=Blue]this[/COLOR].Bars.dBar; [COLOR=Silver]//downloading bar[/COLOR]  
[COLOR=Blue]var [/COLOR]progBarFactor = dBar.[COLOR=Blue]\_width[/COLOR]/100; [COLOR=Silver]//pixel to percents[/COLOR]  
[COLOR=Blue]var [/COLOR]spacing = 10;

[COLOR=Blue]function [/COLOR]displayStreaming (theSource:[COLOR=Blue]Object[/COLOR]) {  
[COLOR=Blue]if /COLOR {  
[COLOR=Blue] clearInterval /COLOR;  
dBar.[COLOR=Blue]\_x[/COLOR] = dBar.[COLOR=Blue]\_width[/COLOR];  
} [COLOR=Blue]else [/COLOR]{  
[COLOR=Blue]var percentLoaded[/COLOR]:[COLOR=Blue]Number[/COLOR] = [COLOR=Blue]Math[/COLOR].[COLOR=Blue]floor[/COLOR]((theSource.[COLOR=Blue]getBytesLoaded/COLOR/ theSource.[COLOR=Blue]getBytesTotal/COLOR)\*100);  
dBar.[COLOR=Blue]\_x[/COLOR] = [COLOR=Blue]percentLoaded[/COLOR]\*progBarFactor;  
}  
}

function doneStreaming():[COLOR=Blue]Void[/COLOR] {  
fileLoaded = [COLOR=Blue]true[/COLOR];  
}

[COLOR=Blue]function [/COLOR]screenFit (){  
[COLOR=Blue] if [/COLOR](myFile.[COLOR=Blue]width[/COLOR] \> [COLOR=Blue]Stage[/COLOR].[COLOR=Blue]width [/COLOR]- 50) {  
myFile.[COLOR=Blue]width[/COLOR] = [COLOR=Blue]Stage[/COLOR].[COLOR=Blue]width [/COLOR]- 50;  
}  
[COLOR=Blue] if [/COLOR](myFile.[COLOR=Blue]height [/COLOR]\> [COLOR=Blue]Stage[/COLOR].[COLOR=Blue]height [/COLOR]- 50) {  
myFile.[COLOR=Blue]height [/COLOR]= [COLOR=Blue]Stage[/COLOR].[COLOR=Blue]height [/COLOR]- 50;  
}  
myFile.[COLOR=Blue]\_x[/COLOR] = [COLOR=Blue]Stage[/COLOR].[COLOR=Blue]width[/COLOR]/2;  
myFile.[COLOR=Blue]\_y[/COLOR] = [COLOR=Blue]Stage[/COLOR].[COLOR=Blue]height[/COLOR]/2;  
};

fileLoaded = [COLOR=Blue]false[/COLOR];  
myFile.[COLOR=Blue]loadMovie/COLOR;  
[COLOR=Blue]onEnterFrame[/COLOR] = [COLOR=Blue]function/COLOR{  
[COLOR=Blue] var [/COLOR]total = myFile.getBytesTotal(), loaded = myFile.[COLOR=Blue]getBytesLoaded/COLOR;  
[COLOR=Blue] if [/COLOR](total != 0 && [COLOR=Blue]Math[/COLOR].[COLOR=Blue]round/COLOR == 1){  
[COLOR=Blue] var [/COLOR]w = myFile.[COLOR=Blue]\_width[/COLOR] + spacing, h = myFile.[COLOR=Blue]\_height[/COLOR] + spacing;  
screenFit();  
}  
}  
[COLOR=Red]trace (myFile.[/COLOR][COLOR=Red]width);[/COLOR]  
myFile.[COLOR=Blue]onLoad [/COLOR]= Delegate.create([COLOR=Blue]this[/COLOR], doneStreaming);  
streamingID = [COLOR=Blue]setInterval [/COLOR](displayStreaming, 100, myFile);  
[COLOR=Blue]stop/COLOR;[/SIZE][/FONT]
