Posted by wishbone on September 16, 2008 at 5:04pm
Hello Drupalistas!
I have Flash consuming AMFPHP services from Drupal. Now I want to build a "mixed" content type and serve that through AMF as well. So I added a CCK "image_field" to the "Page" content type. Now I have an image associated with every "page". This is fine and good, and my services browser shows this:
[log] =>
[format] => 1
[uid] => 1
[name] => admin
[picture] =>
[data] => a:0:{}
[field_image] => Array
(
[0] => Array
(
[fid] => 1
[title] => image1.jpg
[alt] => image1.jpg
[nid] => 1
[filename] => image1.jpg
[filepath] => files/image1.jpg
[filemime] => image/jpeg
[filesize] => 46444
)
)So my image is now an object in an array ("0"). Good so far...
The only problem is I cannot get that value to return in Flash. I have tried these two attempts (and variations of both of these) until I can't see straight. And I can't get it to work.
imageURLs.push("http://site.com/360i/"+result[i]['field_image'][0]['filepath']); and also..
imageURLs.push("http://site.com/360i/"+result[i].field_image[0].filepath);Any ideas or hints for me on what I am doing wrong?
Thanks,
Wishbone
Comments
Is the result[i]
Is the result[i] needed?
What if you try the following:
imageURLs.push("http://site.com/360i/"+result['field_image'][0]['filepath']);
CLose, but not yet...
A term is undefined and has no properties.
This is what I've gotten for all the methods I've tried so far. The best I can do (so far) is by stripping out everything after the result and I get "object Object". So I know Drupal is trying to put the object into an array, but the names the services browser is spitting out are not jiving in Flash.
Errrr....
example
This is how I'm using it: obj['foto'] = String(re.result[i].field_foto[0].filename);
function CallIt(re:ResultEvent) {
LoadBar();
drupal.getview('allTestimonials', ['nid', 'title', 'type', 'field_functietitel', 'field_rollover', 'field_testimonial', 'field_foto'], ['kantoor'], ProcessIt);
}
function ProcessIt(re:ResultEvent) {
LoadBar();
testimonials['kantoor'] = new Array();
for (i=0; i < re.result.length; i++) {
var obj:Array = new Array;
obj['id'] = String(re.result[i].nid);
obj['title'] = String(re.result[i].title);
obj['voornaam'] = String(re.result[i].voornaam);
obj['contenttype'] = String(re.result[i].type);
obj['functietitel'] = String(re.result[i].field_functietitel[0].value);
obj['rollover'] = String(re.result[i].field_rollover[0].value);
obj['testimonial'] = addWindowToLinks(String(re.result[i].field_testimonial[0].value));
obj['foto'] = String(re.result[i].field_foto[0].filename);
testimonials['kantoor'][obj['id']] = obj;
}
LoadDone();
}
I'm not sure how your code
I'm not sure how your code is working, in terms of the drupal.getView() call. The function, at least in the version I have, expects the following:
In your code sample, you've got a completely different order of arguments.
What version of drupalSite are you using?
you may have an array too much
When I look at what is returned by Drupal [log] =>
[format] => 1
[uid] => 1
[name] => admin
[picture] =>
[data] => a:0:{}
[field_image] => Array
(
[0] => Array
(
[fid] => 1
[title] => image1.jpg
[alt] => image1.jpg
[nid] => 1
[filename] => image1.jpg
[filepath] => files/image1.jpg
[filemime] => image/jpeg
[filesize] => 46444
)
)
you only have 1 array field_image array the result data structure looks like a struc so I don't understand why you have result[i]. have you tried result.field_image[0].filepath ?
if it's a view ur loading
if it's a view ur loading up, use result[i]['field_image']['0']['filepath'] or result[i].field_image.0.filepath
if it's just a node.load ur doing, use result['field_image']['0']['filepath'] or result.field_image.0.filepath
note that this 0 (zero) isn't considered a number but a string, so field_image[0] won't work
Also look at Devel Module to find IDs
Just as an addendum, in case folks end up here via the search engines....
I was struggling with finding Object and element IDs. I realized that Devel Module isn't just for template development. It does a great job of letting you tunnel down into a node or view's particular IDs so that you can parse in your AS3 or AS2 class files. Probably a "duh" thing for savvy developers... but I'm a bit "thick" for a designer.
Thanks for the great info y'all.