MACROMEDIA FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH Manual page 584

Learning actionscript 2.0 in flash
Table of Contents

Advertisement

Using components, bindings, and custom formatters
Custom formatters help you format complex data in a specific way. You can also use custom
formatting to help display images, HTML formatted text, or other components within a
component such as the DataGrid. The following example illustrates how useful custom
formatters can be.
To use custom formatters in a document:
1.
Create a new FLA file and add the DataBindingClasses class to the library (Window >
Common Libraries > Classes).
2.
Drag a copy of the DateChooser component onto the Stage and give it the instance
name my_dc.
3.
Drag a copy of the Label component onto the Stage and give it the instance name my_lbl.
4.
Insert a new layer and name it actions.
5.
Add the following ActionScript code to Frame 1 of the actions layer:
import mx.data.binding.*;
var src:EndPoint = new EndPoint();
src.component = my_dc;
src.property = "selectedDate";
src.event = "change";
var dest:EndPoint = new EndPoint();
dest.component = my_lbl;
dest.property = "text";
new Binding(src, dest);
This code creates a binding between the DateChooser's
property of the Label component on the Stage. Each time you click a new date in the
text
calendar, the selected date appears in the Label component.
6.
Save the Flash document as customformat.fla in a convenient location on your hard disk.
(You will recycle it in the next exercise.)
7.
Select Control > Test Movie to test the document.
Try to change the dates in the Calendar component and you'll see the currently selected
date appear in the Label component. The Label component isn't wide enough to display
the entire date, so Flash crops off the text.
8.
Close the test SWF file and return to the authoring environment.
Either resize the Label component on the Stage or select the Label component and set the
property to
autoSize
584
Creating Interaction with ActionScript
in the Parameters tab of the Property inspector.
left
property and the
selectedDate

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-LEARNING ACTIONSCRIPT 2.0 IN FLASH and is the answer not in the manual?

This manual is also suitable for:

Flash 8

Table of Contents