Search code examples
phpactionscript-3model-view-controlleroopactionscript

AS3 OOP MVC with PHP


I'm new to ActionScript and Flex 3... I'm trying to develop an MVC 100% OOP application with Flex 3 using MXML, AS3 and PHP.

  • M (PHP)
  • V (MXML)
  • C (AS3)

The 3 layers I choose for my development. I have 10 AS3 classes that are object related between them and some inherit or implement interfaces.

The only problem here is how to interact 100% OOP with my model. In this case my model has to be a PHP Class that needs to be called from AS3 (the controller).

For example the AS3 class : Patient have a method called Save:

    public function Save(data:Array) : void
    {
        /* PHP call - model layer */
    }

I want to create an instance of my PHP Patient Model class that connects to the DB and insert the data array into it.

What should I use? How can I also return a variable to AS3? What happen to AS3 if there is a cached Exception in PHP?


Solution

  • I think you got it a bit wrong as where PHP fits into the mix. (Or I got you wrong) 1. MVC is flex usage only Model - inside flex (as3) View - Flex view Controller - Flex controller

    PHP fits into the mix when using MVCS s--> Service.

    Now, as for the MVC part, you can use frameworks like Mate (by Afusion) or the RobotLegs. Both are great, I love Mate and have been using it for quite a while now, the advantage of Mate is you use only Puse Flex/AS3 object an none framework-specific objects.

    After connecting to your service from the controller, or from the MAP (if you are using Mate) you can receive/send data using AMF --> ActionScript Messaging Format.

    But still, you have to hold a client side class representation for every server side one. for example --> User.php --> User.as --> ArrayCollection of User and so on and so forth.