Thursday 23 April 2009

Giving up on JSON in Flex

This morning I backed up some stuff, and after breakfast had a look in the garden. All the honey that I had put out yesterday had gone, the ants must have been busy all night, and I'm still surprised they managed to eat all of it so quickly.

Then I went on my comp and installed the latest version of the Java JDK. Weirdly it seemed to install itself in addition to the older version I already had installed, and also didn't change the %JAVA_HOME% environment variable. So I changed that to point to the latest version (jdk1.6.0_13) and restarted my PC.

After restarting I tried compc, but still got the same error
Error loading: C:\Program Files\Java\jdk1.6.0_11\jre\bin\server\jvm.dll


Doing some googling I found this post: Flex 3.2 SDK does not work with 64-bit JDK !! So I downloaded the x86 JDK, changed the %JAVA_HOME% environment variable to point at it, restarted my PC, and compc actually ran!

I compiled the JSON package into a swc using the instructions at Adobe Flex - Packaging components, and it created the swc file okay. The panel would compile okay and work with the swc included via the build file, and it didn't complain when I added import com.adobe.serialization.json.JSON; to the mxml file (If the package doesn't exist it will normally complain when you try to compile the panel). However, when I added some code in that uses the JSON package, I got an error
Error #1065: Variable com.adobe.serialization.json::JSON is not defined.


I did some googling on this, but couldn't find anything helpful. I would guess that I didn't compile the swc file that contains the JSON package properly, though I followed the instructions given by Adobe.

So I decided to try and compile the YahooSearchSample Panel that is provided as an example Panel with the XMP FileInfo SDK and see if that would work with the AS3CoreLib. First I tried to compile it without the AS3CoreLib, just to make sure it worked normally first. However, I couldn't get it to compile:
Buildfile: build.xml
[taskdef] Could not load definitions from resource flexTasks.tasks. It could n
ot be found.

clean:

buildPanel:
[echo] --> Panel 'YahooSearchSamplePanel'

BUILD FAILED
E:\Rusty's docs\my_xmp_schema\XMP-FileInfo-SDK-4.4.2\samples\panels-src\YahooSea
rchSample\build\build.xml:28: Problem: failed to create task or type compc
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/<macrodef> declarations have taken place.


The Flex location (and so the flexTasks.tasks and flexTasks.jar) were pointing to the correct place, and my panel that I'm working on still compiled without errors, so I don't know why it can't see flexTasks.tasks.

I think I'll give up on JSON in Flex and just try and use xml instead. I think the XMP FileInfo SDK actually has a guide in it on how to save (and load) user settings to an xml file, so hopefully I can just follow that.

In the afternoon I went out for a short walk, and saw a couple of Siamese twin dandelions. Then did some more work on my custom XMP File Info Panel. I found that it was no longer saving any changes made to an element by the actionscript, but it would save if I made the changes by hand. After much messing about changing different bits of code I eventually found that it would only save if the element was a textAreaMRU with a dataProvider and you must also set this.xmpModification = true; after changing the element's text with actionscript. Weird.

After dinner I did more work on my panel and found that setting the text value (using actionscript) of a XMPTextArea element wasn't working. No idea why, but changing it to a normal TextArea made it work (it wasn't writing any XMP values).

The weather today was hazy sunshine most of the day, but then clouded over about 4pm.

Food
Breakfast: Strawberry jam toast sandwich; cup o' tea.
Lunch: 2x cheese on toasts; iceberg lettuce; slice of maderia cake; 2x small clementines; double take (Sainnsbury's kitkat); cup o' tea.
Dinner: Shepherd's pie; gravy; green beans; carrots. Pudding was cherry pie (say in the style of in the Animal Crossing film) with custard. Coffee; Green & Black's Maya Gold.
Supper: Milk chocolate digestive; cup o' tea.

No comments: