Re: How can i know the dimension of the "pic.jpg" ?
|
Konjanja Takeuchi |
|
1/4/2008 1:42:33 AM |
Poththacci, Simply check the dimensions of the movie clip. Post Comments |
|
Re: How can i know the dimension of the "pic.jpg" ?
|
Raphaelin Mantein |
|
1/4/2008 1:43:42 AM |
If you have any photo enhancement like Adobe Photoshop or MS Photo editor you can get the dime nsion of the "pic.jpg. They will have a section where you can resize your image and or fi nd out what size it is. Post Comments |
|
Re: How can i know the dimension of the "pic.jpg" ?
|
Kay Yong Poy |
|
1/4/2008 1:44:44 AM |
Recently I was trying to get the height and width of an image loaded into Flash but kept getting zero for height and width. Turns out I was getting the dimensions before the picture was completely loaded .
Instead, I used the movieClipLoader object to load the picture. Then I could use a listener object to detect the onLoadInit event of the movieClipLoader object so that I could get the dimensions after the picture was completely loaded.
Here's the movieClipLoader related code in which the height and width are captured in the image movieclip's orig_height and orig_width variables.
Code: ( text ) // ************************************************** ********** // Create object to listen for when done with loading pic // ************************************************** ********** var loadListener:Object = new Object(); loadListener.onLoadInit = function(target_mc:MovieClip):Void {
target_mc.orig_height = target_mc._height;
target_mc.orig_width = target_mc._width; } ; var mcLoader:MovieClipLoader = new MovieClipLoader(); mcLoader.addListener(loadListener);; // --------------------------------------------------------------------------- // Use MovieClipLoader to load the image // --------------------------------------------------------------------------- mcLoader.loadClip("pic.png", image);
Post Comments |
|
Re: There are other methods available
|
Pamela Teipel |
|
1/4/2008 1:47:28 AM |
There are other methods available for the MovieClip.loadClip() that might be very useful. just grab add them to todd's code and you're sorted. onLoadError, in case of an error onLoadProgress, during the load onLoadStart, when it starts loading onLoadComplete, when it finishes loading onLoadInit, when it is loaded and goes to the first keyframe (that's why using any of the previous methods would return zero, cos it was empty, but when it checks the first keyframe it is filled with your image)
for example: loadListener.onLoadError = function(target_mc:MovieClip):Void { trace('not loaded: ' + mc); } ;
HTH Post Comments |
|
in response to Todd's code, it works great. However, one little tidbit was left out with line 15.
the reference to Code: ( text ) , that is the movie clip you are loading your images into. so it has to be declared before the Code: ( text ) Post Comments |
|