« Return to Thread: Flash CS4 AS3 to django Service.ResourceNotFound

Re: Flash CS4 AS3 to django Service.ResourceNotFound

by Justin Olmanson-2 :: Rate this Message:

Reply to Author | View in Thread

Thanks Nick,

making the changes you suggest did the trick.

I'm now off to figure out crossdomain settings.  :-)

Justin





On Wed, Jun 17, 2009 at 12:33 PM, Nick Joyce <nick@...> wrote:
Hi,

Comments inline.

On 17 Jun 2009, at 18:05, Justin Olmanson wrote:

Hi,

I just started learning django last week and my flash cs4 is a bit dodgy as well. I'm trying to create a writing support tool for 7-11 year olds. Basically the kids type things and every time the space bar is pressed I'd like to send django what they have written so far -parse it in different ways and then send some supports back up to flash.

I've taken the Hellow World example from the pyAMF docs and tried to modify it. When I load the swf file into my browser from my static webspace it gives me no error message or return statement what-so-ever. If I just

I would check crossdomain settings here.

run 'test movie' from my desktop the HelloWorld package returns the following message:

 -----------------------------------------------------------------------Returned Message-----------------------------------------------------
Remoting error:
Service.ResourceNotFound

Unknown service echo.echo
error
['Traceback (most recent call last):', '  File "build/bdist.linux-i686/egg/pyamf/remoting/amf0.py", line 75, in __call__    request.target)', '  File "build/bdist.linux-i686/egg/pyamf/remoting/gateway/__init__.py", line 367, in getServiceRequest', 'UnknownServiceError: Unknown service echo.echo']

----------------------------------------------------------------------------------------------------------------------------------------------------------

On the AS3 side it oddly calls the HelloWorld function before the spacebar is ever pressed (but I'm guessing that that problem is unrelated to the error above).

I'd just like to know what I have out of place or what I need to add.  :-)

thanks,

Justin





I'm not sure I needed to include all these files but, being new I thought I would err on the side of inclusion.

----------------------------------------------------------------------Flash CS4 AS3-------------------------------------------------------------
-----------------------------my as3 script--------------------------------------
//declare variables
//...

//import packages
import com.as3.HelloWorld;
import flash.events.KeyboardEvent;

//listen for spacebar
function hearkey(yourEvent:KeyboardEvent) {
    if (yourEvent.keyCode==32) {//if the key that was pressed was then spacebar then...
        //...
        updateStatus(theStringCompile);//send message to function below
        HelloWorld(input_text.text);//
    }
    ; ;
}
; ;
//...

stage.addEventListener(KeyboardEvent.KEY_UP, hearkey);//listen for any key presses
---------------------------------------------------------------------------------------------

---------------------the included as3 package-----------------------------------

package com.as3 {
    // Copyright (c) 2007-2009 The PyAMF Project.
    // See LICENSE for details.
    import flash.display.MovieClip;
    import flash.text.TextField;
    import flash.net.NetConnection;
    import flash.net.Responder;

    public class HelloWorld extends MovieClip
    {       
        // Gateway connection object
        private var gateway:NetConnection;

        public function HelloWorld(passedString='This was a test')
        {
            // Setup connection
            gateway = new NetConnection();

            // Connect to gateway
            gateway.connect( "http://myurl.com/blog/gateway/" );

            // This var holds the data we want to pass to the remote service.
            var param:String = passedString;

            // Set responder property to the object and methods that will receive the
            // result or fault condition that the service returns.
            var responder:Responder = new Responder( onResult, onFault );

            // Call remote service to fetch data
            gateway.call( "echo.echo", responder, param );


This should be "myservice.echo", according to your services definition in amfgateway.py


        }

        // Result handler method
        private function onResult( result:Object ): void {
            var myData:String = result.toString();
            trace( result );// prints "passedString"
            return_text_output.text = myData;
        }
        // Fault handler method displays error message
        private function onFault( error:Object ): void {
            // Notify the user of the problem
            return_text_output.text = "Remoting error: \n";
            for (var d:String in error) {
                return_text_output.appendText( error[d] + "\n" );
            }
        }

    }
}

---------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------Django Python--------------------------------------------------------------

--------------------------amfgateway.py---------------------------------------------

import pyamf
from pyamf.remoting.gateway.django import DjangoGateway

def echo(request, data):
    return data

services = {
    'myservice.echo': echo
    # could include other functions as well
}

echoGateway = DjangoGateway(services)

---------------------------------------------------------------------------------------------

---------------------urls.py--------------------------------------------------------------

from django.conf.urls.defaults import *
from myproject.blog.views import archive
from myproject.blog.views import test
from myproject.blog.views import passt
from myproject.blog.amfgateway import echoGateway

urlpatterns = patterns('',
     url(r'^$', archive),
     url(r'^test/$', test),
     url(r'^passt/$', passt),
     # AMF Remoting Gateway
     url(r'^gateway/', echoGateway),
)

---------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------------------------------------------
_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users


Cheers,

Nick

_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users



_______________________________________________
PyAMF users mailing list - users@...
http://lists.pyamf.org/mailman/listinfo/users

 « Return to Thread: Flash CS4 AS3 to django Service.ResourceNotFound