Adobe Flex 2 Training from the Source
Posted in Flex |
Mar 21, 2007 10:05:AM |
So the last week I have been reading "Adobe Flex 2 Training from the Source". I have my Advanced ColdFusion training at the end of May, and want to get through this book before I go. I am on Chapter 5 and ran into a problem.
While working on an AS 3 script I was getting an error when I would compile my code. The book for those that don't know about it is simple a step by step guide to creating a Flex app and explains all the features and components of Flex along the way. A great book for getting your feet wet with Flex 2.0.
So following the step by step guide of the book, I found a problem.
Code
<mx:Script>
<![CDATA[
import valueObjects.Product;
[Bindable]
private var theProduct:Product;
private function prodHandler(theItems:Object):void
{
theProduct = new Product(theItems.catID, theItems.prodName, theItems.unitID, theItems.cost, theItems.listPrice, theItems.description, theItems.isOrganic, theItems.isLowFat, theItems.imageName);
trace(theProduct);
}
]]>
</mx:Script>
Now the book doesn't give you the whole code in this Chapter but rather tells you what to replace and what to add and where. Looking at the code it took me an hour to figure out where the problem was.
Code
private var theProduct:Product;
So on this line I was getting this error:
Severity Description Resource In Folder Location Creation Time Id
2 1046: Type was not found or was not a compile-time constant: Product. EComm.mxml flecGrocer line 12 March 21, 2007 3:52:37 PM 342
Then this line:
Code
theProduct = new Product(theItems.catID, theItems.prodName, theItems.unitID, theItems.cost, theItems.listPrice, theItems.description, theItems.isOrganic, theItems.isLowFat, theItems.imageName);
I got this error.
Severity Description Resource In Folder Location Creation Time Id
2 1180: Call to a possibly undefined method Product. EComm.mxml flecGrocer line 16 March 21, 2007 3:52:37 PM 343
I check my action script file and was stumped. The problem? Well was one character error. See when you create a new action script file in Flex, you can define a package i.e. a folder name. I forgot to add the "s" to valueObjects when I created my Product.as file. Now I know it wasn't the authors fault but it did teach me something, that in the future could have wasted hours of unwanted error checking.
So what's all this about, simple double check your spellings. hehe
Print