James
Tue, 09 Feb 2010 16:44:01 -0800
Thank you very much Steve. That work's perfectly now. I never realised it would be that easy. I'm quite inexperienced when it comes to coding. If it's anything more than click="change something or other" then it's beyond me at times ha. Just on another note. These images I'm trying to make in my final app will act as links to the sites in question within 9 different categories each with a few sites and the html window will be made non visible. I want to decrease loading times of the html window and the app itself as much as possible. If I use the same code for each categrory by using a html window for each categrory each loading images the way this one does would that take up too much loading time do you think especially on lower internet connections or would it be okay? Also is there any way of making the html components load faster in any way perhaps by making them load a low res version of some sort? Basically I'm looking for ideas to make this aspect of the application as quick in it's loading times as possible. --- In flexcoders@yahoogroups.com, "valdhor" <valdhorli...@...> wrote: > > Your code seems a little roundabout for me. I have rewritten it but the > functionality is still the same (And it works as you want)... > > <?xml version="1.0" encoding="utf-8"?> > <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical" verticalAlign="middle" backgroundColor="white" > width="1024" height="768"> > <mx:Script> > <![CDATA[ > import mx.graphics.ImageSnapshot; > > private function takeSnapshot(event:Event):void > { > var imageBitmapData:BitmapData = > ImageSnapshot.captureBitmapData(myhtml); > switch(myhtml.location) > { > case "http://abcnews.go.com/": > abcnewsimage.source = new > Bitmap(imageBitmapData); > myhtml.location = "http://news.yahoo.com/"; > break; > case "http://news.yahoo.com/": > yahoonewsimage.source = new > Bitmap(imageBitmapData); > myhtml.location = "http://news.google.com/"; > break; > case "http://news.google.com/": > googlenewsimage.source = new > Bitmap(imageBitmapData); > break; > } > } > ]]> > </mx:Script> > <mx:HBox> > <mx:Image id="abcnewsimage" width="100" height="100"/> > <mx:Image id="googlenewsimage" width="100" height="100"/> > <mx:Image id="yahoonewsimage" width="100" height="100"/> > </mx:HBox> > <mx:HTML id="myhtml" location="http://abcnews.com/" > complete="takeSnapshot(event)" > width="100%" height="100%" /> > </mx:WindowedApplication> > > > > HTH > > > > Steve > > > --- In flexcoders@yahoogroups.com, "James" <garymoorcroft_ict@> > wrote: > > > > At the moment I have an app which I can only describe as something > that generates thumbnails of html pages (or at least it is meant to). > The way this is achieved is by using a html component. Upon event > complete of this component I have a function which creates a snapshot of > the html component and makes it the source of an image there fore making > that image a thumbnail of that particular site. > > > > > > I then want it to do the same for further sites but obviously using > multiple hmtl components would be out of the question as it would > greatly increase loading times (I've tried and it slows the application > down majorly) so what I'm trying to do is set the 'complete' property of > the 1 html component I've got so that when the first site is loaded i.e. > event complete of the html component has been reached a snapshot of that > site will be created and made as the source of my first thumbnail and > then the location of the html component will change to the next site, a > snapshot of that site will then be made upon event complete of the > component and will be made the source of my second thumbnail and so on > and so forth. > > > > > > I'm struggling to get this to work effectively but I think I'm going > along the right lines. Here's my code so far. Can anyone please tell me > how I can edit it so that this effect is achieved in a row the way I > have described:- > > > > <?xml version="1.0" encoding="utf-8"?> > > <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical" verticalAlign="middle" backgroundColor="white" > width="1024" height="768"> > > > > <mx:Script> > > <![CDATA[ > > import mx.graphics.ImageSnapshot; > > > > private function > takeabcnewsSnapshot(abcnewssource:IBitmapDrawable):void { > > var abcnewsimageBitmapData:BitmapData = > ImageSnapshot.captureBitmapData(abcnewssource); > > abcnewsimage.source = new > Bitmap(abcnewsimageBitmapData); > > } > > > > private function > takegooglenewsSnapshot(googlenewssource:IBitmapDrawable):void { > > var googlenewsimageBitmapData:BitmapData = > ImageSnapshot.captureBitmapData(googlenewssource); > > googlenewsimage.source = new > Bitmap(googlenewsimageBitmapData); > > } > > > > private function > takeyahoonewsSnapshot(yahoonewssource:IBitmapDrawable):void { > > var yahoonewsimageBitmapData:BitmapData = > ImageSnapshot.captureBitmapData(yahoonewssource); > > yahoonewsimage.source = new > Bitmap(yahoonewsimageBitmapData); > > } > > > > private function abcnewshtml_complete(evt:Event):void { > > takeabcnewsSnapshot(myhtml); > > } > > > > private function googlenewshtml_complete(evt:Event):void { > > takegooglenewsSnapshot(myhtml); > > } > > > > private function yahoonewshtml_complete(evt:Event):void { > > takeyahoonewsSnapshot(myhtml); > > } > > > > ]]> > > </mx:Script> > > <mx:Image id="abcnewsimage" width="100" height="100"/> > > <mx:Image id="googlenewsimage" width="100" height="100"/> > > <mx:Image id="yahoonewsimage" width="100" height="100"/> > > > > <mx:HTML id="myhtml" > > location="http://abcnews.com/" > > complete="abcnewshtml_complete(event); > myhtml.location='http://news.yahoo.com/'; yahoonewshtml_complete(event); > myhtml.location='http://news.google.com/'; > googlenewshtml_complete(event)" > > width="100%" > > height="454" /> > > > > </mx:WindowedApplication> > > >