flash actionscript:
You have to wait until the jpeg is loaded to apply the onRelease handler or it gets removed. The alternative is to load the jpeg into a clip holder that is inside another clip holder and apply the onRelease to the parent. If you do that, it is not necessary for the jpeg to load to apply the handler.
To speed you along, here's some code you might find usefull... thumbnail.createEmptyMovieClip("mContainer", thumbnail.getNextHighestDepth()); thumbnail.mContainer.loadMovie ("images/image1.jpg"); thumbnail._xscale = thumbnail._yscale = 25; thumbnail.onRelease = function(){ // do stuff --- this._xscale = this._yscale = 100; } Furthermore, you do not have to load the image again - or rather, more likely than not, it won't be loaded twice as it's already in the users caceh. It's only developers like us that have internet settings set to renew files on every visit to the page, most simply reuse items from their cahce. So - loading it again should be almost instantanious - if you want to load the image in a pop-up window in 100% - feel free to do so. // K?re
[quoted text, click to view] > To speed you along, here's some code you might find usefull...
That's more likely to hinder than help i'm afraid. You need to check the image has fully loaded using getBytesLoaded() and getBytesTotal() *before* changing it's scale or applying any event handlers, or else these will be overwritten once the image does load. -- ------------------------------- Remove '_spamkiller_' to mail -------------------------------
Actually, as I mentioned, if you load the image into a movie clip holder and apply the onRelease to the parent, as Kaare did, I do believe the onRelease will be remembered. It is the child clip that reinstantiates itself - not the parent.
[quoted text, click to view] > Actually, as I mentioned, if you load the image into a movie clip holder and > apply the onRelease to the parent, as Kaare did, I do believe the onRelease > will be remembered. It is the child clip that reinstantiates itself - not > the parent.
Oops - yes, you're right. My mistake - I didn't read Kaare's post closely enough, sorry. -- ------------------------------- Remove '_spamkiller_' to mail -------------------------------
That's okay. How many times have I disagreed with you and been right? Maybe twice in five years?
lol. fair enough ;) Have a good weekend... -- ------------------------------- Remove '_spamkiller_' to mail -------------------------------
Guys I have posted many thread all around the web and found luckily the solution of loading external images and then resizing them but now I have another problem that is, How to click that externally loaded image to enlarge it? loadMovie ("images/image1.jpg", thumbnail); thumbnail._xscale = 25; thumbnail._yscale = 25; I have loaded the image in "thumbnail" movieclip, now how am I gona click this? And one more thing, after loading it once I don't want to load it again to show as enlarged image !!! Please help I am desperate !!! Regards,
Kaare, I don't know how am I gona thank you ...... I really really appreciate that..... Thanks a lot a lot a lot ...
Kaare, I don't know how am I gona thank you ...... I really really appreciate that..... Thanks a lot a lot a lot ...
Sorry, men... But... If i'd like to see only one full-sized image on your site? In this case i also have to download all the full-sized images? I think i'm not the only one who don't need this... Maby i'm wrong?
Hey Guyz, Kaare! I've tried this but this also not working: thumbnail.createEmptyMovieClip("myContainer", thumbnail.getNextHighestDepth()); thumbnail.myContainer.loadMovie("images/hotels/varadero/paradisus/largeImage01.j pg"); thumbnail._xscale = thumbnail._yscale=22; // Show Preview. thumbnail.onRelease = function() { duplicateMovieClip(thumbnail, "preview", thumbnail.getNextHighestDepth()); preview._x = 279.4; preview._y = 63.5; preview._xscale = preview._yscale=100; }; Sorry to bug you people again and again but I need help again.
XmenFlash ? personally I love the MovieClipLoader class as well, but I have found that certain things like _width and _height aren't available onLoadComplete and generally it is better to wait for onLoadInit. Just my experience, your mileage may vary. shahgillani ? when you duplicateMovieClip any dynamic content is not duplicated. Is that the part that isn't working?
You're right Rothrock... so what do you refer, what do I do ? and How ? coz I know very little about Actionscript .... Please help me out I shall be grateful Hassan
Hi again, Well, first off ... duplicating a MovieClip does just that - duplicates the MovieClip. But, it is the original object that is being duplicated, not the instance. Hence duplicateMovieClip and attachMovie work similarly - a new instance is being created. Any changes applied to the original is not reapplied to the new instance. This include images (or swfs or whatever) loaded into (no matter how deep) the clip that is being duplicated, and also properties such as scale etc. Only original artwork in a clip can be duplicated. Maybe MM should fix this, I know I'd like them to, but that's how it works for now. Then I might actually use duplicateMovieClip again, which I haven't for ages... So, you cannot duplicate the movieclip as you tried to, or what's tried to in XmenFlash's example, sorry, would've been great though. What I propose is, you simply load the image as before, and on click load it again - it's already in your users cache. Btw. XmenFlash and Rothrock, I believe the MovieClipLoader may be a bit overkill here, as we don't really need to know when the image is loaded - it's a simple imageviewer... Apply the changes and methods once in the init, and leave it be. No need to add too much clutter - especially if we have to load the image twice and create another mcl. A simple loadMovie call should be sufficient, wouldn't you say? This should do it: thumbnail.createEmptyMovieClip("mThumb", thumbnail.getNextHighestDepth()); thumbnail.mThumb.createEmptyMovieClip("mContainer", 1); thumbnail.mThumb.mContainer.loadMovie("images/hotels/varadero/paradisus/largeIma ge01.jpg"); thumbnail.mThumb._xscale = thumbnail.mThumb._yscale=22; // Show Preview. thumbnail.onRelease = function() { var mc = this.createEmptyMovieClip("mPreview", this.getNextHighestDepth()); mc._x = 279.4; mc._y = 63.5; mc.loadMovie("images/hotels/varadero/paradisus/largeImage01.jpg"); }; Notice I've added another depth to the MovieClip chain. This is to retain the scope, x and y values and to be able to use the original scale, which off course is 100%. Within the thumbnail mc, you now have mThumb which is being scaled and contains the mContainer to load the image. Furthermore, a generic mPreview is being created if needed, within thumbnail also. Both clips have same x and y coordinate system calculated from the thumbnail clip's (0,0). A final not is though, that I quite agree with Clown-Z. It would make good sense to have 2 images per image, a thumbnail and a large one. Otherwise you force the user to load quite a lot of extra bytes that are only needed if the user actually want to see all images... You could still use the functionality above, but then it may be a good idea to add a visual preloader for the large image. And - then you might want to (or I might to ;) reconsider using the MovieClipLoader as mentioned ... it all depends on how much work you want to put into it I guess... Anyways, happy flashin' once again :) // K?re
yeah Rothrock, I too agree with your point on onLoadInit. check this code and let me know u'r progress shah =========================================================== var mcl:MovieClipLoader = new MovieClipLoader (); var mobj:Object = new Object (); mobj.onLoadInit = function () { thumbnail._xscale = thumbnail._yscale=22; thumbnail.onRelease = function () { duplicateMovieClip (thumbnail, "preview", thumbnail.getNextHighestDepth ()); preview._x = 279.4; preview._y = 63.5; preview._xscale = preview._yscale=100; }; }; mcl.addListener (mobj); mcl.loadClip ("images/hotels/varadero/paradisus/largeImage01.jpg", thumbnail.myContainer);
duplicateMovieClip has plenty of good uses, but it has its limitations as well. You just have to know what they are. It is especially limited with dynamically loaded content and not as much with attachMovie. I'm sure that if duplicateMovieClip copied all the code, etc. We would be answering questions about how to remove the code. :) Yeah it could work, but I wouldn't definatively say not to use MovieClipLoader. First it is good to get in the habit of pre-loading all your dynamic images. If not for the practice at least for the possiblity that you will at somepoint run into an important situation with dial-up. I also have seen problems where IE cache isn't as instantaneous as you might expect and it has caouse problems. I don't think you need to make another MCL to load another image. I use the same one to load many different images.
That's absolutely true - we probably would see quite a lot of questions about removing originally applied changes and methods... and since we have the initObject available in the MovieClip version of duplicateMovieClip, it is quite easy to pass along paramters (through usage of a for-in loop in creating the object or similarly). Anyways, the general subject here is, which is quite annoying, that you have to load an external image twice (or several times) to use it more than once. I know it's not good to rely on the users cache, but that's kind of what MM has left us with... And you're also correct in the matter that it's always best practice to preload external data of any kind. So if you're up to it shahgilliani, please do use the MovieClipLoader - or if you're not exporting for FP7, then at least it's earlier counterparts - for loading the image both times. And, consider having a thumbnail image and a large copy to ease the users necessarry load - it's quite easy to set up batch processes to do that for you in Photoshop for example.
Hi there ! XmenFlash, Kaare, Rothrock thank you very very very much for your time, I really really really appreciate that !!! Sorry guys for my late reply, but I was having problems opening this forum, coz it sometimes take too long to open, during that my session I guess expire so the page never opened. So, .... XmenFlash It loads the image in the thumbnail but no loading it to the preview mc. Kaare I am very happy that you're helping me out, to tell you what, I also have an account at www.flashkit.com, as you've already known, is the largest flash portal on the web and has more than 500 thousand users but users there don't reply that easy, I sometimes get very disappointed. Rothrock Thank you too Guys! You all have a different opinion about my thread so I am giving you my file of gallery, you can test it according to you expertise if you like and let me know. Please http://www21.brinkster.com/hassanshah/HotelGallery.fla here! Many Thanks once again !
Hi Shah, I've been a bit preoccupied these last days, so I haven't really had the time to look at your file, but just did so now. Anyways, I've quickly scethed out a simple imageviewer for you. Since you already have both thumbnail and preview MovieClips on stage, I'll simply use those. The code I've written is quite easy for you to alter; to add preloaders and such. Also, i've added functionality for a next_bn and prev_bn - which I'm guessing you'll have ... Looki here. // code start var sImgPath:String = "images/hotels/varadero/paradisus/"; // contains names of your images: var aImageNames:Array = ["largeImage01", "largeImage02", "largeImage03", "largeImage04"]; var iCurrentImage:Number = 0; var mcl:MovieClipLoader = new MovieClipLoader(); var oListener:Object = new Object(); mcl.addListener(oListener); function loadLargeImage():Void{ var sImg = getImagePath(); mcl.loadClip(sImg, preview); //preloader functionality } function loadNextImage(iNextNum:Number):Void{ iCurrentImage = getNextImageNum(iNextNum); var sImg = getImagePath(); mcl.loadClip(sImg, thumbnail.mContainer); //preloader functionality } function getImagePath():String{ var sImg = sImgPath+aImageNames[iCurrentImage]+".jpg"; return sImg; } function getNextImageNum(iNum:Number):Number{ if(iNum<0){ return (aImageNames.length-1); } else if(iNum>=aImageNames.length){ return 0; } return iNum; } next_bn.onRelease = function(){ loadNextImage(++iCurrentImage); } prew_bn.onRelease = function(){ loadNextImage(--iCurrentImage); } var mContainer = thumbnail.createEmptyMovieClip("mContainer", thumbnail.getNextHighestDepth()); thumbnail._xscale = thumbnail._yscale=22; thumbnail.onRelease = loadLargeImage; loadNextImage(iCurrentImage); // code end That should give you something to work with, and it's pretty easy to alter into an AS 2.0 class as well. // K?re
Had to edit it real quick, because if you do not check "don't parse emoticons" you end up with this line in the middle: var oListener:object = new Object();
I don't know how am I gona thank you Kaare ..... that's it, I have done it at last it is working now.
Don't see what you're looking for? Try a search.
|