Changing properties of a loaded movie onPress

i have set up a variable that is called picsize

when it is set to 0 i want the picture to have certain attributes like


with (container) {
	loadMovie("flowers.jpg");
	_x = 225;
	_y = -46;
	_xscale = 25;
	_yscale = 25;
	_visible = false;
}

and then when it is set to 1 i want it to have other attributes like


with (container) {
	loadMovie("flowers.jpg");
	_x = 20;
	_y = 20;
	_xscale = 100;
	_yscale = 100;
	_visible = false;
}

i need to have a button that says click to zoom (which i can do) and that button will set the variable to 1 or 0

it’d be even nicer if the loaded image scaled on the press of that button instead of just snapping to those properties

any help in this is greatly appreciated

thanks

Why not just use an if statement?

[AS]if (picsize == 0){
with (container) {
loadMovie(“flowers.jpg”);
_x = 225;
_y = -46;
_xscale = 25;
_yscale = 25;
_visible = false;
}
} else if (picsize == 1) {
with (container) {
loadMovie(“flowers.jpg”);
_x = 20;
_y = 20;
_xscale = 100;
_yscale = 100;
_visible = false;
}
}[/AS]

i want to try to figure out how to make it bigger and smaller with easing … instead of just snapping … that’s be great

but about the button that i said i could make … i apparently can’t

i made an mc that has two frames in it … frame 1 says zoom in frame 2 says zoom out … and here’s the script i put on the movieclip


on (press) {
	if (_root.picsize = 0) {
		_root.picsize = 1;
		this.zoomer.gotoAndStop(2);
	}
	if (_root.picsize = 1) {
		_root.picsize = 0;
		this.zoomer.gotoAndStop(1);
	}
}

but it’s not working

fla file is here http://www.aaronsleeper.com/site.fla

path to the thing i’m working on is _root.window.content.techtext

Problem 1) your if statments are a bit wrong. if (_root.picsize = 0) should be if (_root.picsize <B>==</B> 0).

= sets a value to something
== checks to see if the value is equal to something. returns a boolean value of true or false.

Nextup… You are looking for a variable called picsize, that is defined on the _root. I personally couldn’t find that variable, and the variable needs to be defined to be checked.

Since you are using a movie clip for a button you can define the variable inside the button.

[AS]onClipEvent(load){
picsize = 0;
}[/AS]

And then in the rest of the script you could change _root.picsize to just picsize.

And lastly, your targeting is wrong. You target as this.zoomer, but then that is looking for a clip called zoomer that is INSIDE of your movieclip button. Instead it should just be this.gotoAndStop(1).

That leaves us with…
[AS]onClipEvent (load) {
picsize = 0;
}
on (press) {
if (picsize == 0) {
this.gotoAndStop(2);
picsize = 1;
} else if (picsize == 1) {
this.gotoAndStop(1);
picsize = 0;
}
}[/AS]

As for easing. Check the easing the tutorials on this site. Although those tutorials are for easing motion, you can change the property to _width and _height or _xscale and _yscale and it will work.

Just make sure the endX and endY variables are the final width and height you want your clip to be (you may understand if you read the tutorials)

_root timeline, actions layer, frame 40
that’s where i have all my variables stored

i’ve made the changes but it’s not working
i guess the script on _root.window.content.techtext (Layer: preview, Frame: 2) isn’t noticing the changes

the file is still at http://www.aaronsleeper.com/site.fla

here’s the script incase you don’t want to download the file


this.createEmptyMovieClip("preloader", 1000);
this.createEmptyMovieClip("container", 1001);

if (_root.picsize == 0){
        with (container) {
				unloadMovie (_root.picture);
                loadMovie(_root.picture);
                _x = 225;
                _y = -46;
                _xscale = 25;
                _yscale = 25;
                _visible = false;
        }
if (_root.picsize == 1) {
        with (container) {
				unloadMovie (_root.picture);
                loadMovie(_root.picture);
                _x = 20;
                _y = 20;
                _xscale = 100;
                _yscale = 100;
                _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;
    }
}

as for the easing, i’ve read and understand (i think) those tutorials but i don’t understand how to apply them to this funciton that checks for a 0 or 1 value and then performs an action based on that value :frowning:

i can’t figure out how to get the scaling thing to work so i can apply it to the mc

here’s an example i made in hopes of understanding how to do this … then i have to figure out how to apply it to my movie =)

Try this… :wink:

how do i move it too … b/c when it scales, it does so from the center and then it will scale outside the bounds of the move so i will need to move it to different x, y coords … can i put those in the function too?

i’m going to go try to apply this to my container clip so it will scale the loaded graphic using the bottom right corner as it’s anchor point

lostinbeta = genius at work =)

ok so here’s how i tried to apply it to the container which holds the loaded jpg


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;
	}
}

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

but the lil hand doesn’t even come up when you mouseOver the jpg :frowning:

::cries from exhaustion::

I will see what I can do later, I have to go right now, and I still have to work on this other thing I am doing.

i’m sorry to take up so much of your time beta … i really don’t mean to be a burden

i’ve started a new thread to get some new talent on this problem … so you don’t feel obligated to post

if you do get some free time your help and input is always appreciated

the thread is here http://www.kirupaforum.com/forums/showthread.php?s=&postid=150159#post150159

thanks beta

It’s not your fault, it is my fault because I procrastinate a lot and then I have all this stuff to do at once and it’s like AHHHHH.

I really should learn from my mistakes, BUT I DON’T!..lol.