Archive for the ‘Tutorials’ Category

Play youtube videos in flash tutorial

Wednesday, July 4th, 2007

Like i promised many of you , here is a quick video tutorial on how to load youtube videos in flash , the only thing is im running out of time and i have many other projects to deal with so its a kinda fast so Listen and watch carefully , if you have a question regarding the tutorial you can always post a comment .

Things to remember :

  • AbdulQabiz youtube php engine that is downloadable with the example sourcecode ( Many thanks to him ) .
  • Dont forget to get your own developer ID since all the rest requests requiers the dev id e.g:
    http://www.youtube.com/api2_rest?method=youtube.users.get_profile&dev_id=YOUR_DEV_ID
    NOTE THAT YOU WONT NEED A DEV_ID IF YOU WILL MANUALLY ADD THE YOUTUBE VID LINKS .
  • Read the INTRODUCTION and the DOCUMENTATION .

Things to consider :
The application i built at http://www.zainals.com/xperments/youtube is reading the XML file from youtube , now i didnt explain much about that because its a different topic but if you would like , i can make another video about xml when im free , but for the time being google it , you can find many tutorials at kirupa gotoandlearn.com and tutorialvid.com

Unfortunatly youtube disabled or changed their crossdomain xml file as mentioned on abdulqabiz blog , and will have to use some sort of a proxy script e.g :

<?php
$dataURL = "http://www.youtube.com/api2_rest?method=youtube.videos.list_featured&dev_id=YOURDIV_ID";
//note that this will not follow redirects
readfile($dataURL);
?>

Enjoy the following vid … Enlarge the vid for a clearer preview …

Flash math , using atan2 …

Wednesday, April 18th, 2007

Usage

Math.atan2( y, x )

Parameters
x A number specifying the x coordinate of the point.

y A number specifying the y coordinate of the point.

Returns

A number.

Description
Method; computes and returns the arc tangent of y/x in radians. The return value represents the angle opposite the opposite angle of a right triangle, where x is the adjacent side length and y is the opposite side length.

Get wordpress posts in flash …

Monday, March 26th, 2007

got flooded recently with emails requesting a tutorial on how to get wordpress posts into flash , now i dont have enough time to make a tut , but i will go through it in here quickly so pay attention .

Important links :
XML-RPC on Wordpress
XML-RPC home
XML-RPC tutorial press

———————————————-
Now as far as i remember i downloaded the movable type class from here http://www.dentedreality.com.au/bloggerapi/

download the MTC ( movable type class ) and extract them in your folder on your webspace ( should support php) .

Now open up a new php document call it what ever you want , i called it test.php copy & paste the following code :


include_once("class.mtclient.php");
$username = "USERNAME"; //Blog user name
$password = "PASS"; // Blog Pass
$host = "zainal.wordpress.com"; //change this to your wordpress site
$path = "/xmlrpc.php";//"/path to xmlrpc , keep it as it is , sometimes it needs
// the full path e.g www.abcd.com/blog/xmlrpc.php
// create a new blog
$blog = new mtclient($username, $password, $host, $path);
//get last 6 posts ...
$myBlogs = $blog->getRecentPosts($username , 6);
//cant remember why i kept the counter ….
//OH YA the counter will be used to plot user_data e.g user_data1 , user_data2 , notice the &
// mark below its what flash will read and split data based on ” | ” ….
$counter = 1;
// loop through the MultiD array
for ( $row = 0; $row < 6; $row++ )
{
//At this end you can always Produce XML doc , or as in my case i added "|"
// so i can split Data in flash later on ...
print "&user_data$counter=".$myBlogs[$row][title].'|'.$myBlogs[$row][link];
$counter++;
}
?>

now you can get more than title and link here is an explanation :

/* usage:

requires the following files to be in the same directory:
class.bloggerclient.php
xmlrpc.php

re-implements the following methods with metaWeblog
which returns strings “description”, “link”, and “title”
instead of a single “content” string.

getRecentPosts
getPost
newPost
editPost

also adds the special movabletype methods
which allow category assignment and retrieval
and for listing of supported methods

getCategoryList
getPostCategories
setPostCategories
supportedMethods

example:

include_once(”class.mtclient.php”);

$username = “myusername”;
$password = “mypassword”;
$host = “www.myhost.com”;
$path = “/path/to/mt-xmlrpc.cgi”;

$blog = new mtclient($username, $password, $host, $path);
$myBlogs = $blog->getUsersBlogs();
*/

