Have you checked the book website errata?
Sent from my iPhone
El 28/06/2009, a las 13:01, michael nieuwenhuizen <email@example.com>
I've been learning Flex, and been working with some example from a
book (Learning Flex 3: Getting Up To Speed With Rich Internet
Applications), but in one chapter (12: States) all the examples give
the same mysterious error: the Project shows an error (with the
white cross on a red background), but neither the mxml file I just
created nor any of the other files have an error message. Still,
there's part of the code that supposedly has the error, cos when I
take it out the error message for the Project disappears. If I try
to run the project it tells me there is an error, and if I still
proceed the application crashes saying something about a State not
The error happens in this bit of code:
<mx:SetProperty target="" name="title" > value="New User Registration"/> > <mx:SetProperty target="" name="label" > value="Register"/> > <mx:SetProperty target="" name="label" > value="Already have an account with us?"/> > <mx:SetEventHandler target="" name="click" > handler="currentState=''"/> > <mx:AddChild relativeTo="" > position="firstChild"> > <mx:FormItem id="fullNameFormItem" label="Full Name:"> > <mx:TextInput/> > </mx:FormItem> > </mx:AddChild> > <mx:AddChild relativeTo="" > position="lastChild"> > <mx:FormItem id="confirmPasswordFormItem"> > <mx:TextInput displayAsPassword="true"/> > </mx:FormItem> > </mx:AddChild> > </mx:State> > </mx:states> > > All the target like etc exist. What am I doing wrong?
Yes, I checked the website, and there is no errata. In fact the code online and with much more detail, and still I get the same error message. Have a look at http://greenlike.com/flex/learning/12/ContactManager/srcview/ for example. If I just copy&paste the code given, and try to run it I get an error message without there being an error message for any specific line of the code. The application doesn't seem to work properly.
By the way, if I try to export a release build, I get an error message:
One or more errors were found trying to build the release version. Unable to export.
and no reason give. Looking at the details I get:
Encountered errors or warnings while building project states.mxml.
states.mxml: Type was not found or was not a compile-time constant: states. [Generated code (use -keep to save): Path: /Users/Mike/Programming/Eclipse/workspace/LearningFlex/src/generated/states-generated.as, Line: 424, Column: 14]
I'll take a look at the link later. Who wrote that book?
Could you please explain how you created the project.I tried the same code in your link.But its working fine for me.
Michael -> the guy who wrote the book is called Alaric Cole. The book gets 4.5 stars on Amazon, and rightly so, it's a very good book.
DM -> I just created the project the normal way, with all the default values. The rest of the project works fine, but if I add this example with states it doesn't work anymore. The project is shown below in the image attached. As you can see there is an error flag for the project, but no error flag for any of the files. Still, if I clear the mxml application with the code above the error message disappears, so it;s definitely in this file.
By the way, the error message is:
Type was not found or was not a compile-time constant: states. [Generated code (use
-keep to save): Path: /Users/Mike/Programming/Eclipse/workspace/LearningFlex/src/
generated/states-gen erated.as, Line: 424, Column: 14]
and if I go to that line the code is:
var target:states = this;
flex.jpg 41.8 K
The issue maybe that you can't name your file states or anyother key words. so simply change it to something like myStates.mxml