1 2 Previous Next 44 Replies Latest reply on Sep 21, 2011 2:11 PM by Jerry62712

    What is the best practice - singleton & components

    Jerry62712 Level 1

      I am converting a Flex 3.5 project to 4.0 and have hit a few snags.  One issue that I'm not sure about is the way to address labels.  We switch between English and Spanish if you click a button.

       

      I decided to make the component's labels all based on a singleton class.  The label values there would alter between the languages.  I made them bindable in the singleton.

       

      1) should I directly associate the labels with the singleton "get" method for the appropriate label

      2) should I have a bindable variable in the component that is set from the singleton "get" method and then associate that variable with the various labels

       

      The first method saves a variable in the component while the second seems slightly more readable.

       

      Way one:

       

              [Bindable]
              protected var childSupLabel:String = getLabels.getExpChildSupLabel();
      
              <DHSclasses:AutoResizableTextArea 
                    id="courtOrderedChildSupportLabel"
                    text="{childSupLabel}"
                    autoResize="true" 
                    editable="false" 
                    tabEnabled="false"
                    textAlign="right" 
                    wordWrap="true"
                    left="5"
                    width="89%"/>
      

       

      Way two:

                      <DHSclasses:AutoResizableTextArea 
                          id="elderlyMedicalExpensesLabel"
                          text="{getLabels.getExpMedExpLabel()}"
                          autoResize="true" 
                          editable="false" 
                          tabEnabled="false"
                          textAlign="right" 
                          wordWrap="true"
                          left="5"
                          width="89%"/>
      
        • 1. Re: What is the best practice - singleton & components
          drkstr_1 Level 4

          Both options are coupled to the singleton, so I would say they are equally acceptable. The second options is less typing though...

          • 2. Re: What is the best practice - singleton & components
            Jerry62712 Level 1

            I kind of thought they would be functionally the same.  I only tried it because the entire form doesn't appear so I had to try something.

             

            Thanks for the reply.

            • 3. Re: What is the best practice - singleton & components
              UbuntuPenguin Level 4

              You are using a singleton when the requirement isn't that you MUST have one and only one ( ORM caches and the like ). Best practices left the building long ago.  That's like a hitman complaining about how littering shows no respect for the community.

              • 4. Re: What is the best practice - singleton & components
                Jerry62712 Level 1

                I'm using singletons (and it's still not working) because:

                 

                My component must change the label values if the user clicks a button.

                     This is to allow the user to click a display language in either English or Spanish.

                     The button is in the main mxml and should change both input and result labels de

                 

                My component must save the data entered by the user.

                     This is used to calculate the numbers that will appear in the result component.

                 

                The former way I was dealing with this was to have the component have bindable variables that the invoking main mxml could set.  This resulted in the componenet having a bucket load of variables where it is invoked.

                • 5. Re: What is the best practice - singleton & components
                  UbuntuPenguin Level 4

                  My component must change the label values if the user clicks a button. ->Presenter

                   

                  This is to allow the user to click a display language in either English or Spanish. ->Presenter


                  The button is in the main mxml and should change both input and result labels de->Presenter;

                   

                  My component must save the data entered by the user.->Model and Data Service Events

                   

                  This is used to calculate the numbers that will appear in the result component.->Model->Presenter->View

                   

                  You might want to consider breaking up such a component and divvying up the responsibility on your next assignment.  Using a singleton for EVERYTHING is just asking for trouble int he long term.

                  • 6. Re: What is the best practice - singleton & components
                    Flex harUI Adobe Employee

                    FWIW, you are encouraged to use the ResourceManager for using different

                    strings per language.

                    • 7. Re: What is the best practice - singleton & components
                      Jerry62712 Level 1

                      Thanks for the reply.  For a reason I don't understand, the Labels class doesn't update the component's labels.

                       

                      If I put in a value in the English Labels class (this is the singleton we are talking about), I see it in the component.  But when I update that class it isn't reflected in the component.  It's as if the binding only happens once and changes in the Labels are not reflected after that.  This is a key requirement of course.  The whole point of the class is that whatever value is assigned to it are automatically reflected in anything that has it instantiated.

                      • 8. Re: What is the best practice - singleton & components
                        UbuntuPenguin Level 4

                        You may want to post that "failure to bind" problem in another thread to get more views.  Generally whenever I have a binding problem, there is some type of warning that forebodes that binding will be a problem.  Do you have any of those ?

                        • 9. Re: What is the best practice - singleton & components
                          Jerry62712 Level 1

                          I have 5 warnings.  Two are "CSS type selector..." problems and three are "The style 'backgroundColor' ..." related.

                           

                          The progress I've made is I can put a value in the singleton class of English Labels and it shows up in the component.  The problem is that class which is bindable and the instantiation variable is as well doesn't seem to connect.  that is, I can see changes to the class in debugger, but they are never reflected in the component.

                          • 10. Re: What is the best practice - singleton & components
                            Flex harUI Adobe Employee

                            Post a 20-line test case and we'll take a look.

                            • 11. Re: What is the best practice - singleton & components
                              Jerry62712 Level 1

                              I have no idea how to build a test application, component, singleton class and scripts in 20 lines.

                              • 13. Re: What is the best practice - singleton & components
                                Jerry62712 Level 1

                                I've almost got it.  By using the property and not the method I can get most of the values to appear now.  The only ones that are not working (that I can see as I haven't figured out how to add scrollbars with the new system) are two arrays.  That I can't get to bind from the singleton.  I've tried theses:

                                //yesNoArray.push(English.yesNo[0]);
                                //yesNoArray[0] = 'No';
                                //yesNoArray[0] = English.yesNo[0];
                                //yesNoArray = English.yesNo;
                                //yesNoArray = [English.yesNo];
                                //public var yesNoArray:Array = [English.yesNo];
                                //public var yesNoArray:Array = new Array(English.yesNo);
                                //public var yesNoArray:Array = new Array(English.getYesNo());

                                The fourth one doesn't produce a syntax error, but it doesn't work either.

                                • 14. Re: What is the best practice - singleton & components
                                  Flex harUI Adobe Employee

                                  You’re not seeing warnings about binding to arrays?  Arrays do not send out change events.

                                  • 15. Re: What is the best practice - singleton & components
                                    Jerry62712 Level 1

                                    I see two "binding" warnings.


                                     

                                    import VO.HeaderLabels;

                                    ...

                                    public var pageTopText:HeaderLabels = HeaderLabels.getInstance();

                                    ...

                                    <s:TextArea
                                    id="fsPageTitle"
                                    text="{pageTopText.pageTitleText}"
                                    styleName="pageTitle"
                                    width="60%" height="22"
                                    textAlign="center"
                                    tabIndex="10" 
                                    contentBackgroundColor="#dedacf"
                                    horizontalCenter="0"
                                    fontSize="16"
                                    top="0" borderVisible.Input="false"/>

                                    produces this warning:

                                    Data binding will not be able to detect assignments to "pageTopText".

                                    There is a second to the next item (a s:Button).  There are the only two of the 7 warnings that relate to the word "Binding".

                                     

                                    When I view the page, both are visible and change languages if you hit the button.

                                    • 16. Re: What is the best practice - singleton & components
                                      Flex harUI Adobe Employee

                                      Without a simple test case, it is hard to determine what is going wrong.

                                      • 17. Re: What is the best practice - singleton & components
                                        Amy Blankenship Level 4

                                        If you want to bind to an Array, you need to dispatch a binding event (that tells everything that binds to something that is in the array to go look again).

                                         

                                        FWIW, Singleton is never a good practice http://misko.hevery.com/2008/08/17/singletons-are-pathological-liars .  However, I think even developers who are highly committed to clean code will bend on this enough to occasionally use the legacy Singletons that were built into the Framework before people really understood how bad they were, such as Resource Manager.  Often, they will paper over the top of it if they can, like this, http://mate.asfusion.com/news/flex-i18n-with-localizationsmaps-an-amazing-extension, to try to isolate their app from the effects of using Singletons.

                                        • 18. Re: What is the best practice - singleton & components
                                          Flex harUI Adobe Employee

                                          The discussion on the first link seems to indicate that not everyone agrees that Singletons are a bad practice.

                                          • 19. Re: What is the best practice - singleton & components
                                            kokorito Level 4

                                            of course not

                                            there are many ways to do things with flex. Do whatever works for you in whatever circumstances you are in.

                                             

                                            Singletons are relatively easy to understand and simple to use. If you are comfortable and they do the job then dont worry about others saying its bad practice.

                                            • 20. Re: What is the best practice - singleton & components
                                              Amy Blankenship Level 4

                                              Absolutely.  Only people who care about testable, loosely coupled code think Singletons are bad practice.  This is why Google's testing team has a Singleton detector.  But people who care about testable, loosely coupled code are the people who are most committed to good practice, IMO.

                                              • 21. Re: What is the best practice - singleton & components
                                                Jerry62712 Level 1

                                                Hi Amy, thanks for the post and link.

                                                 

                                                IMO, a singleton is just a tool.  Contrary to the link, it always tells the exact truth. What is put in stays in and stays in in the exact way it was put in.  However, I do see where it could be abused.  The truth often is.  Follow Politics?

                                                 

                                                I have an application with four components (header, input, output and footer).  Information in each changes format (English to Spanish or back) if the user desires.  I was passing in a bucket load of parms to the components to do this.  Looking at singletons, I saw a way to have one and only one source to the various labels and texts in all the components.  I can change the one place and know everyone has the current language.  It reduced the coding a lot which is always one of my goals.

                                                 

                                                I'm converting it from 3.5 to 4 and hope to convince my management to keep Flex by demonstrating it is still viable.  I want to convert this to an app at some point, but first I have to convince them to go to 4.5.  I figure the conversion from 4 to 4.5 would be a lot easier than 3.5 to 4.5.  A lot of people are talking going .net and that is what I'm the lone voice fighing.

                                                 

                                                Perhaps there is a more elegant way in Flex and I would be glad to hear of it.  I haven't seen anything that would indicated this approach is not a good one.  But I would always accept that there are new techniques.  When I started programming, spaghetti code was going out of style.  Procedures were all the thing and they were much better (easier to maintain) than the prior method.  Now-a-days everyone would say OO is better than procedures and they have a valid case.  As with all major changes, there have been submodification.  And that is where this discussion has been based.

                                                 

                                                I see this as stepwise refinement.  Read Asimov's article on this subject for an interesting and informative time.

                                                • 22. Re: What is the best practice - singleton & components
                                                  Jerry62712 Level 1

                                                  The main problem I have in defending Flex here is the lack of support or knowledge base.  For example, I've tried for over a week to find out how to assign an array to another array and no one has suggested a way that works.  My management doens't want to hear excuses and I'm running out of them anyway.  I've shown then the Adobe knowledge base (first place I looked) and the threads here.

                                                   

                                                  I don't think we have a support contract for Flex (we do for LiveCycle) so I haven't called Adobe.  Given this is one of the most expensive softwares existing you would think there would be better support.  Or if I were a lot smarter I wouldn't need it.  I was a technical editor for Osborne-McGraw/Hill after all, but this doesn't come (especially 4.0) as easily or naturally as prior languages did.  For example, now I have to have 100 lines and a new class to add an back ground image where with 3.5 it took 2 lines of CSS.

                                                   

                                                  [off my soapbox]

                                                  • 23. Re: What is the best practice - singleton & components
                                                    Amy Blankenship Level 4

                                                    Hi, Jerry;

                                                     

                                                    You haven't lived until you have to figure out exactly which part of a large application is screwing up the global/static/Singleton state .  Hopefully you never will have to.

                                                     

                                                    Many developers who have been around a long time can't conceive of how to get values to where they need to be without falling back on their old procedural habits (http://sites.google.com/site/steveyegge2/singleton-considered-stupid) .  And I'd agree that manual dependency injection (where you give information to a parent component that it doesn't need, but that needs to be passed to a child component) is only maginally better.  However, today, we have many automated dependency injection frameworks, such as Mate, Robotlegs, and Swiz.  Even Cairngorm, which used to be based on global variables/Singletons, has moved to sitting on top of Parsley, an automated dependency injection framework.  Adobe Consulting explains the change in approach this way http://blogs.adobe.com/tomsugden/2009/08/applying_the_presentation_mode.html .

                                                     

                                                    If you don't want to use a full on DI framework, you can use the princples (http://www.developria.com/2010/04/combining-the-timeline-with-oo.html, http://www.developria.com/2010/05/pass-the-eventdispatcher-pleas.html).  The thing is, these frameworks are starting to become fairly mature, and they've already solved problems you won't think of until you run into them.

                                                    • 24. Re: What is the best practice - singleton & components
                                                      Amy Blankenship Level 4

                                                      I'm not sure what you're asking about the array.

                                                       

                                                      It could be as simple as:

                                                       

                                                      var arrA:Array = [0, 1, 2];

                                                      var arrB:Array = arrA;

                                                       

                                                      or it could be something more complicated.  Look at the docs for Array--they're very thorough.  Possibly concat can do what you need, if the above doesn't work.

                                                       

                                                      The help for Flex is excellent in comparison to other apps, and there is a large and extremely helpful community.  Also look at stackoverflow.com.

                                                      • 25. Re: What is the best practice - singleton & components
                                                        Jerry62712 Level 1

                                                        I couldn't get to the first link (blocked here), but I did read the others including your blog.  Thanks for the links.

                                                         

                                                        I came up with the idea of using the singleton because we are using Cairngorm and that is how they do it.  That is a pretty big project that has taken Deloitte about a year and a half to code for us.  It's a Flex and LiveCycle system that my team will take over next month.

                                                         

                                                        Thanks for your time.  I realize time is pretty sparce!

                                                        • 26. Re: What is the best practice - singleton & components
                                                          Jerry62712 Level 1

                                                          You would think it would be simple.  I assume everyone here know more about it than I do and none of them have been able to figure it out.  I have a singleton that has the values for labels and text.  I can then change the singleton with the appropriate literals and it automatically (via binding) is reflected in the various display components.

                                                           

                                                          This works like a charm for the string variables, but this fails:

                                                          import DHSclasses.FSLangEnglish;

                                                           

                                                          private var English:FSLangEnglish;
                                                          private static var instance:ArrayValues;

                                                           

                                                          // default English version values
                                                          // if the user clicks "Spanish" they will be replaced with those values
                                                          public var yesNoArray:Array = new Array('0','1');
                                                          //yesNoArray.push(English.yesNo[0]);
                                                          //yesNoArray[0] = English.yesNo[0];
                                                          //yesNoArray = English.yesNo;
                                                          //yesNoArray = [English.yesNo];
                                                          //public var yesNoArray:Array = [English.yesNo];
                                                          //public var yesNoArray:Array = new Array(English.yesNo);
                                                          //public var yesNoArray:Array = new Array(English.getYesNo());

                                                          [ I don't know why this gets put in a table, sigh.]

                                                           

                                                          I don't see this as a binding issue as I'm just trying to initially set some values in the two arrays.  I can initialize it, but I would still have the problem of assigning it.  Might as well face the issue head on now.  In the English class yes/no looks like this (incase I'm making some real stupid assumption which I'll admit is probable):

                                                          public const yesNo:Array = new Array(["No","Yes"]);
                                                          public function getYesNo():Array {return yesNo;}

                                                           

                                                           

                                                           

                                                          Creating the array and initializing it isn't the problem.  Changing the value is.  None of the above work.  I only recently started commenting the failures (this has been going on for over a week) to keep track of them.  The fourth one is syntactically correct, but doens't work.  All the rest fail syntax.

                                                           

                                                          This is just to initialize the values.  I will have scripts that use class FSLangEnglish or FSLangSpanish to set the values depending on the user's clicking a button.

                                                          • 27. Re: What is the best practice - singleton & components
                                                            Amy Blankenship Level 4

                                                            As I already said, if you're dead set on using an Array, which is not designed for Binding, then you need to dispatch your own binding events when it changes.  Which means that you need to use a getter/setter pair rather than just a variable.

                                                             

                                                            Or you could just use ArrayCollection, which has already done all the work to allow for Binding.

                                                            • 29. Re: What is the best practice - singleton & components
                                                              Ansury Level 3

                                                              Singleton usage, right or wrong?

                                                               

                                                              Answer: As usual, "it depends".

                                                               

                                                              Anyone that says otherwise is either stubborn/ignorant, or they haven't seen (or been able to visualize) a situation differing from their own niche environment.

                                                              • 30. Re: What is the best practice - singleton & components
                                                                Amy Blankenship Level 4

                                                                Or they have seen it, and been confronted with the reasons why it's bad practice, in spades :-).

                                                                • 31. Re: What is the best practice - singleton & components
                                                                  Ansury Level 3

                                                                  The main problem I have in defending Flex here is the lack of support or knowledge base.  For example, I've tried for over a week to find out how to assign an array to another array and no one has suggested a way that works.  My management doens't want to hear excuses and I'm running out of them anyway.  I've shown then the Adobe knowledge base (first place I looked) and the threads here.

                                                                   

                                                                   

                                                                  Try StackOverflow or the flexcoders group for (yeah I know, developer not Adobe) support as well.

                                                                   

                                                                  But this begs the question, why are you upgrading from 3.5 to 4.0 in the first place?  I don't know if this is 'official' advice but what I've heard is that if you don't have a darn good reason, the general recommendation is to not bother upgrading your SDK.

                                                                   

                                                                  If you have a new project use 4.x, already-developed apps, leave them as is - it's a fairly common practice in my experience.  As for the Flex vs (whatever), you may have a hard time going up against Silverlight or any "true" RIA platform, but I could point you to a ton of posts pointing out the strengths of Flex...

                                                                  • 32. Re: What is the best practice - singleton & components
                                                                    Jerry62712 Level 1

                                                                    I will certainly look at that once I get past the syntax.  And I really mean that.  I usually listen to those that know it better than I do.

                                                                     

                                                                    One error I'm getting on just trying to put the English into the initial creation of the Array class is the major holdup (at this time until it is fixed).  When I step through the code this statement doens't create a syntax error:

                                                                     

                                                                    public var yesNoArray:Array = English.yesNo;

                                                                     

                                                                    But "English" is a null reference resulting in a run time error.  Prior to that statement I have:

                                                                    [Bindable]
                                                                    public class ArrayValues
                                                                    {
                                                                    import DHSclasses.FSLangEnglish;

                                                                     

                                                                    private var English:FSLangEnglish;

                                                                     

                                                                    My assumption was 1) the import would make the class available, 2) the var assignment would give a local object to reference the class and 3) since code assist works and I can see the property or method it should work.

                                                                     

                                                                    Obviously I'm wrong as it doesn't work.  Further, I tried to create a local string to accept any of the strings in that class and that was a syntax error:

                                                                    public tst:String;

                                                                    tst = English.getCalcButtonLabel();

                                                                    error (on txt = line):

                                                                    Multiple markers at this line:

                                                                    -tst

                                                                    -1120: Access of undefined property English.

                                                                    -1120: Access of undefined property tst.

                                                                     

                                                                    You can see why this has taken over a week.  Sigh.

                                                                     

                                                                    I did try to change everything to an array collection and that resulted in this error:

                                                                    Multiple markers at this line:

                                                                    -ArrayCollection

                                                                    -1046: Type was not found or was not a compile-time constant: ArrayCollection.

                                                                    based on this code:

                                                                    public const yesNo:ArrayCollection = new ArrayCollection(["No","Yes"]);
                                                                    public function getYesNo():ArrayCollection {
                                                                    return yesNo;}
                                                                    • 33. Re: What is the best practice - singleton & components
                                                                      Jerry62712 Level 1

                                                                      Hi Ansury,

                                                                       

                                                                      I'm doing the conversion to learn Flex 4 and to convince management that we should still be looking at Flex.  Management isn't developing new stuff in Flex and I'm trying to make the case that it is worth the effort.  The choice I have it to not use Flex or to upgrade the application.  There will be no future Flex applications if mananagement isn't happy with it.  I would be surprised if Adobe's official position was to abandon Flex.

                                                                       

                                                                      No need to convince me to try to stick with Flex.  I wouldn't have wasted a week of my life trying to do a simple array assignment if I were not committed to trying to stay with Flex.

                                                                      • 34. Re: What is the best practice - singleton & components
                                                                        Jerry62712 Level 1

                                                                        Because I listen, I tried to change the arrays to array collections.  Failure.  In the initial class (English) I put in this:

                                                                        public const yesNo:ArrayCollection = new ArrayCollection(["No","Yes"]);
                                                                        public function getYesNo():ArrayCollection {
                                                                        return yesNo;}

                                                                         

                                                                        The error was this (function line):

                                                                        Multiple markers at this line:

                                                                        -ArrayCollection

                                                                        -1046: Type was not found or was not a compile-time constant: ArrayCollection.

                                                                         

                                                                        It was imported as the doc said it would be.  One step forward and two back.

                                                                        • 35. Re: What is the best practice - singleton & components
                                                                          Amy Blankenship Level 4

                                                                          When you use code that assigns the value of a variable to another variable, it needs to be inside a function body (for example, a constructor).

                                                                           

                                                                          So, you can do this:

                                                                           

                                                                          public var tst:String = DHSclasses.FSLangEnglish.getCalcButtonLabel();

                                                                           

                                                                          or you can do this:

                                                                           

                                                                          protected var English = DHSclasses.FSLangEnglish;

                                                                          public var tst:String

                                                                           

                                                                          public function ArrayValues() {

                                                                             tst= English.getCalcButtonLabel();

                                                                          }

                                                                           

                                                                          However, you might want to consider something more like this:

                                                                           

                                                                          protected var language:ILanguage;//your language interface will define getCalcButtonLabel() and whatever other functions are common between languages;

                                                                           

                                                                          public function ArrayValues(language:ILanguage) {

                                                                               this.language=language;

                                                                          }

                                                                           

                                                                          public function get tst():String {

                                                                               return language.getCalcButtonLabel;

                                                                          }

                                                                           

                                                                          You could also allow the language to change at runtime by providing a getter/setter pair for language, and dispatching a custom binding event (that all the other properties declare) when it changes.  Flash Builder 4.5 provides autogeneration to do this for you.

                                                                           

                                                                           

                                                                          This then becomes a truly reusable component, rather than the glued-in-place thing you're trying to do.

                                                                           

                                                                          For the ArrayCollection issue, I'd suggest putting your cursor on the word "ArrayCollection" in the import statement, then pressing F3.  If that takes you to the source code for AC, I'm not sure what's wrong.  If it doesn't (which I think it might not), try cleaning your project.  If that doesn't work, delete all the files and folders in bin-debug and clean again.  If that doesn't work, close and reopen FB.

                                                                           

                                                                          HTH

                                                                          • 36. Re: What is the best practice - singleton & components
                                                                            Flex harUI Adobe Employee

                                                                            Jerry,

                                                                             

                                                                            I keep asking for a simple test case.  It should only take an hour or so to create, much less time than you’ve spent and we’ve spent trying to guess how your code works from snippets.  There are two common approaches to creating such a test case.  One is to start from an empty app and copy in a few things at a time, another is to start with a copy of the current app and comment stuff out.  A test case is unambiguous.  I put it into the debugger and the problem will appear and we can make explicit recommendations.  Emails and code snippets are way to ambiguous.  Flex isn’t particularly hard, and the folks on the forum are quite helpful, but you have to help us help you by removing ambiguity.  I know the temptation is to hope that spending 30 seconds to send a snippet and question will save you from the hour of creating the test case, but the way I see it, there are several advantages to taking the hour to prepare the test case.  They are:

                                                                                -you might be waiting that hour for a response anyway,

                                                                                -in preparing the test case, a significant number of people discover the solution on their own, long before the hour is up

                                                                                -the chances you’ll get bad advice goes way down.

                                                                                -the inability to create a test case quickly serves as an indicator that your app is not modular enough

                                                                             

                                                                            I have touched many of the support issues you’ve logged via your support contract with Adobe.  Their process is also quite similar.  The support tech will ask for a simple test case.  By using the Adobe Support, you will get guaranteed, dedicated responses.  That’s what you’ve paid for.  Use it to your advantage.

                                                                             

                                                                            You are welcome to fire off the quick 30-second question, but when a responder asks for a test case, it is time to take the time to create one.  Also, you started your last reply by saying “I listen”, but Amy and I both have mentioned the Array event dispatching issue and I have asked for a test case several times.

                                                                             

                                                                            I will repeat a guess one more time as to the nature of this particular problem, which I described in an earlier response, then I will no longer respond to this thread until I see a simple test case posted.  And that is: The variable for the English class is not being initialized before it is being used.  When you step through in the debugger, all get functions in the class get called in order to populate the debugger’s variables pane, and that can cause initialization of values to occur in a different order than when you just run the app.  Variables with metadata are implemented as get functions so they can be affected.

                                                                             

                                                                            Adobe wants all of our customers to continue to use Flex.  Flex’s main advantage is reduced development costs.  The best way to show your management the advantages of Flex is the continue to improve your development practices to be more efficient, and that includes the development of modular code, use of existing features like the ResourceManager instead of trying to develop your own, and a refinement of the way you use resources like forums, the internet, and Adobe Support in getting your application ready for production.

                                                                             

                                                                            Going from Flex 3 to Flex 4 is a big change in development practices if you want to use the Spark components.  The principle behind Spark was to enable designers to control every aspect of the visuals without having to learn about ActionScript and CSS styles.  If that principle does not provide a significant advantage to you, then the MX components may make you happier.  Spark also provides a consistent skinning workflow.  If you don’t do much custom skinning because everything you need to change is available via CSS, then you also have less of a reason to use the Spark components. You can still move to Flex 4 and use the MX components and still get the advantages of two-way data binding, the new states syntax, and more.  Just use the MX components and specify the Halo theme, as I have suggested before.

                                                                             

                                                                            -Alex

                                                                            • 37. Re: What is the best practice - singleton & components
                                                                              Ansury Level 3

                                                                              Jerry - My advice would be to stick with Halo components when upgrading, in fact when creating a new project I generally always select "mx" (or Halo?) only rather than a combined mx/s project.  Is the Spark component set even complete in SDK 4.5?  It was missing major components at release forcing you to mix component sets...

                                                                               

                                                                              Spark is primarily for skinning, as harui stated, and if you're upgrading what sounds like a business app... you just don't need it.

                                                                               

                                                                              Not sure if dropping Spark solves your main issue here (sorry but not enough time to read the entire thread), but if it does, Halo + 4.1 or 4.5 is still Flex 4.  Btw your management sounds like a bunch of dummies.  Tell them to stop drinking the Steve Jobs kool aid. 

                                                                              • 38. Re: What is the best practice - singleton & components
                                                                                Jerry62712 Level 1

                                                                                Again I want to thank you for the reply.  By eliminating the setting of the array in the singleton I got past the syntax error.  It still doesn't work, but at least it is further. 

                                                                                 

                                                                                The getter (English.getYesNo) seems to be populated and the assignment in SetEngInput (setArrays.getYesNoArray) seemed to accept the values from the getter based on stepping through it.

                                                                                 

                                                                                No values appear in the component, but that might be due to the binding issue you mentioned.  I have a break point in that componenet where the variable is set and I don't hit that break point.

                                                                                 

                                                                                I had changed all the "Array" variables to "ArrayCollection" but that created syntax errors.  Trying again I don't see those errors, but it still didn't work.  That is, all the labels and text showed up as expected, but the arrays didn't.

                                                                                 

                                                                                Once this is working I have no problem with "updating" it to use the "ILanguage" suggestion.  I'm afraid that that would be beyond me given this rather simple thing is not working.  It may even prove to be simpler once it is all said and done.

                                                                                • 39. Re: What is the best practice - singleton & components
                                                                                  Jerry62712 Level 1

                                                                                  Thanks for the involved response!

                                                                                   

                                                                                  I see two problems to your suggestion.  One is I have no idea of how to take an MXML, component, base class to hold verbiage, script, singleton and put it all in a couple of lines (20 or 40).  The second is I'm not sure how to do this without affecting something else.  While this may be easy as pie to you guys, it's something I haven't done before so it isn't so easy for me.

                                                                                   

                                                                                  I know you like the resource manager, but to my understanding of it, it is completely useless in this case.  I thought I had expressed that twice before. Perhaps I just wasn't clear or clear on the resource manager.  Is there some way the resouce manager can tell if the person using the computer down at your local library is Hispanic or English?  While I can't imagine how, I don't know everything so I ask.

                                                                                   

                                                                                  My understanding is Adobe doesn't plan on supporting 3.5 for very far into the future.  I believe I heard that right here in this forum, perhaps from you.  IAC, my ultimate goal is to convince managment to go to 4.5 so I can make this into an app.  I work for a state government and another one has expressed interest in our existing java version.  We had to drop the 3.5 version because one of our vendors was using technology that prevented them from programmatically seeing the Flex version due to using low level calls to the browser.  Imagine the interest if we give them (I don't think we sell code - at least I've never heard of that) the code for an app!  They would have to have the code as their standards are probably not the same as ours.

                                                                                  1 2 Previous Next