Actionscript 3.0 for beginners: lesson # 4

Tuesday, 11 November, 2008

Resume our sample code of TicTacToe (which is entirely on Google Code) and we start to analyze it in detail.

Import definitions

With Actionscript 3.0 has been done a great job of cleaning and arrangement of classes nell'alberatura (contained in the package package) used during development. In other programming languages, like C for example, when you want to use a feature must explicitly "import" in the code. This operation "import" is necessary to allow the compiler to have all the codes and definitions related features that we want to use. In Actionscript 3.0, however, Education import should not be confused with the standard C / C + #include # #include Actionscript 3.0 provides education include that is identical to #include the C / C + +. The latter include "actual code that, if used or not, is compiled into the final. Education import is the highest level and is more "intelligent" being compiled. It serves primarily to access classes without having to specify the full name. In Alré words instead of using forms like this:

Actionscript:
  1. . MovieClip = new flash. display . MovieClip ( ) ; var myMC: flash. display. MovieClip = new flash. display. MovieClip ();

Continue reading ... "

Related Post

Very short trick: versatility of CSS classes

Monday, November 10, 2008

Most experts already know him, but I am often asked which is the difference between class and id in the CSS style sheets. An overview of some differences and warnings you can find it in classes and ID in CSS, however, a useful feature that distinguishes class from id is the ability to use multiple classes. For example, you can define:

CSS:
  1. border :2px solid #000 } . bordoNero (border: 2px solid # 000)
  2. color :#f00 } . coloreRosso (color: # f00)
  3. border :2px solid #f00 } . bordoRosso (border: 2px solid # f00)

and write in HTML:

HTML:
  1. > Bordo nero con caratteri rossi </div> <div class = "bordoNero coloreRosso"> Border black with red lettering </ div>
  2. > Bordo rosso con caratteri rossi </div> <div class = "bordoRosso coloreRosso"> Border red with red lettering </ div>

class unlike id can contain within it several definitions in any sequence!

Related Post

Very short snippet: Wordpress administrator?

Monday, November 3, 2008

Administrator or underwriter? Here's a quick way to understand this:

PHP:
  1. ; global $ user_ID;
  2. / /
  3. $user_ID , 'wp_capabilities' ) ; $ get_usermeta capabilities = ($ user_ID, 'wp_capabilities');
  4. / /
  5. is_array ( $capabilities ) ) { if (is_array ($ capabilities)) (
  6. $capabilities [ 'Administrator' ] == 1 || $capabilities [ 'administrator' ] == 1 ) { if ($ capabilities [ 'Administrator'] == 1 | | $ capabilities [ 'administrator'] == 1) (
  7. ; echo "You are an administrator";
  8. )
  9. )

Or, as "contracted"

PHP:
  1. ; global $ user_ID;
  2. / /
  3. $user_ID , 'wp_capabilities' ) ; $ get_usermeta capabilities = ($ user_ID, 'wp_capabilities');
  4. / / $ Admin is true if administrator
  5. $capabilities [ 'Administrator' ] == 1 || $capabilities [ 'administrator' ] == 1 ) ; $ admin = ($ capabilities [ 'Administrator'] == 1 | | $ capabilities [ 'administrator'] == 1);

You can of course check all levels made available by Wordpress, as subscriber for example.

Related Post

Wordpress: remove the menu

Saturday, November 1, 2008

It may be useful, sometimes, "obscure" some of the menu of Wordpress, especially if you developed a website / blog for a client and do not want to allow access to sensitive features. There Plugin already performing this function, but to have a personal and complete control, we see in detail how this feature.
As always exploit the useful Action made available by Wordpress, in this case admin_menu Through the global variable $menu can access the list of the menu. We can find the menu to "remove" in two ways: through the label or via the link that it points (see commented shares in the example below). The proposal is "obscured" menu items Design, Settings and Plugins:

