ActionScript 2.0 :: Determining Dimensions Of Loaded Image?
Feb 18, 2010
I am loading images into a movieClip via XML file. I was wondering if there is a way to find out the height and width of the image I am loading. I tried grabbing the movieClip's dimensions but it's only the original size of the clip before i loaded the image.
How do I set the width and height of a loaded image in Flash? Setting the dimensions immediately after requesting it does not work. The width and height remain zero.[code]If I wait a short moment and then set the dimensions, it will work.I tried listening for the Event.INIT event and Event.COMPLETE events before resizing as suggested by some tutorials. Neither of the events were triggered.[code]
I have a site that allows a user to upload an image, modify the image, and then save the image to their computer. This works fine, or at least it suits me so far. This is done by uploading an image to an empty movie clip, failcont_mc, and then exporting it as a jpeg once the user is done editing the image. The empty movie clip seems to be dimensionless, which isn't a problem.
The problem lies when the user uploads a photo that has very high dimensions. I'd like to be able to upload the image, then scale it down and keep it's aspect ratio if it's too large. I only want to be able to do this if the image is too large. For example, load an image sized at 800x600 and scale it down to fit into an area that is 500x400 while keeping it's proportions in tact.
Here is an idea of what I want in steps: 1. Upload the image into empty movieclip 2. Check dimensions of the occupied movieclip (previously empty) 3. if the dimensions are above 500x400 4. then scale the movieclip down while keeping proportions in tact 5. display movieclip
The code is made up of snippets from here and there on the internet, so don't be surprised if you see something that looks familiar. On a side note, I'd like to give credit to those who have allowed their code to be used openly. All of the code works fine, I would just like to add steps 2, 3, and 4. Imageholder: failcont_mc In the code, I have a big white space to give an idea of where I'd like to place the code. I assume the code is executed as it is read by the flashplayer. What I have tried so far was grabbing the width and height of the "occupied" movieclip and setting them as variables. I used these variables to determine if the width or height was the larger number. Then I used the variables to make a proportion to make sure the end dimensions of the movieclip stayed within the area.
Code: //Allow this domain System.security.allowDomain("http://localhost/"); import flash.net.FileReference; // The listener object listens for FileReference events. var listener:Object = new Object(); [Code] .....
- I have an array of ~200 buttons. - Each button pulls individual info from a file online:
/routes/801/ /routes/802/ /routes/803/ ...- My pseudocode looks something like this:
Code: var myURLReq:URLRequest = new URLRequest("/routes/"+butNum); var myURLLoader:URLLoader = new URLLoader(); myURLLoader.addEventListener(Event.COMPLETE, infoLoaded);
[Code]....
My problem is this: Let's say the user clicks 5 buttons. Since data doesn't load immediately, I can't assume infoLoaded is being called in the same sequence in which the user clicks the buttons, but I need to know which file just loaded. Is there a property I can get from ev:Event so it'll give me the URL I used to load myURLLoader?
i have a flash site im working on, with an image gallery. the way the site is designed, when you enter into a gallery, while it's loading the images (lets say 5-10 images), it draws 5-10 gray boxes in the exact spots the images will load into.
the trick is i need to know in advance how big the gray boxes should be (width/height) before the image is fully downloaded.
i found this site: [URL]
but the way he wrote this, as soon as the class determines the images dimensions, it cancels the download.
i'd rather have a fully complete image class that downloads images, dispatches events with the image dimensions as SOON as theyre detected, and fully downloads the images as well.
Right now, my loaded swf works fine and is loading in the correct spot, but it is too large so i need to set the dimensions. I am loading it in through a movie clip also.[code]...
I have a text field that is assigned some HTML text which alongside the text itself also contains an "img" tag for displaying an image.I also am resizing the interface based of the dimensions of the text field and the problem that I have is that the interface resize needs to occur after the image has been loaded in the text field.
My goal is to do various things to a movieclip (zoom out with an alpha change) that has a jpg loaded into it. My thought is that I can load any jpg into the movieclip, and it will follow the commands made to the movieclip (i.e. zoom / alpha change).I am at the point where I am setting up the movieclip properties. Some of the questions I have are: is it possible to constrain the movieclip to a particular dimension, regardless of the jpg size. The jpg would then, ideally, need to be told to center within the movieclip, and the excess picture be cut off. Here is what I have so far: [code]For some reason the mc will no longer show up, and the traces come up as unvalid when I add the width and height dimensions, otherwise the picture will load, but at its original dimension.I was wondering if there was a tutorial explaining some of the concepts of mc's and loading images.
How can I get a jpeg that loads with the loadmovie command to fit to the dimensions of a movieclip that is being used as its "place holder"? Also if this image starts off initially at a much larger resolution than the place holder movieclip and therefore has to be shrunk down to start with, what happens when browser window is then resized to a larger window? (i.e the whole flash movie is enlarged). Will the image be stretched from the size it has been shrunk down to or will it still reference that external file? So if the image was larger than the site would ever need it to be would it look the best quality at all times?
I have a text field that is assigned some HTML text which alongside the text itself also contains an "img" tag for displaying an image.I also am resizing the interface based of the dimensions of the text field and the problem that I have is that the interface resize needs to occur after the image has been loaded in the text field.I haven't been able to find an event of the TextField class for this.
Code: var container:MovieClip = createEmptyMovieClip("container", this.getNextHighestDepth()); var mcLoader:MovieClipLoader = new MovieClipLoader(); mcLoader.addListener(this);[code]....
This always traces the width/height of the content of the external crossball.swf file, not its stage dimensions. So let's say crossball.swf has a document size of 200 by 200 pixels and in it is a shape of 115 by 30 it will trace the last as the width/height of 'container'.Is there any way to get the stage dimensions of an externally loaded swf through moviecliploader?
I have just finished tweeking my html page setting the width and height to 100% so that it appears in the same place on every screen. It seemed successful until i click on a page with an externally loaded swf.URL...i am unsure wether this is an html problem or as3. I have already set the dimensions of the external swfs in flash using:[code]
I'm making an application that gets images from a web site and displays them on a screen for the user.How do I call getSize() on that data? I've been told I can use XML functionality in AS3 to achieve this as well, any idea how someone might accomplish the task?
I'm working with SWFObject 2.2 using the expressInstall.swf that comes with the package.I understand that the swf is loading in another swf from an adobe server which is the actual express install.My problem is that when it loads, it loads at a larger dimension than I can handle and causes my flash to wrap onto another line and makes the site terribly ugly.how to prevent the dimensions from growing once the express install is loaded?(btw, no matter what dimension I change the expressInstall.swf to, it always becomes something bigger than I can have on the screen)
I want to load an external jpg,Is it possible to get the dimensions of the file loaded after? It seems straight forward enough and easy to do - but I don't ever remember seeing such a functionality in Flash before.
I need to get the width and height of the image before it finishes loading with a moviecliploader instance. This is for placement of another clip, which will always load before the image. Is there any way of doing this??? onLoadStart does not give dimensions of the image.
how do I access a button within the emptymcholder, and place it at a specific position?? Is this possible??
I tried doing emptymcholder.buttonname._x, but it does not work.
I'm using the following code to load images into a gallery through xml. The native resolution of the files is relatively high (though fits well on my 1920 x 1200 pixel display). Since I can't determine the resolution of other users' displays I would like to be able to resize the images loaded so that they fit proportionally on any screen.
I am trying to get the image dimensions to center in the dynamic sprite object but I am getting 0 in the height and widh property. get the image dimensions? I tried by using various properties of image control but I am getting the dimensions. Please see code below and the values in the inline comments
I have been searching in forums and I couldn't find an answer so I thought maybe I should ask.
I wrote a script that allows user to select a local file, which gets resized if it exceeds the width/height limits I specified, and finally this file gets uploaded to the server.
In documentation it writes the same max sizes for BitmapData and Loader:
Quote:
In AIR 1.5 and Flash Player 10, the maximum size for a loaded image is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a loaded image is 8,191 pixels wide, it can only be 2,048 pixels high.) In Flash Player 9 and earlier and AIR 1.1 and earlier, the limitation is 2,880 pixels in height and 2,880 pixels in width.
So what I need is to check the file size (width and height) before I attempt to load the bytes of the file into a loader. I'm limited to the ByteArray that I get by the load of the file via a FileReference instance.
Has anybody seen a source where you can get that data out of a ByteArray prior to loading it into a DisplayObject?
I'm loading an image into a movie clip dynamically, but I need to know its width. I can get it during the call back function for the complete event but how to I access this variable later on? If I trace its host mc's width outside of that function it returns '0' for the width.
I'm loading images from an XML file and I know what the image name is, however this is in a string variable. How can I get the dimensions of the image from this?
I'm loading images from an XML file and I know what the image name is, however this is in a string variable. How can I get the dimensions of the image from this?
Is there a way to get the height and width of an image that was loaded via an xml file? I am making an Image Viewer and I want the display to resize to the dimensions of the image loaded.
Here is the pseudo-code to give you an idea what I want:
for (i == 0; i <= 100; i++) { tempImg = get url ("http://mysite.com/" + i + ".jpg"); while (tempImg != fully loaded) {
[Code]....
Basically, I want it to go through my site from 001.jpg to 100.jpg, and return all the pictures that are not 400 x 320, but I don't know exactly how to code it.
The application doesn't need to display the images on-screen or anything fancy. Simple tracing will do for now.
In AS3, I have a Sprite that has a Z axis rotation applied.How do I calculate that Sprite's dimensions (it's original size) from Sprite.rotationZ and Sprite.getRect(...)?
What do I have to write to keep the movieclip not to change dimensions if the user starts playing with the dimensions of his screen ? I remember it was a line of as3 written at the beginning.