11 Replies Latest reply on Jun 14, 2006 7:57 AM by ezalife

    setter and return value problems

    ezalife
      right, i'm trying to rebuild a flash fla using a decompiler program.
      i've got all the as files but can't change the function/method calls.
      the problem is that when i compile the fla i get the error:

      **Error** C:\CMA_reverseEng Dev\Engine\Candidate.as: Line 46: A setter function may not return a value.
      return this.__get__Name();

      which partially makes sense as i've been told that setters can't return values.
      problem is that these are from the very same .as files which created the original engine which worked fine.

      any suggestions... a cut down version o the *.as file in question below:

      Ps. i'm using MX 2004 Pro, on windows, exporting for v7 with AS2.0

      class Candidate{
      var __uci: String = "";
      var __name: String = "";
      var __dob: String = "";
      var __candidateNumber: String = "";
      var __centreNumber: String = "";

      function Candidate() {
      }

      function get Name() {
      return this.__name;
      }

      function set Name(state) {
      this.__name = state;
      return this.__get__Name();
      }
      }

      regards, Rich
        • 1. Re: setter and return value problems
          Level 7
          So what is your question anyway? It actually makes no sense for a setter to
          return a value, which is why the function type should be Void. Especially in
          this case - you'd be returning the value of name, which you are setting - so
          you already have it. What would returning anything get you?

          Candidate.name = "Dave";
          trace(Candidate.name);
          // Dave

          Also, for sake of convention, Class names are initial capped, not function
          names.


          --
          Dave -
          Adobe Community Expert
          www.blurredistinction.com
          http://www.adobe.com/communities/experts/


          • 2. Re: setter and return value problems
            neil manuell
            function set Name(state) {
            this.__name = state;
            return this.__get__Name();
            }

            well this is the baddie just remove the line:
            return this.__get__Name();

            no?
            • 3. Re: setter and return value problems
              ezalife Level 1
              I agree to all intents and purposes this is the baddie line.
              The confusion i have is that i've inherited the code from a fully working, without errors swf.

              I've taken the code directly from the Flash Decompiler program and ended up with a class with many setter methods each containing a return statement.
              This must have been there in the original swf and must also have worked (the swf worked) yet it won't compile and everywhere seems to imply that it is impossible for it to work. yet it did. this is my confusion... does that make sense?
              • 4. Re: setter and return value problems
                ezalife Level 1
                there's another example (attached) in the same class file yet it has no corresponding 'get Data' function..
                i guess i'm asking if you know why it worked in the first place - pre decompiling - and if there are any exceptions to the 'function set & no returns rule'
                re conventions - yup, agree, but i didn't write this code so i'm avoiding making any name changes etc until i can get the code working in it's current form then can worry about impliment correct conventions

                cheers guys
                • 5. Re: setter and return value problems
                  Level 7
                  I don't think it ever worked... I did a simple class test and made the
                  following setter:

                  function set aNum(someNum){
                  myNum = someNum;
                  }

                  When decompiled with ASV I get the following function:

                  function set aNum(someNum){
                  myNum = someNum;
                  //return (aNum);
                  }

                  Although it's commented out, unlike in your example. Also, I'm not sure if
                  this is the compiler at work, or the decompiler. But either way - setters
                  can't return values so you need to remove the returns.

                  --
                  Dave -
                  Adobe Community Expert
                  www.blurredistinction.com
                  http://www.adobe.com/communities/experts/


                  • 6. Re: setter and return value problems
                    2m Level 2
                    What makes you so sure that your decomiler does return you everything perfectly right?
                    • 7. Re: setter and return value problems
                      ezalife Level 1
                      good point - I assumed, perhaps wrongly, that the decompiler in question (Flash Decompiler 2.9 from Eltima) would perform the swf extraction correctly.
                      Am i wrong? This is my first experience using a decompiler and maybe i'm putting to much faith in it's abilites and it's inventing the return statements... - is that possible?
                      • 8. Re: setter and return value problems
                        2m Level 2
                        I don't have a lot of expirience with decopilers, so I can't answer your question, and to be blunt, I'm not sure if I really want to support your cause.

                        Why can't you just ask the person that has built it originally? Or why not just built your own?

                        It's none of my buissness though.
                        • 9. Re: setter and return value problems
                          ezalife Level 1
                          simply put, the person who wrote the engine/code had a disagreement with the company and got laid off, then they stupidly wiped his company PC before realising all engine sourcefiles were on it. I'm not trying to rip off someone else code as it's the companies intellectual copyright - just don't have the time or experience to spend weeks writing a new engine from scratch to work with all the courses currently using the existing one.

                          Hence the decompiler route as a last resort to save the companies ***.
                          • 10. Re: setter and return value problems
                            2m Level 2
                            ...I thought something like that, and didn't want to accuse you of anything. I still don't know where to put my sypathies are with the guy or withe the comany firing him, blanking the machine, having no backup.

                            Seems you are the poor one now.

                            I wouldn't think that a deomiler "invents" stuff, but who knows. What about tryning another one?

                            Another wild guess could be that thae Function in question was called "set-Data" or something, and that the deconpiler for some reason dropped what Character was there before. Just wild guess work though.
                            • 11. Re: setter and return value problems
                              ezalife Level 1
                              oh definitly with the guy, TBH i laughed when i realised they'd wiped the source - i may moan about the process but it's a challenge at it's keeping me employed so can't complain And i understood where you were coming from - gotta be 99% of peeps use decompilers for ripping off anothers work.

                              interesting about the hyphen substitution or somesuch thing. cheers for the pointer and i'll see how it goes finding another prog to. Rich