PHP:
  1. remove_menu_item function () (
  2. ; global $ menu;
  3. / / By label
  4. ( 'Design' , 'Impostazioni' , 'Plugins' ) ; $ removes = array ( 'Design', 'Settings',' Plugins');
  5. / / Through links
  6. / / $ Removes = array ( 'themes.php', 'options-general.php', 'plugins.php');
  7. $removes as $todel ) foreach ($ removes as $ todel)
  8. $menu as $key => $sm ) if ( $sm [ 0 ] == $todel ) { unset ( $menu [ $key ] ) ; break ; } foreach ($ menu as $ key => $ sm) if ($ sm [0] == $ todel) (unset ($ menu [$ key]); break;)
  9. / / Through links
  10. / / Foreach ($ menu as $ key => $ sm) if ($ sm [2] == $ todel) (unset ($ menu [$ key]); break;)
  11. )
  12. / /
  13. , 'remove_menu_item' ) ; add_action ( 'admin_menu', 'remove_menu_item');

Using the links as key to the removal $sm[2] in parts commented code surprise here), is useful when there is certainty of language - location - with which you installed Wordpress. With this technique, however, the menu is removed only at the interface, so you can still access the page via a direct link.

Related Post

Very short snippet: dates PHP plain

Friday 31 October, 2008

Converts a date format yyyy-mm-dd hh:mm:ss to yyyymmddhhmmss Useful to be able to exploit the functions of law; type asort()

PHP:
  1. / **
  2. * Format from "yyyy-mm-dd hh: mm: ss" to "yyyymmddhhmmss"
  3. * /
  4. $d ) { plainDate function ($ d) (
  5. preg_replace ( '/(-|:| \0 40)/' , '' , $d ) ) ; return (preg_replace ('/(-|:| \ 0 40) / ','', $ d));
  6. )

Better than this:

PHP:
  1. $d ) { plainDate function ($ d) (
  2. str_replace ( ' ' , '' , str_replace ( '-' , '' , str_replace ( ':' , '' , $d ) ) ) ) ; return (str_replace ( '','', str_replace ( '-','', str_replace ( ':',''$ d))));
  3. )

Or even this:

PHP:
  1. $d ) { plainDate function ($ d) (
  2. ( ' ' , $d ) ; $ pd = explode ( '', $ d);
  3. ( '-' , $pd [ 0 ] ) ; $ dd = explode ( '-', $ pd [0]);
  4. ( ':' , $pd [ 1 ] ) ; $ hp = explode ( ':', $ pd [1]);
  5. $dd [ 0 ] . $dd [ 1 ] . $dd [ 2 ] . $hp [ 0 ] . $hp [ 1 ] . $hp [ 2 ] ) ; return ($ dd [0]. $ dd [1]. $ dd [2]. $ hp [0]. $ hp [1]. $ hp [2]);
  6. )

Related Post

jQuery: round edges on images to overlap

Thursday, October 30, 2008

Because of the different rendering between different browser, which certainly see Microsoft Internet Explorer in mind, we must always resort to apply for artifizi effects that now should be a standard. The multi-discussed rounded edges are a classic example of the "disaster" produced by the complete inability to achieve a standard seriously on page rendering HTML / CSS. There are numerous networking solutions that allow you to have "effects" (effects exempting dall'HTML present as rounded edges, shadow effects, reflections, etc ...) with patches on the sheets of styles, special tricks using div grafted , Javascript libraries, use of canvas etc ...
For purely educational I would explain further technical (cross-browser) to apply to the rounded edges of images:

Demos and sources

Continue reading ... "

Related Post

Create applications with Desktop Chrome Google and FireFox?

Tuesday, October 28, 2008

Chrome Google allows you to create Desktop applications from a Web page? In fact, as shown in the menu item, is simply allowed to create a shortcut to a shortcut that - in turn - opens a window without the address bar without all the frills of the browser. With this does not mean that we have created a Desktop, and we have just created a link to the same Google Chrome mode - so to speak-chrome-less.

Feature Simla, but more ambitious, had already been proposed by the Mozilla Foundation in 2007 through the Prism. This is certainly the most versatile and articulate, accompanied by a useful extension that allows you to create desktop applications menu of FireFox, like Google Chrome.

However, both solutions are far away from technology Adobe AIR. Before someone is confusing the good stress the substantial differences between a shortcut on the desktop, which opens a window without menus, and a desktop application true and proper.
Adobe AIR, in fact, unlike the solutions proposed by Google Chrome and Prism allows:

  • Virtually complete access to the system running the application with the ability to read and write files. Opportunity to extend its functionality through a DLL (dynamic link library), extensions and third-party products as SHU Player (see Distribute Adobe AIR: AIR Badge by a SHU Player)
  • It manages the application like any other system applications: installation and uninstallation

Related Post

Wordpress: write a personal logout

Monday, October 27, 2008

Starting from post Wordpress: step by step how to create a login, performed the login procedure could be useful to indicate in our blog a link to the disconnection, or logout. We will not use again the standard procedures of Wordpress, but we'll see how to log out low level. First of all we must understand whether a user is logged on or not. This is possible simply querying the variable $user_ID of Wordpress. For example:

PHP:
  1. $user_ID != '' ) { // oppure if( is_user_logged_in() ) { if ($ user_ID! ='') (/ / or if (is_user_logged_in ()) (
  2. / / User is "logged" ...
  3. )

