Hello All,
I have a wizard type app called "main.mxml" with three children
("screen1", "screen2" and "screen3"). I have a button in main.mxml
called "nextButton". Inside screen1.mxml are a couple of radio
buttons that a user can select. How do I get the selected radio
button (in the child component) to broadcast to the nextButton (in
the parent app) where it should point to? For example, in the code
below, on screen1.mxml, I have a function:
//this function is fired when a user selects a radio
button
function buttonClicked( event : Object ) : Void {
//this works
//sets the status label in the parent app
mx.core.Application.application.setStatusLabel
(event.target.data);
//this does not work
//trying to set where nextButton (in the
parent app) will point to when the nextButton is clicked
mx.core.Application.application.nextButton.click =
mx.core.Application.application.goToScreenName(event.target.data);
}
Am I approaching this the wrong way? Any suggestions? I am
essentially trying to create a wizard like application where the
flow from screen to screen will be based on the user's input on each
screen, so the nextButton.click in the parent app will be
dynamically assigned.
Thank you for any help!
<!-- main.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"
xmlns="*" width="100%" height="100%" pageTitle="Wizard Question"
initialize="initApp()">
<mx:Script>
<![CDATA[
//This function is for jumping from screen
to screen outside of the flow when debugging
function jumpToScreen(x){
mainViewStack.selectedIndex = x -1;
}
function goToScreenNumber(x){
mainViewStack.selectedIndex = x-1;
}
function goToScreenName(x){
mainViewStack.selectedChild = x;
}
function initApp(){
//list initialization functions here
}
function setPanelTitle(x){
mainPanel.title = x;
}
function setStatusLabel (x){
statusLabel.text = x;
}
]]>
</mx:Script>
<!-- "jump to" form (for debugging screens)-->
<mx:HBox width="100%" horizontalAlign="right"
verticalAlign="bottom" borderStyle="none">
<mx:HBox width="50%" horizontalAlign="right">
<mx:Form id="showMeScreenForm"
borderStyle="none" marginTop="0" marginBottom="0">
<mx:FormItem label="jump to screen:"
direction="horizontal" horizontalAlign="right">
<mx:TextInput
id="showMeScreenTextInput" width="60"/>
<mx:Button
id="showMeScreenButton" label="Go" click="jumpToScreen
(showMeScreenTextInput.text);"/>
</mx:FormItem>
</mx:Form>
</mx:HBox>
</mx:HBox>
<!-- Main Panel -->
<mx:Panel id="mainPanel" title="" width="100%" height="100%"
styleName="mainPanel">
<!-- Main ViewStack -->
<mx:ViewStack id="mainViewStack" width="100%"
height="100%">
<!-- mainViewStack.selectedChild=screen1 --
>
<screen1 id="screen1" label="screen1"/>
<!-- mainViewStack.selectedChild=screen2 -->
<screen2 id="screen2" label="screen2"/>
<!-- mainViewStack.selectedChild=screen3 -->
<screen3 id="screen3"/>
</mx:ViewStack>
<!-- End Main ViewStack -->
<!-- The Control Bar -->
<mx:ControlBar>
<mx:HBox width="50%"
horizontalAlign="left">
<mx:Label
id="statusLabel" text="" width="200"/>
</mx:HBox>
<mx:HBox width="50%"
horizontalAlign="right">
<mx:Button
id="backButton" label="Back"/>
<mx:Button
id="nextButton" label="Next"/>
</mx:HBox>
</mx:ControlBar>
</mx:Panel>
</mx:Application>
<!-- screen1.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<!-- mainViewStack.selectedChild=screen1 -->
<mx:VBox width="100%" height="100%"
xmlns:mx="http://www.macromedia.com/2003/mxml"
initialize="initScreen1();">
<mx:Script>
<![CDATA[
function initScreen1(){
}
//this function is fired when a user selects a radio
button
function buttonClicked( event : Object ) : Void {
//this works
//sets the status label in the parent app
mx.core.Application.application.setStatusLabel
(event.target.data);
//this does not work
//trying to set where nextButton (in the
parent app) will point to when the nextButton is clicked
mx.core.Application.application.nextButton.click =
mx.core.Application.application.goToScreenName(event.target.data);
}
]]>
</mx:Script>
<mx:Text text="Which screen would you like to go to?"
width="100%"/>
<mx:RadioButton id="goToScreen2RadioButton" label="screen2"
data="screen2" click="buttonClicked( event );"/>
<mx:RadioButton id="goToScreen3RadioButton" label="screen3"
data="screen3" click="buttonClicked( event );"/>
</mx:VBox>
<!-- screen2.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox width="100%" height="100%"
xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Text text="This is screen2." width="100%"/>
</mx:VBox>
<!-- screen3.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:VBox width="100%" height="100%"
xmlns:mx="http://www.macromedia.com/2003/mxml">
<mx:Text text="This is screen3." width="100%"/>
</mx:VBox>
------------------------ Yahoo! Groups Sponsor --------------------~-->
Fair play? Video games influencing politics. Click and talk back!
http://us.click.yahoo.com/T8sf5C/tzNLAA/TtwFAA/nhFolB/TM
--------------------------------------------------------------------~->
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/flexcoders/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/