Results 1 to 5 of 5
  1. #1
    Moo! Are you happy now? Arjan's Avatar
    Join Date
    Oct 2001
    Location
    Woerden, Netherlands
    Posts
    10,307
    Downloads
    39
    Uploads
    1

    flashtool development

    Quote Originally Posted by Dyark View Post
    I am also building a flash application (for me it is the easiest way) but the build has to be made by php first (all the actions are call via URLRequest statment)
    are you using flash, or flash builder 4?

    i am actually using flash builder 4 (Flex) to build the game/tool.
    flashbuilder can make use of Datasources (to connect to mysql through php)

    but the good thing about it, it GENERATES all the PHP code for you (all the mysql statements)

    it also makes use of Zend AMF, that means that the results of the queries are send back in AMF format (kind of XML) which flash builder can handle... and is very small in bytes (its passed in binary)
    Adobe Systems has contributed support for their open, binary Action Message Format (AMF) protocol to Zend Framework. Using Zend_Amf, you can build Flex and AIR applications that are performant and use minimal bandwidth.
    this is the reason i need to have a perfect database... it generates the PHP code based on the table and columnnames... so i dont want to have to change all references in flash if some tables change again..

    i had never used flash builder before one week ago, but i did the video training in 1 week.
    http://www.adobe.com/devnet/flex/videotraining/

    really amazing what that can do, very easy and a lot can be done by drag and drop.
    worth looking into

    in flash builder i make object arrays based on those
    Last edited by Arjan; 07-22-2010 at 08:51 AM.
    Te audire non possum. Musa sapientum fixa est in aure.

  2. #2
    Moo! Are you happy now? Arjan's Avatar
    Join Date
    Oct 2001
    Location
    Woerden, Netherlands
    Posts
    10,307
    Downloads
    39
    Uploads
    1
    for example the php generated code looks like this... it is done in 5 seconds

    PHP Code:
    <?php

    /**
     *  README for sample service
     *
     *  This generated sample service contains functions that illustrate typical service operations.
     *  Use these functions as a starting point for creating your own service implementation. Modify the 
     *  function signatures, references to the database, and implementation according to your needs. 
     *  Delete the functions that you do not use.
     *
     *  Save your changes and return to Flash Builder. In Flash Builder Data/Services View, refresh 
     *  the service. Then drag service operations onto user interface components in Design View. For 
     *  example, drag the getAllItems() operation onto a DataGrid.
     *  
     *  This code is for prototyping only.
     *  
     *  Authenticate the user prior to allowing them to call these methods. You can find more 
     *  information at http://www.adobe.com/go/flex_security
     *
     */
    class RegentsService {

        var 
    $username "arjan";
        var 
    $password "******";
        var 
    $server "localhost";
        var 
    $port "3306";
        var 
    $databasename "legacy";
        var 
    $tablename "regents";

        var 
    $connection;

        
    /**
         * The constructor initializes the connection to database. Everytime a request is 
         * received by Zend AMF, an instance of the service class is created and then the
         * requested method is invoked.
         */
        
    public function __construct() {
              
    $this->connection mysqli_connect(
                                      
    $this->server,  
                                      
    $this->username,  
                                      
    $this->password
                                      
    $this->databasename,
                                      
    $this->port
                                  
    );

            
    $this->throwExceptionOnError($this->connection);
        }

        
    /**
         * Returns all the rows from the table.
         *
         * Add authroization or any logical checks for secure access to your data 
         *
         * @return array
         */
        
    public function getAllRegents() {

            
    $stmt mysqli_prepare($this->connection"SELECT * FROM $this->tablename");        
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_execute($stmt);
            
    $this->throwExceptionOnError();
            
            
    $rows = array();
            
            
    mysqli_stmt_bind_result($stmt$row->regent_id$row->regent_abbr$row->regent_name$row->regent_description$row->domainid$row->gender$row->race$row->alignment$row->derivation$row->bloodstrength$row->bloodscore$row->treasury$row->regency_points$row->regency_defense$row->regent_turns);
            
            while (
    mysqli_stmt_fetch($stmt)) {
              
    $rows[] = $row;
              
    $row = new stdClass();
              
    mysqli_stmt_bind_result($stmt$row->regent_id$row->regent_abbr$row->regent_name$row->regent_description$row->domainid$row->gender$row->race$row->alignment$row->derivation$row->bloodstrength$row->bloodscore$row->treasury$row->regency_points$row->regency_defense$row->regent_turns);
            }
            
            
    mysqli_stmt_free_result($stmt);
            
    mysqli_close($this->connection);
        
            return 
    $rows;
        }

        
    /**
         * Returns the item corresponding to the value specified for the primary key.
         *
         * Add authorization or any logical checks for secure access to your data 
         *
         * 
         * @return stdClass
         */
        
    public function getRegentsByID($itemID) {
            
            
    $stmt mysqli_prepare($this->connection"SELECT * FROM $this->tablename where regent_id=?");
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_bind_param($stmt'i'$itemID);        
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_execute($stmt);
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_bind_result($stmt$row->regent_id$row->regent_abbr$row->regent_name$row->regent_description$row->domainid$row->gender$row->race$row->alignment$row->derivation$row->bloodstrength$row->bloodscore$row->treasury$row->regency_points$row->regency_defense$row->regent_turns);
            
            if(
    mysqli_stmt_fetch($stmt)) {
              return 
    $row;
            } else {
              return 
    null;
            }
        }

        
    /**
         * Returns the item corresponding to the value specified for the primary key.
         *
         * Add authorization or any logical checks for secure access to your data 
         *
         * 
         * @return stdClass
         */
        
    public function createRegents($item) {

            
    $stmt mysqli_prepare($this->connection"INSERT INTO $this->tablename (regent_id, regent_abbr, regent_name, regent_description, domainid, gender, race, alignment, derivation, bloodstrength, bloodscore, treasury, regency_points, regency_defense, regent_turns) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
            
    $this->throwExceptionOnError();

            
    mysqli_stmt_bind_param($stmt'isssiissssidiii'$item->regent_id$item->regent_abbr$item->regent_name$item->regent_description$item->domainid$item->gender$item->race$item->alignment$item->derivation$item->bloodstrength$item->bloodscore$item->treasury$item->regency_points$item->regency_defense$item->regent_turns);
            
    $this->throwExceptionOnError();

            
    mysqli_stmt_execute($stmt);        
            
    $this->throwExceptionOnError();

            
    $autoid $item->regent_id;

            
    mysqli_stmt_free_result($stmt);        
            
    mysqli_close($this->connection);

            return 
    $autoid;
        }

        
    /**
         * Updates the passed item in the table.
         *
         * Add authorization or any logical checks for secure access to your data 
         *
         * @param stdClass $item
         * @return void
         */
        
    public function updateRegents($item) {
        
            
    $stmt mysqli_prepare($this->connection"UPDATE $this->tablename SET regent_abbr=?, regent_name=?, regent_description=?, domainid=?, gender=?, race=?, alignment=?, derivation=?, bloodstrength=?, bloodscore=?, treasury=?, regency_points=?, regency_defense=?, regent_turns=? WHERE regent_id=?");        
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_bind_param($stmt'sssiissssidiiii'$item->regent_abbr$item->regent_name$item->regent_description$item->domainid$item->gender$item->race$item->alignment$item->derivation$item->bloodstrength$item->bloodscore$item->treasury$item->regency_points$item->regency_defense$item->regent_turns$item->regent_id);        
            
    $this->throwExceptionOnError();

            
    mysqli_stmt_execute($stmt);        
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_free_result($stmt);        
            
    mysqli_close($this->connection);
        }

        
    /**
         * Deletes the item corresponding to the passed primary key value from 
         * the table.
         *
         * Add authorization or any logical checks for secure access to your data 
         *
         * 
         * @return void
         */
        
    public function deleteRegents($itemID) {
                    
            
    $stmt mysqli_prepare($this->connection"DELETE FROM $this->tablename WHERE regent_id = ?");
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_bind_param($stmt'i'$itemID);
            
    mysqli_stmt_execute($stmt);
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_free_result($stmt);        
            
    mysqli_close($this->connection);
        }


        
    /**
         * Returns the number of rows in the table.
         *
         * Add authorization or any logical checks for secure access to your data 
         *
         * 
         */
        
    public function count() {
            
    $stmt mysqli_prepare($this->connection"SELECT COUNT(*) AS COUNT FROM $this->tablename");
            
    $this->throwExceptionOnError();

            
    mysqli_stmt_execute($stmt);
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_bind_result($stmt$rec_count);
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_fetch($stmt);
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_free_result($stmt);
            
    mysqli_close($this->connection);
            
            return 
    $rec_count;
        }


        
    /**
         * Returns $numItems rows starting from the $startIndex row from the 
         * table.
         *
         * Add authorization or any logical checks for secure access to your data 
         *
         * 
         * 
         * @return array
         */
        
    public function getRegents_paged($startIndex$numItems) {
            
            
    $stmt mysqli_prepare($this->connection"SELECT * FROM $this->tablename LIMIT ?, ?");
            
    $this->throwExceptionOnError();
            
            
    mysqli_stmt_bind_param($stmt'ii'$startIndex$numItems);
            
    mysqli_stmt_execute($stmt);
            
    $this->throwExceptionOnError();
            
            
    $rows = array();
            
            
    mysqli_stmt_bind_result($stmt$row->regent_id$row->regent_abbr$row->regent_name$row->regent_description$row->domainid$row->gender$row->race$row->alignment$row->derivation$row->bloodstrength$row->bloodscore$row->treasury$row->regency_points$row->regency_defense$row->regent_turns);
            
            while (
    mysqli_stmt_fetch($stmt)) {
              
    $rows[] = $row;
              
    $row = new stdClass();
              
    mysqli_stmt_bind_result($stmt$row->regent_id$row->regent_abbr$row->regent_name$row->regent_description$row->domainid$row->gender$row->race$row->alignment$row->derivation$row->bloodstrength$row->bloodscore$row->treasury$row->regency_points$row->regency_defense$row->regent_turns);
            }
            
            
    mysqli_stmt_free_result($stmt);        
            
    mysqli_close($this->connection);
            
            return 
    $rows;
        }
        
        
        
    /**
         * Utility function to throw an exception if an error occurs 
         * while running a mysql command.
         */
        
    private function throwExceptionOnError($link null) {
            if(
    $link == null) {
                
    $link $this->connection;
            }
            if(
    mysqli_error($link)) {
                
    $msg mysqli_errno($link) . ": " mysqli_error($link);
                throw new 
    Exception('MySQL Error - '$msg);
            }        
        }
    }

    ?>
    Te audire non possum. Musa sapientum fixa est in aure.

  3. #3
    Moo! Are you happy now? Arjan's Avatar
    Join Date
    Oct 2001
    Location
    Woerden, Netherlands
    Posts
    10,307
    Downloads
    39
    Uploads
    1
    and from within flash builder, you just call the functions:

    public function getAllRegents()
    public function getRegentsByID($itemID)
    public function createRegents($item)
    public function updateRegents($item)
    public function deleteRegents($itemID)
    public function count()
    public function getRegents_paged($startIndex, $numItems)

    done
    Te audire non possum. Musa sapientum fixa est in aure.

  4. #4
    Moo! Are you happy now? Arjan's Avatar
    Join Date
    Oct 2001
    Location
    Woerden, Netherlands
    Posts
    10,307
    Downloads
    39
    Uploads
    1
    on the mysql server i make so called views (reference tables) these are not really tables, but a collection of information from tables.

    so for example for regents i make a view called regent_info or so, with navicat (a graphical mysql tool) i create a collection what i really want to see... do there i do all the joints between tables. (just click click drag and click )

    these views are just as tables, so you can perform a select from regent_info as you would normally do.. you can only NOT update reference tables.. they are pure for viewing

    but the PHP code i generate with the datasource is clean of complex join statements...

    let mysql do the work, and not PHP
    Te audire non possum. Musa sapientum fixa est in aure.

  5. #5
    Senior Member Dyark's Avatar
    Join Date
    Jun 2007
    Location
    montreal, canada
    Posts
    163
    Downloads
    69
    Uploads
    2
    I have not played with flex builder, i am doing it with flash cs4, i make the code of my php myself (i prefer controlling my data so if there is an error I find it right away) the http://www.deismaar.com/test/cerilia3.html is the exemple of a map generated with php and mysql.

    That is why, in my table of Province I have a column name variable which use the information of the object (same name as the variable with a .text at the end) and the variable itself (same name no .text at the end). I pass those value to the URLRequest code of my flash action part.

    Also I can vary that very easily, i just send a URLRequestMethod.POST of what region I want (either by regent or domain or anything else i want and the php code will return what I want.

    I have no time right now to go further, i will get back on it in a few days (i am developing the action part and also the live feed and the delay feed of the game).

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
BIRTHRIGHT, DUNGEONS & DRAGONS, D&D, the BIRTHRIGHT logo, and the D&D logo are trademarks owned by Wizards of the Coast, Inc., a subsidiary of Hasbro, Inc., and are used by permission. ©2002-2010 Wizards of the Coast, Inc.