Once we know that someone is logged in the system, we can insert a simple link to our page logout. Then we create a page, for example logout.php and inserting the following code:

PHP:
  1. / **
  2. * Performs logout
  3. *
  4. * @ Author Giovambattista Fazioli
  5. * @ @ Email g.fazioli undolog.com
  6. * @ Web http://www.undolog.com
  7. * /
  8. / / Invoke WordPress bootstrap
  9. 'wp-config.php' ) ; @ Require_once ( 'wp-config.php');
  10. 'wp-includes/pluggable.php' ) ; @ Require_once ( 'wp-includes/pluggable.php');
  11. / / Wp logout
  12. wp_logout ();
  13. / / Load any other page
  14. "Location: /" ) ; header ( "Location: /");

And just then "link" to our page to provide a logout procedures:

PHP:
  1. $user_ID != '' ) { if ($ user_ID! ='') (
  2. ; echo 'Run the <a href="logout.php"> logout </ a>,';
  3. )

Related Post

Wordpress: step by step how to create a login

Friday 24 October, 2008

In this tutorial we'll see how to create a personal login procedure, using Ajax functionality via jQuery. There are several ways to customize the login Wordpress, for example through the use of hooks and filters add_action() add_filter() We use a more low-level, although we still interfaces to the kernel Wordpress. Also make sure to validate a user through the double email / password.

Why create a login?

  • In some contexts can return uitle have the most control over the login page, to propose a custom layout to our registered users. You can also enrich the page with information, a logo from the classic "Password Forgotten?"
  • To allow access via email (as shown here Treaty) instead of user_login standard Wordpress
  • To be able to enter a login panel in the sidebar of our Blog
  • And finally, to have a skeleton - and an idea - for a good Plugin : D

Environment

In our example / tutorial work on the root of Wordpress inside a folder mylogin I created two php files within this folder: index.php and logon.php The first contains the interface of our login, with all functions Javascript / jQuery which we serve. The second file, logon.php will contain the code to validate the user. Then we create a folder css and inside this file layout.css and a folder images Inside the folder images include a classic Ajax loader: create it online at AjaxLoad.info. At the end you should have:

  • mylogin
    • index.php
    • logon.php
    • css
      • layout.css
      • images
        • ajax-loader.gif

Continue reading ... "

Related Post

FireFox: management profiles

Thursday, October 23, 2008

Mozilla Firefox lets you manage multiple profiles, features useful to those who, like me, develops Web sites and requires a series of extensions dedicated to debug and analysis of Web pages. Through the use of profiles you can configure different settings FireFox:

Firefox save your personal information such as bookmarks, passwords and preferences in a file called profile in a different location than the program files for Firefox.

On Windows Vista (see here for other operating systems) allows access to management profiles from Esegui command using:

CODE:
  1. firefox-ProfileManager

Managing profiles

One of the advantages in the use of profiles is to have a FireFox to navigate, without any toolbar and extensions for debugging and FireFox to develop, together with Firebug and all other development tools.

Related Post