This tutorial teaches how to create a dynamic portfolio in Flash that loads images and text from external files. It uses Loader components to dynamically load thumbnail images and larger images. LoadVars loads text files containing image titles and descriptions. Buttons trigger a function to load corresponding images and text files, displaying them in dynamic text fields. The portfolio can be easily updated by changing external files without modifying the FLA.
3. comp3_btn respectively starting from the top. Assign the instance name main_mc to our main display
component at the centre.
It's time to put the code, click on the single frame in our Actions layer and then access the Actions (Right
click the frame>Actions) to assign our script to the timeline and not any of the objects. You should put
all your code in a single place on the timeline instead of scattering the code all over the place.
We'll start off by simply loading all of our thumbnails of the buttons. This should be easy if you read the
other Loader Component tutorial:
comp1_btn.contentPath = "thumb1.jpg";
comp2_btn.contentPath = "thumb2.jpg";
comp3_btn.contentPath = "thumb3.jpg";
You can test the movie to see the buttons take their images if you would like to. We will now make each
of these components a button that tells the main component to load a specific image according the
button clicked. Any movie clip in modern Flash can act as a button by simply attaching a button event
handler property such as .onRelease. We will combine the usage of this with a function to make the
scripting faster and to reduce the amount of code written. You should review the functions tutorial if
you do not know how to use functions. Our function will simply tell the main component to load the
image that we specify, button 1 will load image 1, button 2 will load image 2, and button 3 will load
image 3.
function portfolioLoader (image) {
main_mc.contentPath = image;
}
comp1_btn.onRelease = function (){
portfolioLoader("image1.jpg");
}
comp2_btn.onRelease = function (){
portfolioLoader("image2.jpg");
}
comp3_btn.onRelease = function (){