Join Todd Perkins for an in-depth discussion in this video Constraining property values, part of Flash CS4 Professional: Object-Oriented Programming .
Now we are going to look at constraining the property values of currentIndex…so that it doesn't go out of bounds. In other words, if it goes below zero,…it will go to the last item or above the number of total items. Then we will make…the data kind of loop around to go to zero. We are going to do that in the…controlCurrentIndex method.…So I'm going down there and I'm going to use some conditional statements.…First thing I'm going to do is check to see if currentIndex is greater than or equal…to totalItems. If so, the index is too high and it's out of bounds. Remember…that the total number of items is going to be different than the highest index.…
If we had an XML file with four images in it, the number of total items would…be four, but the highest index number would be three.…So if we pass in a value of 4, for example, and set currentIndex and…currentIndex is set to 4, when we run controlCurrentIndex, that value will then…be out of bounds. So if it's equal to or greater than totalItems then we are…
- Loading external text, images, and XML files
- Creating essential properties for a View class
- Defining a Model class
- Building and implementing interfaces and designs
- Debugging projects
- Building applications with Controller-class buttons
Skill Level Intermediate
1. ActionScript 3.0 Essentials
2. Advanced ActionScript Techniques
3. Object-Oriented Programming Fundamentals
4. The Model View Controller Design Pattern
5. Building a Model Class
6. Building a View Class
7. Building a Controller Class
8. Improving and Debugging the Application
9. Moving Forward
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.