Solved

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

Posted on 2009-05-04
17
1,260 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
 
LVL 3

Expert Comment

by:crittle1
Comment Utility
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
Comment Utility
Maybe you'll have to post it and I can pull it from the thread
0
 

Author Comment

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

Author Comment

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

Author Comment

by:N4Nathan
Comment Utility
Ahh apparently i can send a Zip File :)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 3

Accepted Solution

by:
crittle1 earned 125 total points
Comment Utility
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
Comment Utility
correction: PUTTING the actionscript ( on rollover/rollout ect) on the movieclip activates the button mode.
0
 

Author Comment

by:N4Nathan
Comment Utility
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
Comment Utility
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
Comment Utility
O i see what you mean! except i must have made a boo boo on my end THANKS!
0
 

Author Closing Comment

by:N4Nathan
Comment Utility
Thank you!! :]
0
 
LVL 3

Expert Comment

by:crittle1
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is intended to introduce all collision detection principles in flash, their strengths, weaknesses and workarounds. The main method for Collision Detection in flash is using hitTestObject. But unless you'll be pushing rectangular shapes without …
I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
The goal of the tutorial is to teach the user how to set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

744 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now