MACROMEDIA FLASH MX 2004-USING COMPONENTS Use Manual page 39

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

Advertisement

Add an event listener to the Checkout button
Now you'll add code to display the Checkout screen when the user clicks the Checkout button.
In the Actions panel, add the following code:
// when the Checkout button is clicked, go to the "checkout" frame label
var checkoutBtnListener:Object = new Object();
checkoutBtnListener.click = function(evt:Object) {
evt.target._parent.gotoAndStop("checkout");
};
checkout_button.addEventListener("click", checkoutBtnListener);
This code specifies that, when the user clicks the Checkout button, the playhead moves to the
Checkout label in the Timeline.
Add code for the Checkout screen
Now you're ready to add code to the Checkout screen of the application, on Frame 10 on the
main Timeline. This code processes the data that users enter in the Billing, Shipping, and Credit
Card Information panes that you created earlier with the Accordion component and other
components.
In the Timeline, select Frame 10 in the Actions layer and insert a blank keyframe (select Insert >
1.
Timeline > Blank Keyframe)
Open the Actions panel (F9).
2.
In the Actions panel, add the following code:
3.
stop();
import mx.containers.*;
// define the Accordion component on the Stage
var checkout_acc:Accordion;
Next you'll add the first child to the Accordion component instance, to accept billing
4.
information from the user. Add the following code:
// define the children for the Accordion component
var child1 = checkout_acc.createChild("checkout1_mc", "child1_mc",
{label:"1. Billing Information"});
var thisChild1 = child1.checkout1_sp.spContentHolder;
The first line calls the
instance of the
name
child1_mc
shortcut to an embedded ScrollPane component instance.
Create the second child for the Accordion instance, to accept shipping information:
5.
/* Add the second child to the Accordion.
Add an event listener for the sameAsBilling_ch CheckBox.
This copies the form values from the first child into the second child. */
var child2 = checkout_acc.createChild("checkout2_mc", "child2_mc",
{label:"2. Shipping Information"});
var thisChild2 = child2.checkout2_sp.spContentHolder;
var checkboxListener:Object = new Object();
createChild()
movie clip symbol (which you created earlier) with the instance
checkout1_mc
and the label "1. Billing Information". The second line of code creates a
method of the Accordion component and creates an
Add ActionScript to the main Timeline
39

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?

This manual is also suitable for:

Flash mx

Table of Contents