flash code :

var sender = new LoadVars();
var receiver = new LoadVars();
high= 22;
u = 0;
url = [];
receiver.onLoad = function(ok){
if(ok) {
loader.unloadMovie();
for (var i = 1; i <= 6; ++i)
{
receiver["dataPacket" +i] = receiver["user_data" + i].split("|");
var Ntitle = receiver["dataPacket" + i][0];
url[i] = receiver["dataPacket" + i][1];
trace ("data " + Ntitle);
trace ("data " + url[i]);
trace('attaching');
_root.attachMovie("box", "box" + i, _root.getNextHighestDepth());
_root["box"+i].btn.ID = i;
_root["box"+i].pTitle.text = Ntitle;
_root["box"+i].btn.onPress = function() {
getURL(url[this.ID],_blank);
}
_root["box"+i].btn.onRollOver = function() {
trace('get some');
}
_root["box"+i]._y = 65 +(high * u);
trace('hight ' + (high * u));
_root["box"+i]._x = 0;
u++;
delete receiver["user_data" + i];
}
}
}
sender.sendAndLoad("http://localhost/movabletypeClass/test.php", receiver, "post");

Like i said earlier , you can always produce XML doc from the test.php and read that in flash , there are many ways you can read external files , it all depends on YOU !
Flash & php source files can be downloaded from here …@ ZAINALS

New breed of tutorials , tutorialvid.com.

Thursday, February 22nd, 2007

Here is how the web is advancing …

you dont need to seek written tutorials anymore , why would you do that when you are able to watch a video of your selected tutorial(s) ?

Tutorial Vid 

Long live Web 2.0 !

83 Beatifull wordpress themes you havent seen on smashing Mag!

Monday, February 12th, 2007

God i love em all !!!

83 Beatifull wordpress themes 

tubetorial , Learn the easy way !!!

Monday, February 12th, 2007

We all know how the internet is now affecting everything …
Its advancing in a crazy way , News , RSS , Videos , Songs , Listen , Learn , Interact , watch , vidCams , i can go on forever .
its the new way to promote your business and your ideas …

Long story short … TubeTorial.

Free Videos on :

  • google adsense
  • Optimzie wordpress
  • learn HTML
  •  Easy money with google Adsense
  • how to increase commentsand views with 1 Plugin
  • Make money with RSS feeds .
  • and much more of Videos !!

Why not giving it a try , Free Vids , makes everyone happy …

Simply the best Bookmark !!

Friday, January 26th, 2007

Every Developer/Designer should have this on the top of the their bookMarks !

the site includes :

  • Tutorials ( Everything  Flash , php , ajax , css etc )
  • Site reviews ( best sites ever)
  • free useful tools ( fonts , code snippets )
  • and much MORE !

I cant say more that You’ll have to see it  your self !!

http://www.smashingmagazine.com 

Im a CoffeeCup Ambassador !

Thursday, December 7th, 2006

CoffeeCup Web Design Software

as quoted

“you have been selected as one of the few that I would like to personally invite to become a CoffeeCup Ambassador. This is an exclusive club of our biggest fans, best users, and closest friends.”

So what is CoffeCup ?

CoffeeCup Software started in a real Coffee House 1996. Our first program was the HTML Editor. Over the last 10 years we have created a lot more Web Design & Flash Software. Our philosophy has always been to create software and services so you can make better Websites. We are dedicated to helping you by offering extraordinary support so we can succeed together. Consider us a partner and a friend, because we really are about Fresh Software and Warm People.

But how can it Help me ?
As in for me , i created a jukebox that would take several weeks in development , in just 2 minutes ! check it out Zainals JukeBox (web Mp3 Player) * I only uploaded 1 song .

You can modify the skin , select between a range of KooL skins and upload em directly to your website … easy eyh ?

Why wait … go download the trials and check em out now  Get CoffeeCup Web Design Software

Quick Flash “Prealoder” tutorial .

Wednesday, December 6th, 2006

