MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 40

Using components
Hide thumbs Also See for FLASH MX 2004-USING COMPONENTS:
Table of Contents

Advertisement

checkboxListener.click = function(evt:Object) {
if (evt.target.selected) {
thisChild2.shippingFirstName_ti.text =
thisChild1.billingFirstName_ti.text;
thisChild2.shippingLastName_ti.text =
thisChild1.billingLastName_ti.text;
thisChild2.shippingCountry_ti.text = thisChild1.billingCountry_ti.text;
thisChild2.shippingProvince_ti.text =
thisChild1.billingProvince_ti.text;
thisChild2.shippingCity_ti.text = thisChild1.billingCity_ti.text;
thisChild2.shippingPostal_ti.text = thisChild1.billingPostal_ti.text;
}
};
thisChild2.sameAsBilling_ch.addEventListener("click", checkboxListener);
The first two lines of code are similar to the code for creating the Billing Information child:
you create an instance of the
and the label "2. Shipping Information". The second line of code creates a shortcut
child2_mc
to an embedded ScrollPane component instance.
Beginning with the third line of code, you add an event listener to the CheckBox instance. If
the user clicks the check box, the shipping information uses the data the user entered in the
Billing Information pane.
Next, create a third child for the Accordion instance, for credit card information:
6.
// define the third Accordion child
var child3 = checkout_acc.createChild("checkout3_mc", "child3_mc",
{label:"3. Credit Card Information"});
var thisChild3 = child3.checkout3_sp.spContentHolder;
Add this code to create ComboBox instances for the credit card month, year, and type, and
7.
populate each with a statically defined array:
/* set the values in the three ComboBox instances on the Stage:
ccMonth_cb, ccYear_cb and ccType_cb */
thisChild3.ccMonth_cb.labels = ["01", "02", "03", "04", "05", "06", "07",
"08", "09", "10", "11", "12"];
thisChild3.ccYear_cb.labels = [2004, 2005, 2006, 2007, 2008, 2009, 2010];
thisChild3.ccType_cb.labels = ["VISA", "MasterCard", "American Express",
"Diners Club"];
Finally, add the following code to add event listeners to the Checkout button and the Back
8.
button. When the user clicks the Checkout button, the listener object copies the form fields
from the Billing, Shipping, and Credit Card Information panes into a LoadVars object that is
sent to the server. (The LoadVars class lets you send all the variables in an object to a specified
URL.) When the user clicks the Back button, the application returns to the main screen.
/* Create a listener for the checkout_button Button instance.
This listener sends all the form variables to the server when the user clicks
the Checkout button. */
var checkoutListener:Object = new Object();
checkoutListener.click = function(evt:Object);
evt.target.enabled = false;
/* Create two LoadVars object instances, which send variables to
and receive results from the remote server. */
40
Chapter 2: Creating an Application with Components (Flash Professional Only)
movie clip symbol, with the instance name
checkout2_mc

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004-USING COMPONENTS and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Flash mx

Table of Contents