Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Controlling an masked photo with actionscript 1

Status
Not open for further replies.

Kirderf

Technical User
Oct 4, 2000
183
US
Here is a crazy problem .

In a movie clip named "mask" I have a long, horizontal photo which I have masked with a shorter rectangle shaped mask.
I have named the photo "move". (It is a movie clip inside the movie clip, "mask".)

On the main timeline I want to move the photo from left to right using buttons, while keeping the masked area from moving.

I am trying to use the setvariable commands, but I am doing something wrong.

I have many stars to give for this one!

Thanks,
Kirderf I'd gladly pay you on Thursday
for a hamburger today!
 
make the photo a movie clip if its not already then to the clip

onClipEvent (enterFrame) {
if (_x>640+_width) { // if 640 is movie width......alter this at will//
_x = 0-_width;
}
_x += 2; //control the speed with this variable
updateAfterEvent();
}
 
Oh! Another precious script!
But a very bad use of an onEnterFrame event. That (those) clips will be looping for ever, putting unnecessary stress on the processor. Regards,

oldman3.gif
 
what is your problem ?

the script will do exactly what was asked for....and if Kirdef decides only to have one pass of the photo the code is very easily altered.
 
I've added the on clip event code,
but the picture keeps scrolling off the page
no matter what numbers I change.
The speed seems to be the same as well.

Could you check this out to see what I mean.

You need to click through to feed the machine and then go to the examples page to see what I mean.

It is still rough around the edges, but its in progress.

Thanks,
I'd gladly pay you on Thursday
for a hamburger today!
 
I would like to be able to control it with buttons, but i havent gotten to that step yet. I'll study the "On Clip event" commands more to understand them. I was trying to do this with a "setvariable" command and couldnt do a thing.

At least we are moving it. I'd gladly pay you on Thursday
for a hamburger today!
 
this will only show it once with photo starting at x=0

OnClipEvent (enterFrame) {
if (this._x<500) { // if 500 is photo width......alter this at will//
this._x += 2;
}
updateAfterEvent();
}

Do you want it to loop?
 
Bill your syntax!

Small &quot;o&quot; for &quot;OnClipEvent&quot;.

May I suggest you add my trace, just to demonstrate this &quot;bad&quot; use of the &quot;enterframe&quot; event. Even when stopped, the mc is still looping unnecessarily!

onClipEvent (enterFrame) {
trace (&quot;Yo! I'm still looping: &quot;+count++);
if (this._x<500) { // if 500 is photo width......alter this at will//
this._x += 2;
}
updateAfterEvent();
} Regards,

oldman3.gif


Don't worry, if my reply is wrong, BillWatson will clean it up for me!
 
got a better suggestion Oldnewbie appears to think this is his personal forum. His replys are gospel...he knows it all.
 
For a better way of using an enterFrame event, yes! But I'll keep it stored in an include .as file, carefully hidden in my brain.

You're not willing to share your precious code, why should I share mine with you?

CLUE: I'm not saying that your inside code is bad, but only that it's a bad pratice to leave a mc looping on enterFrame events, once those event checks are no longer needed.

Finally, I don't consider this as my personal forum. Just don't like to be overposted by young &quot;studs&quot; with sloppy syntax, and who, on top of that, have no sense of humour whatsoever!

Regards,

oldman3.gif


Don't worry, if my reply is wrong, BillWatson will clean it up for me!
 
Yes, the photo clip is inside a clip.
I think it is a path problem. I would like to control the masked photo from the root timeline using left and right buttons.
I have tried to use setvariables and move the photo with the premise that &quot;mask.photo._x = _xmouse;&quot; might allow me to move the photo with the mouse. Don't work.
I am trying to learn, so my approach is to make it simple at first..then try the tough stuff.


The tough stuff would be: to be able to zoom in and out as well as pan from left to right.
Right now, i'd be happy with just controlling the photo from left to right with navigation buttons.

Thanks for your help. I'd gladly pay you on Thursday
for a hamburger today!
 
much easier

on (release){
photo._x+=10; //add path and set number to suit
}

-=10 for other button Oldnewbie appears to think this is his personal forum. His replys are gospel...he knows it all.
 
Excellent! This is what works.

on (release) {
mask.photo._x += -10;
}

How to get the photo to stop at its width of 136.
I'd gladly pay you on Thursday
for a hamburger today!
 
on (release) {
if (mask.photo._x<136){
mask.photo._x += -10;
}
}

and for other button check for zero

136 is awkward for jumps of 10 maybe better to add another statemnet to make it only jump 2 or 3 from 130 and of course no jump after 136 or before 0
Oldnewbie appears to think this is his personal forum. His replys are gospel...he knows it all.
 
This works for the left button.

on (release) {
if (mask.photo._x > 1) {
mask.photo._x += -9;
}
}

Great! so if I wanted to zoom the photo out and in using the same concept I would need two new buttons but some variable other than x and y. Maybe a scale command? I'd gladly pay you on Thursday
for a hamburger today!
 
not realy...zooming in and out is actually much harder to achieve. Getting the math right can be tricky. There is a map zoomer I think (haven't checked yet but remember seeing one) at Macromedia exchange. That might do. Otherwise its a question of resetting the origin away from the top left corner into the centre of the section of the photograph that you have under the mask before you can apply a scaling function.
Your case is more difficult in that only a section of the image can be available for zooming at any particular time. Oldnewbie appears to think this is his personal forum. His replys are gospel...he knows it all.
 
just came across this.....have a look..may be just what you are seeking....movement and a built in zoom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top