Re: [Flashcoders] tracing height
you should look at movieClipLoader ( http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Partsfile=1998.html ) this allows you to add listeners to the loader (in your case, you should use onLoadInit) to fire a method/function On Tue, Jul 8, 2008 at 3:56 PM, Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] wrote: I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tracing height
there's an example of some code if you look at the onLoadInit link http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Partsfile=1998.html On Tue, Jul 8, 2008 at 4:17 PM, allandt bik-elliott (thefieldcomic.com) [EMAIL PROTECTED] wrote: you should look at movieClipLoader ( http://livedocs.adobe.com/flash/9.0/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Partsfile=1998.html ) this allows you to add listeners to the loader (in your case, you should use onLoadInit) to fire a method/function On Tue, Jul 8, 2008 at 3:56 PM, Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] wrote: I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tracing height
- Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 8:56 AM Subject: [Flashcoders] tracing height I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! Hi Theodore, There might be better ways than what I am using, but this works. For each image I create a new movieclip which onEnterFrame resizes the target loadMovie image to a set size, and then removes itself so it doesn't keep working needlessly. This is cut and pasted from a project where images are sourced from XML, so it might have some extraneous ... mrand=Math.round(Math.random()*3000); tname='img'+mrand; _root.createEmptyMovieClip(tname, imagedepth); imagedepth++; _root['img'+mrand].createEmptyMovieClip('md', imagedepth); _root['img'+mrand].md.loadMovie(images.childNodes[i].attributes['imgloc']); _root['img'+mrand]._x=images.childNodes[i].attributes['x']; _root['img'+mrand]._y=images.childNodes[i].attributes['y']; trace(images.childNodes[i].attributes['imgloc']); // image sizer mrand=Math.round(Math.random()*3000); sizer=tname+'sizer'+mrand; imagedepth++; _root.createEmptyMovieClip(sizer, imagedepth); imagedepth++; _root[sizer].pushw=images.childNodes[i].attributes['w']; _root[sizer].pushh=images.childNodes[i].attributes['h']; _root[sizer].clipname=tname; //trace(images.childNodes[i].attributes['w']); _root[sizer].onEnterFrame=function(){ trace(this.clipname + ' ' + this.pushw + ' ' + this.pushh); _root[this.clipname]._width=this.pushw; _root[this.clipname]._height=this.pushh; //trace(this.clipname); // img0sizer if(!init){ init=1; } if((this.pushw)(this.pushh)(init30)){ // counts to 30 frames and quits, should be enough this.removeMovieClip(); } init++; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
RE: [Flashcoders] tracing height
Ok - so I have tried the following: this.createEmptyMovieClip(img_mc, 999); var my_mcl:MovieClipLoader = new MovieClipLoader(); mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void { trace(onLoadComplete: + target_mc); }; my_mcl.addListener(mclListener); my_mcl.loadClip(http://www.helpexamples.com/flash/images/image1.jpg;, img_mc); and while the clip loads I am not getting a trace... that's really what I need Ted -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabino Travassos Sent: Tuesday, July 08, 2008 11:24 AM To: Flash Coders List Subject: Re: [Flashcoders] tracing height - Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 8:56 AM Subject: [Flashcoders] tracing height I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! Hi Theodore, There might be better ways than what I am using, but this works. For each image I create a new movieclip which onEnterFrame resizes the target loadMovie image to a set size, and then removes itself so it doesn't keep working needlessly. This is cut and pasted from a project where images are sourced from XML, so it might have some extraneous ... mrand=Math.round(Math.random()*3000); tname='img'+mrand; _root.createEmptyMovieClip(tname, imagedepth); imagedepth++; _root['img'+mrand].createEmptyMovieClip('md', imagedepth); _root['img'+mrand].md.loadMovie(images.childNodes[i].attributes['imgloc' ]); _root['img'+mrand]._x=images.childNodes[i].attributes['x']; _root['img'+mrand]._y=images.childNodes[i].attributes['y']; trace(images.childNodes[i].attributes['imgloc']); // image sizer mrand=Math.round(Math.random()*3000); sizer=tname+'sizer'+mrand; imagedepth++; _root.createEmptyMovieClip(sizer, imagedepth); imagedepth++; _root[sizer].pushw=images.childNodes[i].attributes['w']; _root[sizer].pushh=images.childNodes[i].attributes['h']; _root[sizer].clipname=tname; //trace(images.childNodes[i].attributes['w']); _root[sizer].onEnterFrame=function(){ trace(this.clipname + ' ' + this.pushw + ' ' + this.pushh); _root[this.clipname]._width=this.pushw; _root[this.clipname]._height=this.pushh; //trace(this.clipname); // img0sizer if(!init){ init=1; } if((this.pushw)(this.pushh)(init30)){ // counts to 30 frames and quits, should be enough this.removeMovieClip(); } init++; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tracing height
According to the help files you need: var mclListener:Object = new Object(); - Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 1:09 PM Subject: RE: [Flashcoders] tracing height Ok - so I have tried the following: this.createEmptyMovieClip(img_mc, 999); var my_mcl:MovieClipLoader = new MovieClipLoader(); mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void { trace(onLoadComplete: + target_mc); }; my_mcl.addListener(mclListener); my_mcl.loadClip(http://www.helpexamples.com/flash/images/image1.jpg;, img_mc); and while the clip loads I am not getting a trace... that's really what I need Ted -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabino Travassos Sent: Tuesday, July 08, 2008 11:24 AM To: Flash Coders List Subject: Re: [Flashcoders] tracing height - Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 8:56 AM Subject: [Flashcoders] tracing height I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! Hi Theodore, There might be better ways than what I am using, but this works. For each image I create a new movieclip which onEnterFrame resizes the target loadMovie image to a set size, and then removes itself so it doesn't keep working needlessly. This is cut and pasted from a project where images are sourced from XML, so it might have some extraneous ... mrand=Math.round(Math.random()*3000); tname='img'+mrand; _root.createEmptyMovieClip(tname, imagedepth); imagedepth++; _root['img'+mrand].createEmptyMovieClip('md', imagedepth); _root['img'+mrand].md.loadMovie(images.childNodes[i].attributes['imgloc' ]); _root['img'+mrand]._x=images.childNodes[i].attributes['x']; _root['img'+mrand]._y=images.childNodes[i].attributes['y']; trace(images.childNodes[i].attributes['imgloc']); // image sizer mrand=Math.round(Math.random()*3000); sizer=tname+'sizer'+mrand; imagedepth++; _root.createEmptyMovieClip(sizer, imagedepth); imagedepth++; _root[sizer].pushw=images.childNodes[i].attributes['w']; _root[sizer].pushh=images.childNodes[i].attributes['h']; _root[sizer].clipname=tname; //trace(images.childNodes[i].attributes['w']); _root[sizer].onEnterFrame=function(){ trace(this.clipname + ' ' + this.pushw + ' ' + this.pushh); _root[this.clipname]._width=this.pushw; _root[this.clipname]._height=this.pushh; //trace(this.clipname); // img0sizer if(!init){ init=1; } if((this.pushw)(this.pushh)(init30)){ // counts to 30 frames and quits, should be enough this.removeMovieClip(); } init++; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tracing height
On Tue, Jul 8, 2008 at 4:09 PM, Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] wrote: Ok - so I have tried the following: this.createEmptyMovieClip(img_mc, 999); var my_mcl:MovieClipLoader = new MovieClipLoader(); mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void { trace(onLoadComplete: + target_mc); }; my_mcl.addListener(mclListener); my_mcl.loadClip(http://www.helpexamples.com/flash/images/image1.jpg;, img_mc); and while the clip loads I am not getting a trace... that's really what I need Ted -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabino Travassos Sent: Tuesday, July 08, 2008 11:24 AM To: Flash Coders List Subject: Re: [Flashcoders] tracing height - Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 8:56 AM Subject: [Flashcoders] tracing height I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! Hi Theodore, There might be better ways than what I am using, but this works. For each image I create a new movieclip which onEnterFrame resizes the target loadMovie image to a set size, and then removes itself so it doesn't keep working needlessly. This is cut and pasted from a project where images are sourced from XML, so it might have some extraneous ... mrand=Math.round(Math.random()*3000); tname='img'+mrand; _root.createEmptyMovieClip(tname, imagedepth); imagedepth++; _root['img'+mrand].createEmptyMovieClip('md', imagedepth); _root['img'+mrand].md.loadMovie(images.childNodes[i].attributes['imgloc' ]); _root['img'+mrand]._x=images.childNodes[i].attributes['x']; _root['img'+mrand]._y=images.childNodes[i].attributes['y']; trace(images.childNodes[i].attributes['imgloc']); // image sizer mrand=Math.round(Math.random()*3000); sizer=tname+'sizer'+mrand; imagedepth++; _root.createEmptyMovieClip(sizer, imagedepth); imagedepth++; _root[sizer].pushw=images.childNodes[i].attributes['w']; _root[sizer].pushh=images.childNodes[i].attributes['h']; _root[sizer].clipname=tname; //trace(images.childNodes[i].attributes['w']); _root[sizer].onEnterFrame=function(){ trace(this.clipname + ' ' + this.pushw + ' ' + this.pushh); _root[this.clipname]._width=this.pushw; _root[this.clipname]._height=this.pushh; //trace(this.clipname); // img0sizer if(!init){ init=1; } if((this.pushw)(this.pushh)(init30)){ // counts to 30 frames and quits, should be enough this.removeMovieClip(); } init++; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Theodore, you code is almost right, you forgot only create the object that will be used as listener. Before set the onLoadComplete, add a line with: mclListener = {}; And you'll have your working code. I suggest you use onLoadInit instead onLoadComplete, because onLoadInit is dispatched after content was fully loaded and initialized. Gabino, use this code and you'll be able to get the dimensions of your loaded movie as soon image is loaded. Best, -- Fábio Pinatti :: web.developer www.pinatti.com.br :: 19. 9184.3745 / 3342.1130 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tracing height
On Tue, Jul 8, 2008 at 4:43 PM, Gabino Travassos [EMAIL PROTECTED] wrote: According to the help files you need: var mclListener:Object = new Object(); - Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 1:09 PM Subject: RE: [Flashcoders] tracing height Ok - so I have tried the following: this.createEmptyMovieClip(img_mc, 999); var my_mcl:MovieClipLoader = new MovieClipLoader(); mclListener.onLoadComplete = function(target_mc:MovieClip, status:Number):Void { trace(onLoadComplete: + target_mc); }; my_mcl.addListener(mclListener); my_mcl.loadClip(http://www.helpexamples.com/flash/images/image1.jpg;, img_mc); and while the clip loads I am not getting a trace... that's really what I need Ted -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Gabino Travassos Sent: Tuesday, July 08, 2008 11:24 AM To: Flash Coders List Subject: Re: [Flashcoders] tracing height - Original Message - From: Lehr, Theodore M (N-SGIS) [EMAIL PROTECTED] To: Flash Coders List flashcoders@chattyfig.figleaf.com Sent: Tuesday, July 08, 2008 8:56 AM Subject: [Flashcoders] tracing height I have: _root.imageMovie.loadMovie(stepImageArray[0]); sizeImage(); function sizeImage () { trace(_root.imageMovie._height); } But I keep getting 0 I am guessing because the trace is fired before the image is loaded... how can I make sure this function does not fire until the image is loaded. I tried: _root.imageMovie.onLoad = function() { } But that does not seem to fire at all My ultimate goal is to control the size of the image that is being loaded to make sure it is not too big Thanks! Hi Theodore, There might be better ways than what I am using, but this works. For each image I create a new movieclip which onEnterFrame resizes the target loadMovie image to a set size, and then removes itself so it doesn't keep working needlessly. This is cut and pasted from a project where images are sourced from XML, so it might have some extraneous ... mrand=Math.round(Math.random()*3000); tname='img'+mrand; _root.createEmptyMovieClip(tname, imagedepth); imagedepth++; _root['img'+mrand].createEmptyMovieClip('md', imagedepth); _root['img'+mrand].md.loadMovie(images.childNodes[i].attributes['imgloc' ]); _root['img'+mrand]._x=images.childNodes[i].attributes['x']; _root['img'+mrand]._y=images.childNodes[i].attributes['y']; trace(images.childNodes[i].attributes['imgloc']); // image sizer mrand=Math.round(Math.random()*3000); sizer=tname+'sizer'+mrand; imagedepth++; _root.createEmptyMovieClip(sizer, imagedepth); imagedepth++; _root[sizer].pushw=images.childNodes[i].attributes['w']; _root[sizer].pushh=images.childNodes[i].attributes['h']; _root[sizer].clipname=tname; //trace(images.childNodes[i].attributes['w']); _root[sizer].onEnterFrame=function(){ trace(this.clipname + ' ' + this.pushw + ' ' + this.pushh); _root[this.clipname]._width=this.pushw; _root[this.clipname]._height=this.pushh; //trace(this.clipname); // img0sizer if(!init){ init=1; } if((this.pushw)(this.pushh)(init30)){ // counts to 30 frames and quits, should be enough this.removeMovieClip(); } init++; } ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders using {} is a shortcut. Like using [] to create an array. -- Fábio Pinatti :: web.developer www.pinatti.com.br :: 19. 9184.3745 / 3342.1130 ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Re: [Flashcoders] tracing height
snip I suggest you use onLoadInit instead onLoadComplete, because onLoadInit is dispatched after content was fully loaded and initialized. Gabino, use this code and you'll be able to get the dimensions of your loaded movie as soon image is loaded. Best, /snip Fábio, Yeah, that is much better than what I was doing. :) ___ Flashcoders mailing list Flashcoders@chattyfig.figleaf.com http://chattyfig.figleaf.com/mailman/listinfo/flashcoders