Category 'Tutorials'


Actionscript 3.0: MovieClip MovieClip over

Just a Flash Developer / Actionscript is preparing to write a function similar to a tooltip, clashes immediately with the problem of the propagation of events between overlapping MovieClips. In fact, if a MovieClip (B) is superimposed to a MovieClip (A), which responds, for example, an event MouseEvent.Mouse_OVER , by hovering on the MovieClip (B) no event be higher than intercepted by the MovieClip (A):

MovieClip MovieClip over

Continued ...

Very short trick: avoid error message in PHP

If we do not want a PHP function to issue any warnings or errors, just enter the first call to the character of the spiral - or at - (@):

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

Continued ...

WordPress: how to write a reply to comment using jQuery

Recently Cristiano Up has released a useful plugin for WordPress that can Append two links to each comment in a post (maybe you have installed a similar, since in the directory WordPress.org I beamed a couple, but being an Italian software would the case to honor the excellent work done by Christian). These links (reply & shares), meet and / or to quote the author of a comment by performing the tedious task to insert the at sign (@) to indicate to whom it is addressed. In this tutorial I will show - for medium to experienced users - the way these two features adding to it "by hand", without resorting to the installation of any plugins. Also exploit the capabilities of jQuery for the JavaScript part. The technique I present is the same that I used to introduce this feature in this blog.

Note: The use of a plugin is the best solution for those who tend to frequently modify your WordPress template, or at least, has plans to implement this. This tutorial is only to show how to perform targeted interventions within the code WordPress and is dedicated to the inquisitive.

Edit the file comments.php

The first change we make is to insert the link "reply" and "shares" in every comment. To do this we edit the file comments.php located in the folder of our theme. This file contains all the instructions that display the comments at the end of a post. The section we are concerned (which may vary slightly from theme to theme) is the creation of loops through the comments, identified by:

Continued ...

Very short trick: PHP echo Car

In PHP, you can use an abbreviated form, or contracted, to display variables or returns of functions:

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

Continued ...

Actionscript 3.0 for beginners: lesson # 3

We continue the analysis of the example of the game Tic Tac Toe, presented in Actionscript 3.0 for beginners: lesson # 2 . We arrived at the function that creates the game grid:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/ **
* Graphic design grid (3x3) on screen
*
* @ Param void
* @ Return void
* @ Private
* /
createGrid ( ) : void { private function createGrid (): void {
/ / Temporary pointer to a MovieClip
/ / Note: here you could also use a Sprite
/ / But in this case I need to extend the object
/ / Adding some personal proproetà. The Sprite
/ / Is a closed class and therefore not extensible runtime, while
/ / The MovieClip class is a dynamic class and then makes
/ / Possible to add run-time properties
MovieClip , i : uint = 0 ; var tm: MovieClip , i: uint = 0;
/ / Add the MovieClip in a 3x3 pattern
; i < 9 ; i ++ ) { for (; i <9; i + +) {
( ) ; tm = new MovieClip ();
tm ) ; addChild (tm);
= OFFSETX + ( ( i % 3 ) * ( PLAYER_WIDTH + PLAYER_OFFSET ) ) tm. offsetX = x + ((i% 3) * (PLAYER_WIDTH PLAYER_OFFSET +))
= OFFSETY + Math . floor ( i / 3 ) * ( PLAYER_HEIGHT + PLAYER_OFFSET ) tm. OFFSETY + y = Math . floor (i / 3) * (+ PLAYER_HEIGHT PLAYER_OFFSET)
tm. _index = i;
0 ) ; drawPlayer (tm, 0);
}
/ / Draw the 2 lines and 2 horizontal ranges addressable
this . graphics ) { with (this. graphics) {
6 , 0x666666 ) ; lineStyle (6, 0x666666);
OFFSETX , OFFSETY + ( PLAYER_HEIGHT + 15 ) ) ; moveTo (offsetX, OFFSETY + (PLAYER_HEIGHT + 15));
OFFSETX + ( ( PLAYER_WIDTH + 20 ) * 3 ) , OFFSETY + ( PLAYER_HEIGHT + 15 ) ) ; lineTo (offsetX + ((PLAYER_WIDTH + 20) * 3), OFFSETY + (PLAYER_HEIGHT + 15));
OFFSETX , OFFSETY + ( PLAYER_HEIGHT + 20 ) * 2 ) ; moveTo (offsetX, OFFSETY + (PLAYER_HEIGHT + 20) * 2);
OFFSETX + ( ( PLAYER_WIDTH + 20 ) * 3 ) , OFFSETY + ( PLAYER_HEIGHT + 20 ) * 2 ) ; lineTo (offsetX + ((PLAYER_WIDTH + 20) * 3), OFFSETY + (PLAYER_HEIGHT + 20) * 2);
OFFSETX + ( PLAYER_WIDTH + 15 ) , OFFSETY ) ; moveTo (offsetX + (PLAYER_WIDTH + 15), OFFSETY);
OFFSETX + ( PLAYER_WIDTH + 15 ) , OFFSETY + ( ( PLAYER_HEIGHT + 20 ) * 3 ) ) ; lineTo (offsetX + (PLAYER_WIDTH + 15), OFFSETY + ((PLAYER_HEIGHT + 20) * 3));
OFFSETX + ( PLAYER_WIDTH + 20 ) * 2 , OFFSETY ) ; moveTo (offsetX + (PLAYER_WIDTH + 20) * 2 OFFSETY);
OFFSETX + ( PLAYER_WIDTH + 20 ) * 2 , OFFSETY + ( ( PLAYER_HEIGHT + 20 ) * 3 ) ) ; lineTo (offsetX + (PLAYER_WIDTH + 20) * 2 OFFSETY + ((PLAYER_HEIGHT + 20) * 3));
}
}

