tailieunhanh - Foundation Flash CS4 for Designers- P8
Foundation Flash CS4 for Designers- P8: I can remember the day as clear as if it were just yesterday. I was walking by my boss’s office late one winter afternoon at the college where I teach, and he called me into his office. Sitting on his desk was a thin, white box with some sort of weird swirl on it. He slid the box across to me and asked, “You know anything about Flash?” | CHAPTER 4 6. Replace the existing ActionScript altogether with this variation trace loneliestNumber function quickTest void var loneliestNumber int 1 trace loneliestNumber quickTest 7. Test this movie one last time. You ll see an error in the Compiler Errors panel 1120 Access of undefined property loneliestNumber. Close the SWF. This time the variable is declared inside the function. The function s scope can see it but the main timeline s no longer can. Why Outer scopes can t look in the process only moves from inside out. You got an error because when the main timeline looks into its own private world it doesn t see anything named loneliestNumber. There s nothing above it that has that value either so it gives up. You ve seen that scope has the potential to trip you up with variables. Now let s dig deeper into variables. Variables Variables are often described as buckets. It s not a bad analogy. Like buckets variables are containers that temporarily hold things. Like buckets variables come in specific shapes and sizes and these configurations determine what sorts of things and how many of them a given variable can hold. In fact variables are practically the same as properties. A great way of understanding the concept of a variable is to consider a trip to the supermarket. You pay for a bunch of tomatoes a can of soup a box of Twinkies a head of lettuce and a package of paper towels. The clerk puts them in a bag you pay for them pick up the bag and walk out of the store. If someone were to ask you what you carrying the answer would be groceries. The word describes all of the objects you have purchased but it doesn t describe any item in particular and the contents of your bag certainly might change. The word groceries is a suitable placeholder. Essentially variables are properties that aren t associated with a particular class which means you can create a variable in any timeline and access it from that timeline without needing to refer to an object first. The .
đang nạp các trang xem trước