Skip to main content
Known Participant
November 21, 2009
Answered

Swap image actionscript

  • November 21, 2009
  • 1 reply
  • 3697 views

Hi there.

I'm a beginner in flash actionscript. I want to basically swap images using actionscript. So if you click on a thumbnail, the main big image will change corresponding to the thumbnail being clicked. I don't want to use a simple on click go to and play actionscript...

I'll try to paint a picture of what I'm trying to achieve.

There is a background image, middle ground and foreground image... people will have a selection of thumbnails to chose from to change these images (so they are creating their own big picture)

Once the user clicks on a thumbnail for the background, the main image will change corresponding to the thumbnail.. and the same for middleground image and foreground image.

I can acheive this in director using lingo but I am required to use flash and actionscript.  Hope you can help!

Thanks in advance!

This topic has been closed for replies.
Correct answer kglad

When i put that actionscript on the thumbnail, I get an error message - statement must appear appear within on statement - I thought the seconds part of the code did that: -

thumb1.onRelease=function(){
target.loadMovie(this.largeImage);

}

Am I missing something?


that code should be attached to a frame, not an object.

1 reply

kglad
Community Expert
Community Expert
November 21, 2009

each thumbnail will need to reference the larger image.  the easiest way to do that is to assign a property to the thumbs:

thumb1.largeImage="image1.jpg";

thumb2.largeImage="secondimage.jpg";

etc

you can then use:

thumbX.onRelease=function(){

target.loadMovie(this.largeImage);

}

dips045Author
Known Participant
November 21, 2009

Hi,

many thanks for such a quick reply!

I need a bit more guidance with assigning a property to the thumbs. Do I use the setProperty function?

I have named all of the thumbs and the main image.

Many thanks again!

kglad
Community Expert
Community Expert
November 21, 2009

no, use dot notation like i showed:

thumb1.largeImage="cafda.jpg";

assigns the property largeImage to thumb1 (which is the movieclip displaying the first thumbnail image).