2 buttons, one large image, x-axis movement

how to explain?

i have 2 buttons and one large image. this image has about 10 product images inside of the clip.

here is the idea…

i want to click on the move left or move right button, clicking on the button will move the MC containing the Product Images to the left or right.

the thing i am not getting is normally when i move stuff on the X-axis i have more than one button and attach the actions to each button. but i only have two buttons now. one for left and one for right. now i am confused.

appreciate any ideas, thanks!

Hi,
very quickly and off the top of my head, you need to write a few if else arguments, something like this :
[AS]on(release){
if(imageHolder._x==xPos){
//wherexPos is the corordiantes that the image holder is
imageHolder._x = newXpos;
// where newxPos is the coordinates that you want it to move to;
} else if (imageHolder._x==xPos){
imageHolder = newXpos;
}[/AS]

and so on throught out the left and right positions that you want the images to appear.
It is very possible to write function for this ( to keep your code to a minimum), I will try and look out a file for you from a while ago, but in the meantime, I think that people in this forum will probably come up with a better answer, anyway, try it and see

Cheers

SteveD

i am looking through that idea right now as well, thanks for the ideas.

i have been looking for code for a function, too. i have seen something like this before, but i can’t seem to put my finger on it.

thanks again!

just thought of something else that could help…

each image is 100 pixels wide inside of the MC that needs to be moved.

so each click on the right button should subtract 100 pixels from the current position and each left click should add 100 pixels to the current position.

just writing that gives me an idea, let me know yours, too.

thanks!

2 buttons with instance names “leftclick” and “rightclick”
1 MC with instance name “pi”

here is the script i have in a MC sitting off the stage to actually move the MC “pi”:

startx2 = getProperty(/:pi, _x);
horznumx2 = /:targetx2-startx2;
setProperty("/pi", _x, startx2+(horznumx2/8));

so targetx2 is the thing that needs to be changed each time. what it looks like needs to happen is upon pressing the “rightclick” button i need to add 100 to the current value of target2x. and do the opposite for the “leftclick”.

this is the right idea, i just need to figure out how to do it.

thanks!

p.s. - i have had 3 cups of coffee while posting today.

Hi,
Caffiene will do your 'ed in man, stick to beer (lol!!!).
Yep, you are on the right track except you are using Flash4 syntax which isn’t really needed. It is about 7.45pm here ( European Time) and I am of to cook dinner for me and my gal, I have a file somewhere that has the same code you need. I’ll try and find it and post tomorrow for you - if you can wait thet long, or don’t get it worked out before - but really you are on the right track - leave the caffiene alone and keep thinking

Cheers

Steve

have a good dinner i will keep the ole eyes open for another answer

cheers

Hi Darley,
Sorted the code for you, before I post are you working in MX or f5,
I ask as it easier to stop the image scroll ( for me ) in MX, but if you are using 5, I will have to have a different look.
haven’t do anything about the pixel reduction in images, can you tell me what you are trying to achieve with that ?

SteveD

I am using MX. About the pixel reduction…what exactly do you mean there. I am not familiar with the term.

Thanks again.

Hi,
OK will be back with a test file for you in a short time.
You said

each image is 100 pixels wide inside of the MC that needs to be moved

I dunno what you mean by that oor what you are trying to achieve

SteveD

i have 10 images INSIDE a MC called “pi”

each single image is 100x100, those image when place one next to another make the MC pi a total of 1000 pixels wide x 100 tall.

the idea is that if i make “pi” move 100 pixels left or right it will always show an image at 100x100.

that make it clearer?

Hi,
Why don’t you put the images that you want the user to see under a mask.
The test file below does this, and the code moves the imageHolde mc the width of one image, that way there is always only one image on display
There is some code in the file that you may not need, basically I wanted to stop the “scroll” at either end when the imaheHolder came to eithe 10 or 1 - does that make send - well i have commented the code that you need to move the images from left to right, you can play around with the rest - any probs just ask

hope it helps

SteveD

oooooooooops!! forgot the fla.

wow, that is exactly what i was looking for! sorry it has taken me a while to get back. i have pulled the file apart and i am trying to figure out one new things.

I want to add 3 text fields. In these text fields I want to load text dynamically when the appropriate image is scrolled into place. So when image 2 scrolls into place, the dynamic text for the 2nd image will load as well.

Does that make sense? I am going to add some stuff to the existing file and see if I can get something going.

Once again, thanks for all this help!

Hi,
As well as using the var count to stop the scroll, you could use it to load in the text as well, try something like :

[AS]if(count==1){
//load txt file code here
} else if( count == 2){
//load another txt file code here
//and so on and so on
}[/AS]

You would need to put that in frame one, with a gotoAndPlay(1) in frame 2 so that the var count is constantly checked.

Also, you can probably write for loop for this to make it easier and shorter, you may need to play around with this a bit as I have done it of the top of my head, not tested, but, try something like this :
[AS]myArray = new Array(“file1.txt”, “file2.txt”,“file3.txt”// and so on);
for (i=0; i<myArray.length; i++){
if(myArray*==count){
trace(“success”);
//load txt file code here
}
}[/AS]

that should keep you going a bit, let us know how it works out

Cheers

SteveD

p.s did a quick edit there, my syntax was up the spout a bit, so make sure you check it otherwise it won’t work lol!!!

Hi darley,
Forgive me, I apologise, the last post was probably the biggest load of rubbish I have ever written - just hope you didn’t spend any time trying to implement it. Do this:
First make sure your text file names end in a number - myFile1.txt, myFile2.txt etc

Second create 2 additional key frames on the actions layer and make sure that you hit f5 for all the other layers.

Third in frame 2 put a simple stop() action

fourth in frame3 put this code:

[AS]infoText = new loadVars();
//infoText = name of var inside text file.
infoText.load(“test”+count+".txt");
//test.txt = name of txt file
infoText.onLoad = function() {
box.text = this.infoText;
//box = instance name of DTB
};
gotoAndPlay(2);[/AS]

Finally, on frame1 of the actions layer put :
[AS]_root.gotoAndPlay(3);[/AS]

You need to put this betwen the last two } for both the FWD and BACK code.

I have tested that and it will work, whatever count is ,the relevant txt file will open

Cheers

Bon Weekend

SteveD

i am working this out more and more. here is the main thing i am nnot getting. the text is not changing when i click the buttons. i am thinking that maybe it would mean i need to put something on the buttons themselves so “onPress”, something.

i am attaching the file for you to see what i mean.

thanks again!

Hi Darley,
probably didn’t explain myself properly, but:
[AS]_root.gotoAndPlay(3);[/AS]

Needs to be set in the first frame of the BUTTON ? I have put that right. The code in fr1 of the _root timeline sets the position of the buttons, stops at frame2, if it was to loop to frame one the buttons would keep reseting, when you click on a button, the var count is increased or decreased by one, the button sends the root to frame three where the value of count is checked and the correct text file is loaded in. Is that bit better, I hope so, look at the file below, it will work the way you want it to

Cheers

SteveD

it is people like you that make this board a great resource.

thanks for all the help!