Visitors to VTC.com will be able to view all introductory videos for each training course.
Free Trial Members will gain access to first three chapters for each training course.
Full Access Members have full access to VTC.com�s entire library of video tutorials.
Next, we hide the old slide by setting its alpha to zero, that's very clever right there. Alpha equals zero is transparent, alpha equals 100 is fully opaque. Then we bring the old slide to the front: mcSlideHolder.swapChildren sprContainer2 comma sprContainer1, so that's the function that will switch the slides back and forth between Container1 and Container2. Then we get to the last part of this function and the last part of the actual script itself. Then we create a new Loader for the slide: slideLoader equals new Loader and then we add an EventListener for when it is loaded, notice that when it's loaded we're going to run the fadeSlideIn function, right there. The next line is a little bit tricky. We're going to add the picture with the URLRequest that contains the source path to the current image. Again, that source path is very, very important. That's the path to your XML file. Now that's picked up right here in that at source call, that at source call refers to our original XML file, that src tag right there, so that's very important. And then last of all we show the description of the slide on the lbl description text file, or text field, right here is the lbl description text field. I'm setting up that tag right there at description is this XML tag back right there. Now I haven't shown you where that lbl description text field is, nor the lbl count, so let me do that right now. You'll need to set these up in your original Flash file for this to work. If we go in here to our file, double-click on this portion down here. Notice that I'm getting into the Info movie clip, or Info mc movie clip. Let's go ahead and open up our Properties Inspector and notice that there are some text fields down here that I need to define for you. There's a description but there is a dynamic text field called lbl underscore description, that's where the description goes. Another one here is called lbl underscore count. That's where the count will go so that you can see which slide you're on. So it's very, very important. I neglected to show you that earlier. Let's open up the Actions Panel again and click on the, actually let's go back to the Scene 1, click on the first frame there to bring up our script, and we're just about finished. So, there are the calls to populate the description and the slide number - those two lines, very, very important. When I went through this as practice I had trouble with this part of the code. I had this description incorrect so I wasn't getting my slide description. Then go ahead and run the init function here, init open-close parentheses semicolon, and that should be it. Lastly, you'll want to check the scripts. Probably the best way to do that is to go by section. The first section was importing your custom classes and setting up your constants. Then the next section was setting up your variables. Go ahead and pause the movie as I go through each section and check all of these lines of code for the syntax and the colors and everything. Then I went through a series of functions, the first being the initialize function. Let's go ahead and stop that, get that function correct. Then two other functions were on - let's go ahead and move this down so that's not going to distract you - the first one was the onLoadComplete function and then the fadeSlideIn function. Go ahead and pause the movie and get those correct. And the last one was the big one, the switchSlide function. I don't think I'll be able to get all of this in one picture here, but there's the first part of it, go ahead pause the movie and then there's the last part of it right there. Now the moment of truth here, Control, Test Movie and we should get a nice fade-in according to the parameters that you set for the timing of the slide and the timing of the fades. We should have a description here of each of the images as well as the slide count, 3 of 5, 4 of 5, 5 of 5 and so on. Again, I'd like to thank Rafael Nuenlist and the TechLab's website for most of the source code for this example. Rafael's great documentation and explanation of all the scripts, very clear code, was by far the best that I encountered when researching various XML Slideshows for this project. That will conclude then this section of the tutorial on Working XML Data into Your Flash Projects Using ActionScript, which now takes us to the final section of the tutorial: Scripting Flash Games.
| Course: | Adobe Flash ActionScript 3.0 for Designers |
| Author: | James Gonzalez |
| SKU: | 34060 |
| ISBN: | 1-935320-82-3 |
| Release Date: | 2009-11-09 |
| Duration: | 9.5 hrs / 101 lessons |
| Work Files: |
Yes |
| Captions: | No |
| Compatibility: |
Vista/XP/2000, OS X, Linux QuickTime 7, Flash 8 |