N4Nathan
asked on
How to load an external image into a movieClip then maniplulate movieClip using Flash CS3 AS2
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;
}
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....
pic1_mc.onRollOver = function(){
this.pic1_mc.gotoAndPlay("
}
pic1_mc.onRollOut = function(){
this.pic1_mc.gotoAndPlay("
}
assuming that you pic1_mc is in the main timeline.
See if that works....
ASKER
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
screeny.JPG
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.
Maybe you'll have to post it and I can pull it from the thread
ASKER
Dang i can't attach fla file i'll try and pm you
ASKER
Hmmm i'm new here and i can't seem to find how to pm.
ASKER
Ahh apparently i can send a Zip File :)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
correction: PUTTING the actionscript ( on rollover/rollout ect) on the movieclip activates the button mode.
ASKER
Which movieclip is that on? since the movieclip that is over top of the movieclip blocks the bottom one from being clickable or rollover
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.
ASKER
O i see what you mean! except i must have made a boo boo on my end THANKS!
ASKER
Thank you!! :]
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.
check out:
http://www.adobe.com/devnet/actionscript/cookbook/swap_movieclips.html
I think that may solve your problem.
ASKER
I didn't even think about putting the rollover etc onto the movieclip i tried doing it all in actions panle hahah :P Thanks
ASKER
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
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.