Att: geniuses .. please help me figure out why this code doesn't work

this code is on a frame inside an MC i have and it performs the loadMovie fine as well as the preloader but when i try to apply an onPress function to the container clip with the loaded movie (jpg) in it … it doesn’t work. the lil hand doesn’t come up and the actions in the onPress script are not performed

any assistance is greatly appreciated

thanks


this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 1001);
     with (container) {
                loadMovie(_root.picture);
                _x = 225;
                _y = -46;
                _xscale = 25;
                _yscale = 25;
                _visible = false;
        }

preloader.onEnterFrame = function() {
    var l = container.getBytesLoaded();
    var t = container.getBytesTotal();
    var getPercent = l/t;
    loadText = Math.round(getPercent*100)+"%";
    loadBar._width = getPercent*160.5;
    if (l>0 && l>=t) {
        container._visible = 1;
		delete loadText;
		loadBar._visible = 0;
        delete this.onEnterFrame;
    }
}

MovieClip.prototype.scale = function(finX, finY) {
	this.speed = 5;
	this.endX = finX;
	this.endY = finY;
	this.onEnterFrame = function() {
		this._xscale += (this.endX-this._xscale)/this.speed;
		this._yscale += (this.endY-this._yscale)/this.speed;
	}
}


container.onPress = function() {
	if (_root.picsize == 0) {
		scale(25, 25);
		_root.picsize = 1;
	} else if (_root.picsize == 1) {
		scale(100, 100);
		_root.picsize = 0;
	}
}

you need to assign the onPress handler once the movie/jpg is loaded

try this:

this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 1001);
with (container) {
loadMovie(_root.picture);
_x = 225;
_y = -46;
_xscale = 25;
_yscale = 25;
_visible = false;
}
preloader.onEnterFrame = function() {
var l = container.getBytesLoaded();
var t = container.getBytesTotal();
var getPercent = l/t;
loadText = Math.round(getPercent*100)+"%";
loadBar._width = getPercent*160.5;
if (l>0 && l>=t) {
container._visible = 1;
delete loadText;
loadBar._visible = 0;
container.onPress = function() {
if (_root.picsize == 0) {
scale(25, 25);
_root.picsize = 1;
} else if (_root.picsize == 1) {
scale(100, 100);
_root.picsize = 0;
}
}
delete this.onEnterFrame;
}
}
MovieClip.prototype.scale = function(finX, finY) {
this.speed = 5;
this.endX = finX;
this.endY = finY;
this.onEnterFrame = function() {
this._xscale += (this.endX-this._xscale)/this.speed;
this._yscale += (this.endY-this._yscale)/this.speed;
}
}

=)

sweet … it works … now i just gotta edit the function b/c it’s all funky

thank you very much =)

:stuck_out_tongue:

anytime shuga =)

sniffle i can’t figure out how to get the jpg to scale without everything else

http://www.aaronsleeper.com > enter the site > click on the button that says tech > click the first button on the left … a pic of flowers will pop up in the bottom right > click that pic and see everything scale

i just want the picture to scale

http://www.aaronsleeper.com/site.fla

the path to where all this is going on in the fla file is _root.window.content.techtext (images layer, frame 2)

thanks for your help

--------------edit------------------
ps. i want the image to scale larger … not smaller

and i’m trying to figure out how to get it to move and scale so it doesn’t go out of the screen when it scales larger =)

container.onPress = function() {
if (_root.picsize == 0) {
this.scale(25, 25);
_root.picsize = 1;
} else if (_root.picsize == 1) {
this.scale(100, 100);
_root.picsize = 0;
}
}

:wink:

Try replacing the onPress with this…

[AS]container.onPress = function() {
if (_root.picsize == 0) {
this.scale(25, 25);
_root.picsize = 1;
} else if (_root.picsize == 1) {
this.scale(100, 100);
_root.picsize = 0;
}
};[/AS]

Notice scale(25,25) was changed to <B>this.</B>scale(25, 25); same with the scale(100,100).

Otherwise it scales the clip it is in, which is the techtext, but when you define that <B>this</B> clip should run the scale function, it scales the container clip.

Please note though, then when you load an image into Flash, it connects the upper left corner to the movie clip, so this means it scales from that corner :-\

Haha, you replied while I was typing kax. Shame on you.

you’re so slow my friend… :stuck_out_tongue: :wink:

wow … that’s sweet … alright … so all my loaded jpgs are going to be the same size … so i’d like to figure out how i can move the MC on press along with the scale … so it appears to scale from the bottom right corner … i can find the exact numbers … i just can’t figure out how to add movement to the scaling function

thanks very much for all your help guys =)

*Originally posted by kax *
**you’re so slow my friend… :stuck_out_tongue: :wink: **

Sorry for explaining why I did what I did.

Sen stealer :scream:

HAHAHA… :stuck_out_tongue:

I gotta go now, feel free to solve the next problem with the ease that I won’t be rushing to get there before you.

Originally posted by lostinbeta
*Please note though, then when you load an image into Flash, it connects the upper left corner to the movie clip, so this means it scales from that corner :-*

true… but doesn’t mean you can’t keep the centre of the jpg at certain position :wink:

ie. if you want to keep the centre at 100,100. you’d need to do something like this:

this._x = 100-(this._width/2);
this._y = 100-(this._height/2);

=)

here’s the script so you don’t have to go search through the code for it =)


MovieClip.prototype.scale = function(finX, finY) {
        this.speed = 5;
        this.endX = finX;
        this.endY = finY;
        this.onEnterFrame = function() {
                this._xscale += (this.endX-this._xscale)/this.speed;
                this._yscale += (this.endY-this._yscale)/this.speed;
        }
}

ps. the center is ok to move it’s the bottom right corner that i want to stay stationary

b/c the pic is loaded in the bottom right corner of the movie and i want it to scale larger so that it appears to be getting bigger towards the upper left corner

:slight_smile:

ok… then just add this lines:

MovieClip.prototype.scale = function(finX, finY) {
this.speed = 5;
this.endX = finX;
this.endY = finY;
this.onEnterFrame = function() {
this._xscale += (this.endX-this._xscale)/this.speed;
this._yscale += (this.endY-this._yscale)/this.speed;
this._x = xcentre-(this._width/2);
this._y = ycentre-(this._height/2);
}
}

again… xcentre and ycentre would be the coordinates where the centre of the jpg should be positioned :wink:

we should stop editing/posting while someone else is posting!! :stuck_out_tongue: :crazy:

but the center is going to move since it is scaled fromt the bottom right towards the top left

i just took out the /2 after the _width and _height

now it works but i have to figure out the proper coordinates =)

thanks again!

i knew how to do that… i was giving you some time to think :stuck_out_tongue: :wink:
… i’m serious =)

and you want the proper coordinates for the bottom right corner?
you can get them adding the width/height to the x/y of the movie clip :wink:

figured that out … http://www.aaronsleeper.com … it works! =)

tear thank you so much … you fuzzy lil geniuses you

no problem man =)

and now that everthing is solved… i should get back to work :sure: :stuck_out_tongue: