I load an image in a movieclip, the image size is grater than the moveclip, so how can I specify the image size should fit the moveclip without modifying the image? Thanks
I dette særtema ser vi på, hvordan cloud og AI bliver fundamentet for virksomhedernes digitale forretning, og hvordan de nye muligheder for automatisering og forretningsværdi kan udnyttes uden at miste overblik, sikkerhed og menneskelig kontrol.
You should load the image in a seperate movieclip in your first movieclip. When the image is fully loadet, you can specify the size of the movieclip with its normal properties. Your code could look like this:
function loadImage(file, name, depth, width, height){ var img = this.createEmptyMovieClip(name, depth); img.loadMovie(file); var handler = new Object(); handler.onEnterFrame = function(){ if(img.getBytesLoaded() == img.getBytesTotal() && img.getBytesTotal() > 0){ img._width = width; img._height = height; delete this; } } }
Then you can use this function in your movieclip like in this example:
I do not want to use so much code. My aim is to hit a button and load the image in a movieclip such that the image size should not be bigger than the mc size: on (release) { _root.picture.loadMovie("myimage.jpg"); } Unless otherwise Thanks for your effort:
I do not want to use so much code. My aim is to hit a button and load the image in a movieclip such that the image size should not be bigger than the mc size: on (release) { _root.picture.loadMovie("myimage.jpg"); } Unless otherwise Thanks for your effort:
Of cause you can't just use loadMovie("myimage.jpg"); - that's the problem... loadMovie() can't do it all for you, thats why you should define your own method that does what you want - that's the point in programming!
Escuse me saying this - but I just can't see why you changed your mind, just because the solution is a few lines of code....
Even if I use the suggested code, the image size does not change at all. If I call the method as: loadImage("landscape.jpg", "myImg", 1, 100, 50); gives the original image size. I use the code in the on release() {.....} statement of a button. Thanks for your reply
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.