A quick tutorial i made about “preloaders” using a single frame ( onEnterFrame Event ) .
Mind you , i was @ work while doing this :D Enjoy

here is the code used , i know the vid aint that clear , but thats the best i can do for YouTube :

stop();
var initX:Number = _root.mask._x;
onEnterFrame = function() {
var total:Number = this.getBytesLoaded()*100/this.getBytesTotal();
this.mask._x = initX+(total*this.mask._width/100);
this.dynoText.text = Math.floor(total);
if( total == 100 ) {
delete onEnterFrame;
this.gotoAndStop(2);
}
};

if you need the files , lemme know …

Get X & Y resolution using flash …

Sunday, December 3rd, 2006

Been a while since i posted anything about flash ( lazy cow moo) heh !

Ever wanted to keep/save information about your site visitors ?
I think its important to keep an eye on visitors resolutions , so when you get to design a website , you’ll know what dimensions you’re going to use . ( including Operating system and IP ).

now lets start with MySQL DataBase , We’ve got several ways to operate & manipulate Mysql DB , either using shell/Command line or simply use PhpMyAdmin

Lets start with creating a database :

CREATE DATABASE `information` ;

Now lets build the table & fields :

CREATE TABLE `resolution` (
`ID` INT( 10 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
`X` INT(10) NOT NULL ,
`Y` INT( 10 ) NOT NULL ,
`OS` VARCHAR( 40 ) NOT NULL
) ENGINE = innodb;

Okay enough with mysql , now lets jump to flash & create 2 loadvars() , one to send and one to recieve , then we’ll use System.capabilities object to get the X & Y Resolution and the Operating system running on the visitor machine.
After collecting the information we’ll need to send it to the database using PHP , i’ll show you how ,later in this tutorial .

Flash :

loadObject = new LoadVars();
rcvObject = new LoadVars();
loadObject.Width = System.capabilities.screenResolutionX;;
loadObject.Height = System.capabilities.screenResolutionY;
loadObject.OS = System.capabilities.os;
trace(System.capabilities.os);
//send it
loadObject.sendAndLoad(’http://www.YourWebSite.com/send.php’,rcvObject);

rcvObject.onLoad = function() {
if(this.Result==’connected’) {
trace(’inserted’);
}else{
trace(’wopsy, something went wronge !!’);
}
}

trace(loadObject.Width +’ By ‘ + loadObject.Height + ‘ Using : ‘ + loadObject.OS);

Aight , now lets build the PHP script that will make flash communicate with the database.
It will recieve the loadvars objects and will encapsulate them into php variables :
PHP:

<?php
$host = ‘localhost’;
$user = ‘root’;
$pass = ”;
$db = ‘information’;
$table=’resolutions’;
$Width = $_POST['Width'];
$Height = $_POST['Height'];
$OS = $_POST['OS'];

$DB = mysql_connect($host,$user,$pass) or die(mysql_error());
mysql_select_db($db)or die();

$query = “INSERT INTO `resolutions` ( `ID` , `X` , `Y` ,`OS`)
VALUES (
NULL , ‘$Width’, ‘$Height’ , ‘$OS’
)”;

$result = mysql_query($query)or die(mysql_error());

if($result){
echo ‘Result=connected’;
}else{
echo’some went wrong’;
}
?>

you can always add more information ( you will need to add more fields into your database) such as time , referrers & ip ..   e.g:

IP:

$ip = (getenv(HTTP_X_FORWARDED_FOR))
?  getenv(HTTP_X_FORWARDED_FOR)
:  getenv(REMOTE_ADDR);

Referrer: track where you visitors are coming from :

$refer = $_SERVER['HTTP_REFERER'];

Time & Date : that will be within the mysql query using mysql function NOW();

$query = “INSERT INTO `resolutions` ( `ID` , `X` , `Y` ,`OS`,`IP`,`time`,`referrer`)

VALUES (NULL , ‘$Width’, ‘$Height’ , ‘$OS’ , ‘$ip’ ,NOW(),’$refer’
)”;

thats it :D in case you are wondering how are you going to view the details , you can use the grid component within flash to view them with the help of PHP off course .
something like THIS!

i will show you how to do this on my next tutorial