Danh mục

Foundation Flash CS5 For Designers- P14

Số trang: 50      Loại file: pdf      Dung lượng: 1.01 MB      Lượt xem: 17      Lượt tải: 0    
Jamona

Xem trước 5 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Foundation Flash CS5 For Designers- P14: Flash is one of the most engaging, innovative, and versatile technologies available-allowing the creation of anything from animated banners and simple cartoons to Rich Internet Applications, interactive videos, and dynamic user interfaces for web sites, kiosks, devices, or DVDs. The possibilities are endless, and now it just got better
Nội dung trích xuất từ tài liệu:
Foundation Flash CS5 For Designers- P14 BUILDING INTERFACES WITH THE UI COMPONENTSHere’s an exercise designed to show you how the ProgressBar component works: 1. Open the ProgressBar.fla file in this chapter’s Exercise folder. Note that a ProgressBar instance exists in frame 1 with the instance name pb, as well as a text field with the instance name output. In frame 5, you’ll find a fairly heavy image of red leaves on a tree branch, snapped by one of the authors. In the scripts layer, there’s a MovieClip.stop() method in frames 1 and 5. 2. Click into frame 1 of the scripts layer. Note the existing stop() method. Type the following ActionScript after that method (new code in bold):stop();root.loaderInfo.addEventListener(Event.COMPLETE, completeHandler);function completeHandler(evt:Event):void { play();};pb.source = root.loaderInfo;Here, first, the playhead stops at this frame. Next, an Event.COMPLETE handler is assigned to theLoaderInfo instance associated with the root property of the main timeline. Say again? Yeah, this one isa bit different from what you’ve seen.In the same way that the stop() method is invoked here on the main timeline—appearing, as it does,without an object reference prefix—the root property is also being invoked implicitly on the main timeline.(root is a property of the DisplayObject class, which means MovieClip and other classes have it byinheritance.) The root property refers to the topmost display object in a given display list. In this context, itessentially refers to the display list of the main timeline (everything that’s visible—or will be visible—on themain timeline, including that onion photo on frame 5).The main timeline, being a movie clip, features a loaderInfo property, which points to an instance of theLoaderInfo class that (as its name suggests) manages loading information for the object at hand. In thiscase, when the movie itself has completed loading, the Event.COMPLETE event is dispatched, and thecompleteHandler() function invokes MovieClip.play() on the main timeline, causing the playhead toresume play until it encounters the second stop() method on frame 5. It’s frame 5 that reveals the image.Notice that, so far, none of this yet touches the ProgressBar component. That happens only at this point.Immediately after the event handler, the ProgressBar.source property, by way of the pb instance, isassociated with the root.loaderInfo reference. As if by magic, that’s all it takes to set the thermometer-style movement in motion. 3. Test the movie. When the SWF launches, select View ➤ Simulate Download from the SWF’s menu bar to see the ProgressBar component in action. Selecting View ➤ Download Settings lets you select the speed of the simulated Internet connection. 4. Close the SWF. 629 www.zshareall.com CHAPTER 11 5. Let’s also display a text message indicating a percent loaded. In the Actions panel, add a few more lines below the existing code: pb.addEventListener(ProgressEvent.PROGRESS, progressHandler); function progressHandler (evt:ProgressEvent):void { output.text = Math.floor(pb.percentComplete).toString() + %; }; The ProgressBar component features a percentComplete property, which we’re using here. The addEventListener() method is invoked against the pb instance, listening for a ProgressEvent.PROGRESS event. The function it performs sets the output text field’s text property to a rounded-down string version of the progress percentage, with the percent sign tacked onto the end for good measure. RadioButton componentThis book was purchased by flashfast1@gmail.com Radio buttons are gregarious. They belong in groups and courteously defer to each other as each takes the spotlight. ...

Tài liệu được xem nhiều: