Reverse engineer a Flash/AMFPHP view

Events happening in the community are now at Drupal community events on www.drupal.org.
wishbone's picture

I hope this is the appropriate place for this question. I have searched around but cannot find an answer. Hopefully someone here can help:

I am building a Flash/AMFPHP/Drupal site. I populate the Flash from Views.
I had a working view into Flash but somehow screwed it up (don't ask!)...

Background info:
I have created a Custom Content Type called "music" using the CCK audio_field.
I have a view that collects all nodes of this type.

In Flash I push the "Titles" and the "Bodies" into two arrays using this:

      private function getMP3s(result:Object):void
       {
          for (var i = 0; i < result.length; i++)
            {
              MP3Titles.push(result[i].title);
               MP3Urls.push("http://www.mySite.com/"+result[i].field_audio[0].filepath);
            }
          createMenu();
          playMP3(0);
            trace("MP3Titles are "+MP3Titles);
           trace("MP3Bodies are "+MP3Urls);
     };

And here is the breakdown of my view:
name: audio
access: anonymous, authenticated
description: audio view for Flash
page view URL: audio
view type: full nodes
fields: file:Path (label: Body)
Filters: Node: Type, Audio

My question is about rebuilding the view.
I have been unable to rebuild the view to successfully pull in these arrays. I have the "Titles" array but the "Bodies" are null.

Can someone give me a pointer on building my view so my "Titles" array will work? I could also open the Drupal up to someone if it would help diagnose the problem.

Comments

This may help

behindthepage's picture

I found this tutorial very helpful.
http://www.pictulog.net/bin/node/317

Regards
Geoff
The user previously known as gpdinoz

Interesting Link, but...

wishbone's picture

Thanks for replying gpdinoz. Interesting link, but not really much help. Since I am using a view and not a module for services output, and using Flash instead of Flex - it doesn't really help me at this time. Next time I will be trying Flex instead of Flash.
Anyone care to read my plight and offer suggestions?

View type doesn't matter

bmcmurray's picture

The display type of your view doesn't matter. If it is returning the type of content you want then it will work in Flash. From flash you should pass an array of fields that you want the service to return when you call it -- make sure that you are asking for all of the fields you want: title, body, field_audio

B.McMurray

B.McMurray

View type

wishbone's picture

Hi Brian,
The View works just fine in Drupal. But Flash can't understand it due to the array I am using in Flash. I have no problem adjusting the array of fields from Flash. And the titles array works fine. But since I can't get feedback on the fields pushed out from Drupal I can't make Flash understand them.
MP3Urls.push("http://www.mySite.com/"+result[i].field_audio[0].filepath);

So far I have tried both "field_audio" and "field_file" (using the CCK filefield module) but neither return the path to the file.
Strange for sure. Any other ideas? Care to look at my source or my view?

Try this...

bmcmurray's picture

Flash can be particular about the syntax for accessing an associative array's values. Try the following syntax and see if it accesses the filepath that you're looking for.

result[i]['field_audio'][0]['filepath']

B.McMurray

B.McMurray

Brain, I mean Brian

wishbone's picture

PERFECT!
I owe you a beer, maybe 6!

possum4all's picture

In case others find this post while searching for parsing solutions... I just wanted to add that using the devel module can help you find and use object elements for anything inside a node without busting open a database or template file. It helps ID field elements, views, node elements, etc.

Being more of a designer type, I'm finding that it's not always real clear where all the elements inside data objects are stored and how to get to them (I don't do much db stuff). I was having an especially hard time finding the element IDs (names? properties?) for a field_image Array nested inside a parent node object. I could parse the node but couldn't get to the child array IDs. Devel helped.

Once I found the element IDs, it was easy to use them inside Flex, AS3, and/or Flash class files.

Services

Group organizers

Group categories

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: