RE: [flexcoders] Moving a viewStack through actionscript
Thank you tracy. That helps a lot. I got it to work! From: "Tracy Spratt" Sent: Tuesday, March 10, 2009 6:42 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Moving a viewStack through actionscript Put the change handler on the RadioButton group, and in that handler dispatch your specially named, bubbling event. In the handler for that event, you can access the dispatching component through the reference in the target or currentTarget property. So you can access the value of the RadioButtonGroup through that reference. Tracy Spratt, Lariat Services, development services available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Wally Kolcz Sent: Tuesday, March 10, 2009 8:34 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Sorry to be a pain, but when I added the parent.parent.checkSingle() it gives me an error. 1061: Call to a possibly undefined method checkSingle through a reference with static type flash.display:DisplayObjectContainer. I though my problem was the 'public var testMod:test1 = new test1();', thinking the 'new test1()' was the problem. So I removed it and just set it to a local variable. public var testMod:test1; I was able to see the checkSingle method in the auto hinting. But when I try to run it now, I get that the testMod is null. If I were to do the dispatchEvent route, I would have to attach it to the test1 module, right? this.addEventListener("answered", checkSingle);. How could I get the variable passed from the components (questions) to the module's checkSingle() method? There will be between 20-100 of these questions. From : Michael Wills Sent: Monday, March 09, 2009 3:21 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test
RE: [flexcoders] Moving a viewStack through actionscript
Would I put the dispatch on the radio button group of the 'Next' button? From: "Tracy Spratt" Sent: Tuesday, March 10, 2009 6:42 AM To: flexcoders@yahoogroups.com Subject: RE: [flexcoders] Moving a viewStack through actionscript Put the change handler on the RadioButton group, and in that handler dispatch your specially named, bubbling event. In the handler for that event, you can access the dispatching component through the reference in the target or currentTarget property. So you can access the value of the RadioButtonGroup through that reference. Tracy Spratt, Lariat Services, development services available From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Wally Kolcz Sent: Tuesday, March 10, 2009 8:34 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Sorry to be a pain, but when I added the parent.parent.checkSingle() it gives me an error. 1061: Call to a possibly undefined method checkSingle through a reference with static type flash.display:DisplayObjectContainer. I though my problem was the 'public var testMod:test1 = new test1();', thinking the 'new test1()' was the problem. So I removed it and just set it to a local variable. public var testMod:test1; I was able to see the checkSingle method in the auto hinting. But when I try to run it now, I get that the testMod is null. If I were to do the dispatchEvent route, I would have to attach it to the test1 module, right? this.addEventListener("answered", checkSingle);. How could I get the variable passed from the components (questions) to the module's checkSingle() method? There will be between 20-100 of these questions. From : Michael Wills Sent: Monday, March 09, 2009 3:21 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test1(parent).checkSingle(group1.selectedValue); I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::viewst...@6563ae1 to com.ipexpert.tests.test1. at com.ipexpert.questions.q1::question1/___question1_Button1_click()[D:\wkolcz\My Documents\Flex Builder 3\IPExpertBrainBuster\src\com\ipexpert\questions\q1\question1.mxml:21] Here is checkSingle() and nextQuestionPlease() public function checkSingle(answer:Object):void { if (answer !=0) { Application.application.score += 1; } currentQuestion += 1; nextQuestionPlease(); } public function nextQuestionPlease():void { questionsVS.selectedIndex=currentQuestion; } ------------ From : Michael Wills Sent: Monday, March 09, 2009 11:44 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your quest
RE: [flexcoders] Moving a viewStack through actionscript
Put the change handler on the RadioButton group, and in that handler dispatch your specially named, bubbling event. In the handler for that event, you can access the dispatching component through the reference in the target or currentTarget property. So you can access the value of the RadioButtonGroup through that reference. Tracy Spratt, Lariat Services, development services available _ From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Wally Kolcz Sent: Tuesday, March 10, 2009 8:34 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Sorry to be a pain, but when I added the parent.parent.checkSingle() it gives me an error. 1061: Call to a possibly undefined method checkSingle through a reference with static type flash.display:DisplayObjectContainer. I though my problem was the 'public var testMod:test1 = new test1();', thinking the 'new test1()' was the problem. So I removed it and just set it to a local variable. public var testMod:test1; I was able to see the checkSingle method in the auto hinting. But when I try to run it now, I get that the testMod is null. If I were to do the dispatchEvent route, I would have to attach it to the test1 module, right? this.addEventListener("answered", checkSingle);. How could I get the variable passed from the components (questions) to the module's checkSingle() method? There will be between 20-100 of these questions. _ From: Michael Wills Sent: Monday, March 09, 2009 3:21 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test1(parent).checkSingle(group1.selectedValue); I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::viewst...@6563ae1 to com.ipexpert.tests.test1. at com.ipexpert.questions.q1::question1/___question1_Button1_click()[D:\wkolcz\ My Documents\Flex Builder 3\IPExpertBrainBuster\src\com\ipexpert\questions\q1\question1.mxml:21] Here is checkSingle() and nextQuestionPlease() public function checkSingle(answer:Object):void { if (answer !=0) { Application.application.score += 1; } currentQuestion += 1; nextQuestionPlease(); } public function nextQuestionPlease():void { questionsVS.selectedIndex=currentQuestion; } _ From: Michael Wills Sent: Monday, March 09, 2009 11:44 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your question1 component knows about your test1 component. If it's a more complex app though, you may want to look at "decoupling" your app. Otherwise this app will quickly become inflexible and harder to maintain as it grows. In this case, you could set up your question components to dispatch an event
Re: [flexcoders] Moving a viewStack through actionscript
Sorry to be a pain, but when I added the parent.parent.checkSingle() it gives me an error. 1061: Call to a possibly undefined method checkSingle through a reference with static type flash.display:DisplayObjectContainer. I though my problem was the 'public var testMod:test1 = new test1();', thinking the 'new test1()' was the problem. So I removed it and just set it to a local variable. public var testMod:test1; I was able to see the checkSingle method in the auto hinting. But when I try to run it now, I get that the testMod is null. If I were to do the dispatchEvent route, I would have to attach it to the test1 module, right? this.addEventListener("answered", checkSingle);. How could I get the variable passed from the components (questions) to the module's checkSingle() method? There will be between 20-100 of these questions. From: Michael Wills Sent: Monday, March 09, 2009 3:21 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test1(parent).checkSingle(group1.selectedValue); I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::viewst...@6563ae1 to com.ipexpert.tests.test1. at com.ipexpert.questions.q1::question1/___question1_Button1_click()[D:\wkolcz\My Documents\Flex Builder 3\IPExpertBrainBuster\src\com\ipexpert\questions\q1\question1.mxml:21] Here is checkSingle() and nextQuestionPlease() public function checkSingle(answer:Object):void { if (answer !=0) { Application.application.score += 1; } currentQuestion += 1; nextQuestionPlease(); } public function nextQuestionPlease():void { questionsVS.selectedIndex=currentQuestion; } From: Michael Wills Sent: Monday, March 09, 2009 11:44 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your question1 component knows about your test1 component. If it's a more complex app though, you may want to look at "decoupling" your app. Otherwise this app will quickly become inflexible and harder to maintain as it grows. In this case, you could set up your question components to dispatch an event that your test1 then listens to. That way question1 doesn
Re: [flexcoders] Moving a viewStack through actionscript
I normally do dispatch custom events from my TitleWindows back to the parent, but was having a hard time figuring out how to pass the value of the selection (radiobutton) back to the parent to score. From: Michael Wills Sent: Monday, March 09, 2009 3:21 PM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test1(parent).checkSingle(group1.selectedValue); I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::viewst...@6563ae1 to com.ipexpert.tests.test1. at com.ipexpert.questions.q1::question1/___question1_Button1_click()[D:\wkolcz\My Documents\Flex Builder 3\IPExpertBrainBuster\src\com\ipexpert\questions\q1\question1.mxml:21] Here is checkSingle() and nextQuestionPlease() public function checkSingle(answer:Object):void { if (answer !=0) { Application.application.score += 1; } currentQuestion += 1; nextQuestionPlease(); } public function nextQuestionPlease():void { questionsVS.selectedIndex=currentQuestion; } From: Michael Wills Sent: Monday, March 09, 2009 11:44 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your question1 component knows about your test1 component. If it's a more complex app though, you may want to look at "decoupling" your app. Otherwise this app will quickly become inflexible and harder to maintain as it grows. In this case, you could set up your question components to dispatch an event that your test1 then listens to. That way question1 doesn't have to be directly connected to "parent". I hope that makes sense! Michael Wally Kolcz wrote: > > When I added the click="nextQuestion()" it was triggered off the > selecting of a radio button and not the button. Here all the code I > have. It is telling me that the viewStack doesn't exist when I believe > it should. > > test1.mxml > > > http://www.adobe.com/2006/mxml"; layout="vertical" > width="100%" height="98%" > xmlns:questions="com.ipexpert.questions.q1.*" > creationComplete="initApp()" > > > > > paddingLeft="10"> > > > > > > > > > > question1.mxml > > > http://www.adobe.com/2006/mxml"; width="98%" > height="98%"> > > > > > > > > > label="Physical" value="0" /> > label="Session" value="0" /> > label="Network" value="1" /> > label="Presentation" value="0" /> >
RE: [flexcoders] Moving a viewStack through actionscript
>, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. Raising some events from the question components strikes me as being a whole lot easier than dealing with addressing all the different objects through the heirarchy! But then when I first started out with flex I didn't know that and tried to do pretty well the same sort of thing. You could probably google and read enough on custom events to do what you need in an hour or two, you'd more than likely spend much more time trying to work out your current problems than that, I'd guess. Hth -Original Message- From: flexcoders@yahoogroups.com [mailto:flexcod...@yahoogroups.com] On Behalf Of Michael Wills Sent: 09 March 2009 22:20 To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. __ This communication is from Primal Pictures Ltd., a company registered in England and Wales with registration No. 02622298 and registered office: 4th Floor, Tennyson House, 159-165 Great Portland Street, London, W1W 5PA, UK. VAT registration No. 648874577. This e-mail is confidential and may be privileged. It may be read, copied and used only by the intended recipient. If you have received it in error, please contact the sender immediately by return e-mail or by telephoning +44(0)20 7637 1010. Please then delete the e-mail and do not disclose its contents to any person. This email has been scanned for Primal Pictures by the MessageLabs Email Security System. __
Re: [flexcoders] Moving a viewStack through actionscript
Hi Wally, sorry I missed the hierarchy there. You have checkSingle on the module and not the Viewstack. In that case, you should be able to do parent.parent.checkSingle and leave out the cast as test1. So public var testMod:Object = parent.parent; The last one failed because it was trying to convert a viewstack into a test1 which of course isn't a viewstack. But I'm not sure about this one because the parent.parent is a module. You could also forgo using the testMod variable and in your click declaration instead of click="testMod.checkSingle(group1.selectedValue)" use click="parent.parent.checkSingle(group1.selectedValue)" /> Hopefully that'll work for you. If you have a little time to invest, and if you may be doing more Flex apps in the future, even though this one is not going to be a full-on huge app, I'd learn about dispatching custom events. It's not that complicated but it takes some time to understand. It would save some of the hassle you're trying to do of course at the expense of a new and different kind of hassle. :-) Michael Wally Kolcz wrote: Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test1(parent).checkSingle(group1.selectedValue); label="Next" click="test1(parent).checkSingle(group1.selectedValue)" /> I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::viewst...@6563ae1 to com.ipexpert.tests.test1. at com.ipexpert.questions.q1::question1/___question1_Button1_click()[D:\wkolcz\My Documents\Flex Builder 3\IPExpertBrainBuster\src\com\ipexpert\questions\q1\question1.mxml:21] Here is checkSingle() and nextQuestionPlease() public function checkSingle(answer:Object):void { if (answer !=0) { Application.application.score += 1; } currentQuestion += 1; nextQuestionPlease(); } public function nextQuestionPlease():void { questionsVS.selectedIndex=currentQuestion; } *From*: Michael Wills *Sent*: Monday, March 09, 2009 11:44 AM *To*: flexcoders@yahoogroups.com *Subject*: Re: [flexcoders] Moving a viewStack through actionscript If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your question1 component knows about your test1 component. If it's a more complex app though, you may want to look at "decoupling" your app. Otherwise this app will quickly become inflexible and harder to maintain as it grows. In this case, you could set up your question components to dispatch an event that your test1 then listens to. That way question1 doesn't have to be directly connected to "parent". I hope that makes sense! Michael Wally Kolcz wrote: > > When I added the click="nextQuestion()" it was triggered off the > selecting of a radio button and not the button. Here all the code I > have. It is telling me that the viewStack doesn't exist when I believe > it should. > > test1.mxml > > > http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml>" layout="vertical" > width="100%" height="98%" > xmlns:questions="com.ipexpert.questions.q1.*" > creationComplete="initApp()" > > > > > paddingLeft="10"> > > > > > > > > > > question1.mxml > > > http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml>" width="98%" > height="98%"> > > > > > > > > > label="Physical" value="0" /> > label="Session" value="0" /> > label="Network" value="1" /> > label="Presentation" value="0" /> > > click="testMod.checkSingle(group1.selectedValue)" /> > > > -- > *From*: Michael Wills <mailto:michael%40mawills.com>> > *
Re: [flexcoders] Moving a viewStack through actionscript
Wow...its a 'simple' one time create app. All I want to do is when the user selects an answer on the question1.mxml component, they can click a button, pass the value of the radio button to the test1 module's checkSingle() method and then move to the next question in the test1 module's stack. When I changed the function call on the button of question1.mxml to test1(parent).checkSingle(group1.selectedValue); I get this error: TypeError: Error #1034: Type Coercion failed: cannot convert mx.containers::viewst...@6563ae1 to com.ipexpert.tests.test1. at com.ipexpert.questions.q1::question1/___question1_Button1_click()[D:\wkolcz\My Documents\Flex Builder 3\IPExpertBrainBuster\src\com\ipexpert\questions\q1\question1.mxml:21] Here is checkSingle() and nextQuestionPlease() public function checkSingle(answer:Object):void { if (answer !=0) { Application.application.score += 1; } currentQuestion += 1; nextQuestionPlease(); } public function nextQuestionPlease():void { questionsVS.selectedIndex=currentQuestion; } From: Michael Wills Sent: Monday, March 09, 2009 11:44 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your question1 component knows about your test1 component. If it's a more complex app though, you may want to look at "decoupling" your app. Otherwise this app will quickly become inflexible and harder to maintain as it grows. In this case, you could set up your question components to dispatch an event that your test1 then listens to. That way question1 doesn't have to be directly connected to "parent". I hope that makes sense! Michael Wally Kolcz wrote: > > When I added the click="nextQuestion()" it was triggered off the > selecting of a radio button and not the button. Here all the code I > have. It is telling me that the viewStack doesn't exist when I believe > it should. > > test1.mxml > > > http://www.adobe.com/2006/mxml"; layout="vertical" > width="100%" height="98%" > xmlns:questions="com.ipexpert.questions.q1.*" > creationComplete="initApp()" > > > > > paddingLeft="10"> > > > > > > > > > > question1.mxml > > > http://www.adobe.com/2006/mxml"; width="98%" > height="98%"> > > > > > > > > > label="Physical" value="0" /> > label="Session" value="0" /> > label="Network" value="1" /> > label="Presentation" value="0" /> > > click="testMod.checkSingle(group1.selectedValue)" /> > > > -- > *From*: Michael Wills > *Sent*: Monday, March 09, 2009 10:55 AM > *To*: flexcoders@yahoogroups.com > *Subject*: Re: [flexcoders] Moving a viewStack through actionscript > > Hey there Wally, > > You can get access to the currently selected viewstack, and also set it, > through selectedIndex. So your initial declaration would be like > click="nextQuestion()"> > > and in your function nextQuestion you can increment the selectedIndex. > I'd have to check but I think you can find the number of items in your > viewStack with numChildren. That would give you your max value to finish > your quiz or handle the end how you would like. > > You can find more about what you can do with viewstacks in the docs: > > http://livedocs.adobe.com/flex/3/langref/mx/containers/ViewStack.html > <http://livedocs.adobe.com/flex/3/langref/mx/containers/ViewStack.html> > > Hope that helps! > > Michael > > Wally Kolcz wrote: > > > > I have a test that I want to walk through the questions using a > > function. How can I set the inital value of the ViewStack > > (questionsVS) to 0 and then increment it by one each time someone > > clicks a button? > > > > paddingLeft="10"> > > > > > > > > > > > > > > > > >
Re: [flexcoders] Moving a viewStack through actionscript
If I am understanding your code correctly, you actually want to call test1(parent).checkSingle instead of testMod. The reason is because you are instantiating a brand new, and unrelated, test1 component with public var testMod:test1 = new test1(); You might be able to do public var testMod:test1 = test1(parent); casting the variable to the type test1. If it's a simple app you are working on, you can do this kind of tightly coupled design. By that I mean, your question1 component knows about your test1 component. If it's a more complex app though, you may want to look at "decoupling" your app. Otherwise this app will quickly become inflexible and harder to maintain as it grows. In this case, you could set up your question components to dispatch an event that your test1 then listens to. That way question1 doesn't have to be directly connected to "parent". I hope that makes sense! Michael Wally Kolcz wrote: > > When I added the click="nextQuestion()" it was triggered off the > selecting of a radio button and not the button. Here all the code I > have. It is telling me that the viewStack doesn't exist when I believe > it should. > > test1.mxml > > > http://www.adobe.com/2006/mxml"; layout="vertical" > width="100%" height="98%" > xmlns:questions="com.ipexpert.questions.q1.*" > creationComplete="initApp()" > > > > > paddingLeft="10"> > > > > > > > > > > question1.mxml > > > http://www.adobe.com/2006/mxml"; width="98%" > height="98%"> > > > > > > > > > label="Physical" value="0" /> > label="Session" value="0" /> > label="Network" value="1" /> > label="Presentation" value="0" /> > > click="testMod.checkSingle(group1.selectedValue)" /> > > > > *From*: Michael Wills > *Sent*: Monday, March 09, 2009 10:55 AM > *To*: flexcoders@yahoogroups.com > *Subject*: Re: [flexcoders] Moving a viewStack through actionscript > > Hey there Wally, > > You can get access to the currently selected viewstack, and also set it, > through selectedIndex. So your initial declaration would be like > click="nextQuestion()"> > > and in your function nextQuestion you can increment the selectedIndex. > I'd have to check but I think you can find the number of items in your > viewStack with numChildren. That would give you your max value to finish > your quiz or handle the end how you would like. > > You can find more about what you can do with viewstacks in the docs: > > http://livedocs.adobe.com/flex/3/langref/mx/containers/ViewStack.html > <http://livedocs.adobe.com/flex/3/langref/mx/containers/ViewStack.html> > > Hope that helps! > > Michael > > Wally Kolcz wrote: > > > > I have a test that I want to walk through the questions using a > > function. How can I set the inital value of the ViewStack > > (questionsVS) to 0 and then increment it by one each time someone > > clicks a button? > > > > paddingLeft="10"> > > > > > > > > > > > > > > > > >
Re: [flexcoders] Moving a viewStack through actionscript
When I added the click="nextQuestion()" it was triggered off the selecting of a radio button and not the button. Here all the code I have. It is telling me that the viewStack doesn't exist when I believe it should. test1.mxml http://www.adobe.com/2006/mxml"; layout="vertical" width="100%" height="98%" xmlns:questions="com.ipexpert.questions.q1.*" creationComplete="initApp()" > question1.mxml http://www.adobe.com/2006/mxml"; width="98%" height="98%"> From: Michael Wills Sent: Monday, March 09, 2009 10:55 AM To: flexcoders@yahoogroups.com Subject: Re: [flexcoders] Moving a viewStack through actionscript Hey there Wally, You can get access to the currently selected viewstack, and also set it, through selectedIndex. So your initial declaration would be like and in your function nextQuestion you can increment the selectedIndex. I'd have to check but I think you can find the number of items in your viewStack with numChildren. That would give you your max value to finish your quiz or handle the end how you would like. You can find more about what you can do with viewstacks in the docs: http://livedocs.adobe.com/flex/3/langref/mx/containers/ViewStack.html Hope that helps! Michael Wally Kolcz wrote: > > I have a test that I want to walk through the questions using a > function. How can I set the inital value of the ViewStack > (questionsVS) to 0 and then increment it by one each time someone > clicks a button? > > > > > > > > >
Re: [flexcoders] Moving a viewStack through actionscript
Hey there Wally, You can get access to the currently selected viewstack, and also set it, through selectedIndex. So your initial declaration would be like and in your function nextQuestion you can increment the selectedIndex. I'd have to check but I think you can find the number of items in your viewStack with numChildren. That would give you your max value to finish your quiz or handle the end how you would like. You can find more about what you can do with viewstacks in the docs: http://livedocs.adobe.com/flex/3/langref/mx/containers/ViewStack.html Hope that helps! Michael Wally Kolcz wrote: > > I have a test that I want to walk through the questions using a > function. How can I set the inital value of the ViewStack > (questionsVS) to 0 and then increment it by one each time someone > clicks a button? > > > > > > > > >
[flexcoders] Moving a viewStack through actionscript
I have a test that I want to walk through the questions using a function. How can I set the inital value of the ViewStack (questionsVS) to 0 and then increment it by one each time someone clicks a button?