Why not just set an an instance variable(some people say global) like:
mx.core.Application.application._NextButtonViewIndex =
event.target.data;

On Click you could then do: 
myViewstack.selectedIndex = _NextButtonViewIndex;  

You are using a ViewStack, I hope? 

Tracy

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Mink, Joseph
Sent: Wednesday, October 05, 2005 3:49 PM
To: [email protected]
Subject: RE: [flexcoders] Pass data from child component to parent in
wizard app

I'm not totally sure of your approach, but as far as the specifc line
giving you trouble (mx.core.Application.application.nextButton.click =
mx.core.Application.application.goToScreenName(event.target.data);), did
you happen to trace or log the value of event.target.data?

I think if I were making a wizard, I would use a different mxml
component for each wizard screen.  And I would store the input from each
wizard screen in the parent application.

Hope something here was useful to you, though I doubt it : )

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of face7hill
Sent: Wednesday, October 05, 2005 3:22 PM
To: [email protected]
Subject: [flexcoders] Pass data from child component to parent in wizard
app


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> 




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 




SPONSORED LINKS 
Web site design development
<http://groups.yahoo.com/gads?t=ms&k=Web+site+design+development&w1=Web+
site+design+development&w2=Computer+software+development&w3=Software+des
ign+and+development&w4=Macromedia+flex&w5=Software+development+best+prac
tice&c=5&s=166&.sig=L-4QTvxB_quFDtMyhrQaHQ>     Computer software
development
<http://groups.yahoo.com/gads?t=ms&k=Computer+software+development&w1=We
b+site+design+development&w2=Computer+software+development&w3=Software+d
esign+and+development&w4=Macromedia+flex&w5=Software+development+best+pr
actice&c=5&s=166&.sig=lvQjSRfQDfWudJSe1lLjHw>   Software design and
development
<http://groups.yahoo.com/gads?t=ms&k=Software+design+and+development&w1=
Web+site+design+development&w2=Computer+software+development&w3=Software
+design+and+development&w4=Macromedia+flex&w5=Software+development+best+
practice&c=5&s=166&.sig=1pMBCdo3DsJbuU9AEmO1oQ>         
Macromedia flex
<http://groups.yahoo.com/gads?t=ms&k=Macromedia+flex&w1=Web+site+design+
development&w2=Computer+software+development&w3=Software+design+and+deve
lopment&w4=Macromedia+flex&w5=Software+development+best+practice&c=5&s=1
66&.sig=OO6nPIrz7_EpZI36cYzBjw>         Software development best
practice
<http://groups.yahoo.com/gads?t=ms&k=Software+development+best+practice&;
w1=Web+site+design+development&w2=Computer+software+development&w3=Softw
are+design+and+development&w4=Macromedia+flex&w5=Software+development+be
st+practice&c=5&s=166&.sig=f89quyyulIDsnABLD6IXIw>      

________________________________

YAHOO! GROUPS LINKS 


        *        Visit your group "flexcoders
<http://groups.yahoo.com/group/flexcoders> " on the web.
          
*        To unsubscribe from this group, send an email to:
         [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]> 
          
*        Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service <http://docs.yahoo.com/info/terms/> . 


________________________________





--
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



 








------------------------ Yahoo! Groups Sponsor --------------------~--> 
Get Bzzzy! (real tools to help you find a job). Welcome to the Sweet Life.
http://us.click.yahoo.com/A77XvD/vlQLAA/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/
 




Reply via email to