Continued ...

jQuery: how to build an extension Plugins

Like all the libraries of this type also jQuery allows you to extend its basic functionality using real plugins. Respecting the rules of its operation, that is, return it is always a pointer to the selected item or jQuery itself, you can write a plugin with a few lines of code. Take for example the proposed code in jQuery against everyone: a benchmark with 5 browser , which was (after the correction reported by Luca ):

1
2
3
4
5
) . css ( 'cursor' , 'pointer' ) . click ( $ ('H2.dropdown'). Css ('cursor', 'pointer'). Click (
function () {
$ ( this ) . next ( ) . is ( ':hidden' ) ) $ ( this ) . next ( ) . slideDown ( ) ; else $ ( this ) . next ( ) . slideUp ( ) ; if ($ (this). next (). is (': hidden')) $ (this). next (). slideDown (); else $ (this). next (). slideUp ();
}
);

Continued ...

Actionscript 3.0 for beginners: lesson # 2

As promised here is the second lesson in ActionScript 3.0! Today we start the analysis of a simple project that reproduces the play or the Tic Tac Toe Tic Tac Toe. I tried to include some special features in this example, ActionScript 3.0, trying to give space to the understanding and not on style. It follows that if I had to write the "game" really, I probably would have structured very differently, but in this case I tried to mediate between a classical program with a compact, hermetic more understandable for newbies.

Continued ...

Very short snippet: send HTML mail with PHP

The code necessary and sufficient to send a simple email in HTML format using the command mail() in PHP is:

1
2
3
4
5
6
7
/ / Prepare the header to indicate HTML
"MIME-Version: 1.0 \n " . $ Headers = "MIME-Version: 1.0 \ n".
"Content-type: text / html; charset = utf-8 \ n".
"From: Undolog.com <info@undolog.com> \ n".
"Bcc: Copy <g.fazioli@undolog.com> \ n";

"Destinatario <info@e-lementi.com>" , "Oggetto della mail" , "<p>Corpo della mail in <strong>HTML</strong></p>" , $headers ) ; mail ("Recipient <info@e-lementi.com>", "Subject of mail", "Body of email <p> <strong> HTML </ strong> </ p>", $ headers);

Continued ...

ABS-WP: add your blog to search the browser

Update: latest version

OpenSearch is a standard that defines a set of formats for the sharing of search results. This standard is used, for example, from social networks like Facebook , which have an own system of research. One use of this standard for browsers that support it, is the ability to automatically recognize and then add your own website or blog to the list of search engines in the browser's drop down menu:

image

If you visit (with FireFox or Flock ) search engine Divoogle , you can place it among the search engines on the menu.
This, however, could be performed manually by selecting "Manage Search Engines ..." in Firefox, for example. But besides being a particular operation, each user should play individually. Last generation browsers such as Flock , thanks to the standard permit OpenSearch to automate this function, automatically signaling the user that the web site or blog offers its own search engine:

