Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 08-27-2003, 09:44 AM   #1
headkick
Registered User
 
headkick's Avatar
 
Join Date: Apr 2003
Location: washington dc
Posts: 54
Default laod and grow as sub problem

Thought I had worked this all out but another question has popped up.

I am using the following code from Jesse to do a load and grow function for a library of photos. It works fine on the main stage, but I need this to work as a sub-menu. The grow function works as a sub, but the image is not showing up.



ActionScript Code:
// Actions for buttons btn1_btn.onRelease = function() {     loadThenGrow("photos/02_ph_2nudes.jpg"); }; btn2_btn.onRelease = function() {     loadThenGrow("photos/02_COL_edinburgh.jpg"); }; // LoadTheGrow function takes a target image name. // Targets are hard-coded for the moment because I'm lazy function loadThenGrow(img) {     bg_square_mc._parent.holder_mc.removeMovieClip();     bg_square_mc._parent.createEmptyMovieClip("holder_mc", 1);     bg_square_mc._parent.holder_mc._visible = false;     bg_square_mc._parent.holder_mc.onData = function() {         if (this.getBytesLoaded() == this.getBytesTotal()) {             this._visible = false;             // Image fully loaded, grab dimensions and resize             // background clip             w = this._width;             h = this._height;             bg_square_mc.growTo(w+1, h+1, 10, _root.showHolder);         }     };     bg_square_mc._parent.holder_mc.loadMovie(img); } function showHolder() {     w = bg_square_mc._parent.holder_mc._width;     h = bg_square_mc._parent.holder_mc._height;     bg_square_mc._parent.holder_mc._x = bg_square_mc._x-w/2;     bg_square_mc._parent.holder_mc._y = bg_square_mc._y-h/2;     bg_square_mc._parent.holder_mc._visible = true;     bg_square_mc._parent.holder_mc._alpha = 50;         trace ("Image resized");         bg_square_mc._parent.holder_mc.fadeTo(5, _root.doneHolder);         } MovieClip.prototype.fadeTo = function(fadeRate, callback) {         if ((fadeRate == undefined) or (fadeRate<=0)) {                 fadeRate = 10;         }         if (!this.fading) {                 this.fading = true;                 this.fadeInterval = setInterval(this, "doFadeTo", 60, fadeRate, callback);         } }; MovieClip.prototype.doFadeTo = function(fadeRate, callback) {         if (this._alpha > 100) {                                 clearInterval(this.fadeInterval);                 this.fading = false;                 if (callback) {                         callback();                 }         } else {                 this._alpha += fadeRate;         } };

This is the grow function:

ActionScript Code:
// MovieClip growTo Proto v1 by Jesse Stratford // [email][email protected][/email] // You may use this script as you wish provded these comments remain // Arguments: //    w - target width //    h - target height //    growRate - higher = slower //    callback -    funtion to call when growing is complete MovieClip.prototype.growTo = function(w, h, growRate, callback) {     // If the grow rate is undefined or invalid, set it     if ((growRate == undefined) or (growRate<=0)) {         growRate = 10;     }     // Only grow if currently not growing     if (!this.growing) {         this.growing = true;         // Call doGrowTo at regular intervals (change the '60' below if you wish)         this.growInterval = setInterval(this, "doGrowTo", 10, w, h, growRate, callback);     } else {         // already growing, don't start again.         // might want to indicate some sort of error here     } }; MovieClip.prototype.doGrowTo = function(w, h, growRate, callback) {     // Get the current width and heigh of the clip     wDiff = w-this._width;     hDiff = h-this._height;     // Inertia resize workaround. If we're within 2 pixels, snap to size.     if (Math.abs(wDiff)<2 && Math.abs(hDiff)<2) {         this._width = w;         this._height = h;         // Stop the grow interval (save CPU)         clearInterval(this.growInterval);         // Reset growing variable         this.growing = false;         // Call function if one was passed         if (callback) {             callback();         }     } else {         // Keep growing if we haven't reached our target size.         this._width += wDiff/growRate;         this._height += hDiff/growRate;     } };


Again everything here works fine on the main stage level (1). But it does not show the photo when used as a sub-menu. Any suggestions?

Thanks in advance.
headkick is offline   Reply With Quote
Old 08-27-2003, 10:02 AM   #2
headkick
Registered User
 
headkick's Avatar
 
Join Date: Apr 2003
Location: washington dc
Posts: 54
Default also

Thought I should include this. The original script for this by Jesse is located:

http://www.actionscripts.org/showMovie.php?id=754

It contains a zipped fla to view how it works. Basically I am doing the same thing but as a sub menu with an alpha.


D
headkick is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:39 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.