Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How to load an external image into a movieClip then maniplulate movieClip using Flash CS3 AS2

Posted on 2009-05-04
17
1,274 Views
Last Modified: 2013-11-11
I'm working on a photography website for school i'm not very good at using actionscript but i'm learning. Here's my problem: I load an image from the same directory into a movieclip using loadMovie. Once the image is displayed i'd like it to be able to be clickable so the user can see the image and be able to click it. And on top of that make the movieClip have a rollover effect. For some reason when you uplaod an image into a movieclip then call upon the movieclip to lets say add a onRelase function it doesn't work why? For the following code i have created 2 movieclips one to upload image and the other as a button.
stop();
this.onLoad=function(){ 
loadMovie("IMG_0001.jpg", pic1_mc); // load image from same directory into movieclip
loadMovie("big0001.jpg", images_mc); // load image into the BIG movieclip
images_mc._alpha=0;
}
//this code ads the fade effect to photos
this.onEnterFrame=function(){
	images_mc._alpha+=99;
}
// when thumb1_mc is released the image1.jpg is loaded in images_mc, the _alpha property is set to 0, but addis +10 in the onEnterFrame event we obtain the fade transition between photos
 
pic1_mc.onRelease=function(){
	images_mc.loadMovie("big0001.jpg");  
	images_mc._alpha=0;
}

Open in new window

0
Comment
Question by:N4Nathan
  • 9
  • 8
17 Comments
 
LVL 3

Expert Comment

by:crittle1
ID: 24304311
Do you have them stack on top of another? If so, make sure the top layer is the button.

Why do you have 2 movieclips? Can't you just have one.. and each time it is clicked, load the next image you specify....

If you still have problems, make a button to the side... so when it's clicked, the images do as you wish....just a thought.
0
 
LVL 3

Expert Comment

by:crittle1
ID: 24304472
Also, for the rollover affect, you can go create the affect in the pic1_m  timeline... then call it like this:

pic1_mc.onRollOver = function(){
this.pic1_mc.gotoAndPlay("2"); //go to and Play frame 2... so frame 1 will have the stop(); command
}

pic1_mc.onRollOut = function(){
this.pic1_mc.gotoAndPlay("5"); //go to and Play frame 5 frame. this is your roll out funtion
}

assuming that you pic1_mc is in the main timeline.
See if that works....
0
 

Author Comment

by:N4Nathan
ID: 24305884
Yes my movieclips are on top of eachother the one on top layer is the button and the one on bottom is the image im loading externally. How can i make the same movieclip be clickable and display the external image? So i don't have to have 2 movieclips layered. I can get the rollover to work on my image except than the image isn't clickable. I enclosed a JPEG of what a page looks like. Each movie clip is a 50x50 thumbnail. With an invisible button ontop of the image so you can still see the image and make it clickable. This worked fine untill i needed to add the rollover effect which changes the movieclips alpha value. Thanks
screeny.JPG
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 3

Expert Comment

by:crittle1
ID: 24305926
can you pm me the file and I will do what I can to help. I have about 20min on my hands. Make sure to send the images...or at least the first 2. I'll post the answer if I can figure it out.
0
 
LVL 3

Expert Comment

by:crittle1
ID: 24305960
Maybe you'll have to post it and I can pull it from the thread
0
 

Author Comment

by:N4Nathan
ID: 24306289
Dang i can't attach fla file i'll try and pm you
0
 

Author Comment

by:N4Nathan
ID: 24306326
Hmmm i'm new here and i can't seem to find how to pm.
0
 

Author Comment

by:N4Nathan
ID: 24306364
Ahh apparently i can send a Zip File :)
0
 
LVL 3

Accepted Solution

by:
crittle1 earned 125 total points
ID: 24306404
ok, check this out first. Wasn't sure if you go the post so I took the liberty and made a sample fla.  ( apparently I can't load it) so I'm going to post the code.


The first part of the code is in frame 1 of the fla. The second part is on the movieclip itself. Make sure to change the movieclip instance name to fit your needs.  The actionscript on the button will activate the button mode. Mind you it changes in as3 but that's a totally different beast! You should be learning that since as2 will be of the past.

Anyhow, see the attached. If you want the next image in the sequence to load.. or a specific, you will have to specify an if / then statement. Read up on that a bit and post back.

stop();
loadMovie("CompactCover.jpg", "holder_mc")
 
 
 
 
//ON THE EMPTY MOVIECLIP
 
on (rollOver) {
//_root.yourmovieclipname.gotoAndStop(10);
this._alpha = 70;
 
}
 
on (rollOut) {
//_root.yourmovieclipname.gotoAndStop(10);
this._alpha = 100;
 
}
 
on (release){
	this.loadMovie("CompactCover2.jpg", "holder_mc")
}

Open in new window

0
 
LVL 3

Expert Comment

by:crittle1
ID: 24306413
correction: PUTTING the actionscript ( on rollover/rollout ect) on the movieclip activates the button mode.
0
 

Author Comment

by:N4Nathan
ID: 24306453
Which movieclip is that on? since the movieclip that is over top of the movieclip blocks the bottom one from being clickable or rollover
0
 
LVL 3

Expert Comment

by:crittle1
ID: 24306483
the gotoandstop is commented out, but use it if you want to make a custom rollover animation inside the movieclip. The code tells it to go to and stop at a certain frame. You could change that to gotoandPlay to play it if you prefer.  OR you could just stick with telling it what to do via the actionscript... like changing the position, alpha, rotating it, making it darker, shrinking... zooming it... ect.
0
 

Author Comment

by:N4Nathan
ID: 24306489
O i see what you mean! except i must have made a boo boo on my end THANKS!
0
 

Author Closing Comment

by:N4Nathan
ID: 31577620
Thank you!! :]
0
 
LVL 3

Expert Comment

by:crittle1
ID: 24306558
Why do you have the 2 movieclips anyhow? You can load all the info into one movieclip, including the rollover animation, fading in and out. I have it set up for one. mmm, I would look into swaping depths if your dead set on having 2. You can't have 2 images atop of one another and have them both clickable. One takes precedence. Another thing you could think about is dynamically creating an empty movieclip, then "deleting" it when the next image is loaded....  Let me check my settings to see if I can set it so you can contact me.


check out:
http://www.adobe.com/devnet/actionscript/cookbook/swap_movieclips.html

I think that may solve your problem.

0
 

Author Comment

by:N4Nathan
ID: 24307977
I didn't even think about putting the rollover etc onto the movieclip i tried doing it all in actions panle hahah :P Thanks
0
 

Author Comment

by:N4Nathan
ID: 24316781
Hmm For some reason the rollover works fine but the on (release) function wont work when i try and apply it to my holder movieclip :S
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Download slideshow or picture elements 16 438
High Internet Explorer CPU on Flash site in Citrix 2 839
bandwidth 5 74
PDF: Display my cards game? 8 124
This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
The goal of the tutorial is to teach the user how to select which audio input to use. Once you have an audio input plugged into the laptop or computer, you will go into the audio input settings and choose which audio input you want to use.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question