image

WordPress Plugin: Blog in your list of search engines

The manual procedure is useful to enable this feature everywhere, we will see below. In the meantime, if you have a WordPress blog, you can install this simple plugin ( wp-abs.zip ) that does all the work for you. Once installed and activated you will not have to configure anything! Loading your WordPress blog on Firefox or Flock , you will magically your blog listed in the drop-down list of search engines.
For the source you reference here .

Manual installation of the OpenSearch standard

For those wishing to carry out the installation of the OpenSearch standard in manual mode can follow the simple tutorial shown below and / or refer to the documentation on this site OpenSearch .

To report a search engine to your browser, just create an XML file on our site or Blog. Here for example of the file opensearch_desc.xml undolog.com:

1
2
3
4
5
6
7
8
9
?> <? Xml version = "1.0"?>
<OpenSearchDescription xmlns = "http://a9.com/-/spec/opensearch/1.1/"
xmlns: moz = "http://www.mozilla.org/2006/browser/search/">
<ShortName> Undolog </ ShortName>
<Description> Open Search Undolog.com </ Description>
width = "16" type = "image/x-icon" > http://www.undolog.com/favicon.ico </Image > <Image Width = height = "16" "16" "image/x-icon" type => http://www.undolog.com/favicon.ico </ Image>
method = "get" template = "http://www.undolog.com/?s={searchTerms}" /> <url "text/html" Method = type = template = "get" "http://www.undolog.com/?s={searchTerms}" />
<moz:SearchForm> http://www.undolog.com/ </ moz: SearchForm>
</ OpenSearchDescription>

As you can see its format is quite simple. The point is imported line 7:

1
2
3
...
method = "get" template = "http://www.undolog.com/?s={searchTerms}" /> <url "text/html" Method = type = template = "get" "http://www.undolog.com/?s={searchTerms}" />
...

This tells the browser how and where to search. Normally, as in this case, WordPress uses the standard:

1
http://mioblog.com/?s=stringa to search

However, depending on need, as I did for Divoogle , this part of the code may vary. della nostra home page: Once you create this file, simply insert a tag link in the section head of our home page:

1
2
<! - OpenSearch ->

segnalerà al browser (che lo supporta) dove recuperare tutte le informazioni per aggiungere il motore di ricerca. Through the attribute rel="search" , this link will signal to the browser (that supports it) where to get all the information to add the search engine.

Continued ...

Simple Accordion with the class USimpleTabStrip

The class USimpleTabStrip , presented Unobtrusive Simple TabStrip , can also be used to create a simple menu Accordion .
offerti da Scriptaculous : Using the effects of BlindUp() and BlindDown() offered by Scriptaculous :

1
2
3
4
5
6
7
8
9
10
function init () {
USimpleTabStrip ( ) ; UTS USimpleTabStrip = new ();
; UTS. Init ();
function ( e ) { UTS. OnShow = function (e) {
( e ) ; new Effect. BlindDown (s);
}
function ( e ) { UTS. onHide = function (e) {
( e ) ; new Effect. BlindUp (s);
}
}

And relocating the HTML elements ( HTML source ):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
"accordion" > < div class = "accordion">
"#acc1" > Accordion 1 < / a > < a href = "# ACC1"> Accordion 1 </ a >
"acc1" >< / a > < a name = "ACC1"> </ a >
< div >
h1 > < h1 > # 1 Content </ h1 >
p > < p > Blah blah blah .... </ p >
</ div >

"#acc2" > Accordion 2 < / a > < a href = "# ACC2"> Accordion 2 </ a >
"acc2" >< / a > < a name = "ACC2"> </ a >
< div >
h1 > < h1 > # 2 Content </ h1 >
p > < p > Blah blah blah .... </ p >
</ div >

"#acc3" > Accordion 3 < / a > < a href = "# ACC3"> Accordion 3 </ a >
"acc3" >< / a > < a name = "ACC3"> </ a >
< div >
h1 > < h1 > # 3 Content </ h1 >
p > < p > Blah blah blah .... </ p >
</ div >

</ div >

You get a simple menu Accordion which can be used very quickly.

Continued ...



Stop SOPA