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

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

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 a user 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

Very short trick: undefined values in Javascript

Wednesday, 22 October, 2008

There is an abbreviated form for assigning "in flight" a value to a variable if another is not defined (undefined), using the logical OR operator (| |) - Double-pipe:

JavaScript:
  1. / / Pluto is undefined
  2. var pluto;
  3. ; var foo = pluto | |'5 ';
  4. pippo ) ; alert (foo);
  5. / / Result: 5

This technique is useful for writing functions with parameters:

JavaScript:
  1. param ) { miaFunc function (param) (
  2. ; var p1 = param | | 'benchmark';
  3. / / ...
  4. )

But we must be careful to use this form as zero values such as 0 false are misinterpreted, because of "guilt" of the OR logic used:

JavaScript:
  1. ; pluto var = 0;
  2. ; var foo = pluto | |'5 ';
  3. pippo ) ; alert (foo);
  4. / / Result: 5
  5. ; pluto var = false;
  6. ; var foo = pluto | |'5 ';
  7. pippo ) ; alert (foo);
  8. / / Result: 5
  9. ; pluto var = 1;
  10. ; var foo = pluto | |'5 ';
  11. pippo ) ; alert (foo);
  12. / / Result: 1

Related Post

CSS3: someone has seen Internet Explorer?

Thursday, October 16, 2008

I own no ...

CSS:
  1. p (
  2. / * * Rounded Corners /
  3. border-radius: 9px; / CSS * 3 * /
  4. -o-border-radius: 9px; / Opera * * /
  5. -iCab-border-radius: 9px; / iCab * * /
  6. -KHTML-border-radius: 9px; / Konqueror * * /
  7. -moz-border-radius: 9px; / * Firefox * /
  8. -webkit-border-radius: 9px; / * * Safari /
  9. )

Related Post

A class countdown in Javascript

Monday 13 October, 2008

In the post with 3D CountDown FIVe3D (See How I Did It: write a countdown in Flash), was a class proposal for the creation of an object CountDown in Actionscript, here's a version similar in Javascript:

JavaScript:
  1. / **
  2. * CountDown Class
  3. *
  4. * @ Author Giovambattista Fazioli
  5. * @ @ Email g.fazioli undolog.com
  6. * @ Web http://www.undolog.com
  7. *
  8. * @ Param dd (string) 'day month, year'
  9. *
  10. * /
  11. dd ) { function countdown (dd) (
  12. / / Init target time
  13. Date ( dd ) ; var target = new Date (dd);
  14. = target. getTime ( ) ; this. targetTime = target. getTime ();
  15. / **
  16. * Refresh countdown
  17. * /
  18. = function ( ) { this. refresh = function () (
  19. Date ( ) ; var today = new Date ();
  20. ( ) ; var = currentTime today. getTime ();
  21. / / Time left
  22. this . targetTime - currentTime ) ; this. _leftMilliseconds = (this. targetTime - currentTime);
  23. ( this ._leftMilliseconds / 1000 ) ; this. _leftSeconds = Math. floor (this. _leftMilliseconds / 1000);
  24. ( this ._leftSeconds / 60 ) ; this. _leftMinutes = Math. floor (this. _leftSeconds / 60);
  25. ( this ._leftMinutes / 60 ) ; this. _leftHours = Math. floor (this. _leftMinutes / 60);
  26. / / No module
  27. = Math. floor ( this ._leftHours / 24 ) ; this. leftDays = Math. floor (this. _leftHours / 24);
  28. / / For print
  29. = this ._leftMilliseconds % 1000 ; this. leftMilliseconds = this. _leftMilliseconds% 1000;
  30. = this ._leftSeconds % 60 ; this. leftSeconds = this. _leftSeconds% 60;
  31. = this ._leftMinutes % 60 ; this. leftMinutes = this. _leftMinutes% 60;
  32. = this ._leftHours % 24 ; this. leftHours = this. _leftHours% 24;
  33. )
  34. ( ) ; this. refresh ();
  35. )

Example

JavaScript:
  1. countDown ( '1 1, 2009' ) ; var so = new countdown ('1 1, 2009 ');
  2. / / Show how many days, hours, minutes, seconds and milliseconds in the first January 2009
  3. cd. leftDays + "," + cd. leftHours + "," + cd. leftMinutes + "," + cd. leftSeconds + "," + cd. leftMilliseconds ) ; document. write (ie leftDays + "," + cd. leftHours + "," + cd. leftMinutes + "," + cd. leftSeconds + "," + cd. leftMilliseconds);

Related Post

Very short trick: avoid error message in PHP

Wednesday, October 8, 2008

If we do not want a PHP issue any error or warning, just enter the first call to the function of the snail - or at - (@):

PHP:
  1. / / Instead of using the canonical form
  2. ; $ res = miaFunc ();
  3. / / You can use
  4. ; $ res = @ miaFunc ();

Related Post

Very short trick: PHP cars echo

Thursday, October 2, 2008

In PHP you can use an abridged form, or contracted, to see returns of variable or functions:

PHP:
  1. / / Instead of
  2. $miavar ?> <? php echo $ miavar?>
  3. / / You can write
  4. ?> <? = $ Miavar?>
  5. / / Instead of
  6. miaFunc ( ) ?> <? php echo miaFunc ()?>
  7. / / You can write
  8. ?> <? MiaFunc = ()?>

Related Post