Koz O' Rama

Wednesday, April 9, 2008

Dynamic Text Under Mask in Flash CS3

Having trouble displaying dynamic text under a mask in Flash CS3? So was I! I figured it out, so here's how to do it. This one's going to be short and sweet.

All you need to do to fix this problem is embed the text when the movie publishes. You can do this by selecting your dynamic text box and clicking the "Embed" button in the properties panel.

When the window pops up asking you which glyphs to select, do not select all! I accidently did this and wound up embedding every single character for each language into my file. Assuming you're building an English speaking flash site, you would select 'Uppercase', 'Lowercase', 'Numerals', and 'Punctuation'. This will take care of all characters in the English script.

Test your movie, and voila! You have dynamic text appearing under a mask!

I hope this has been of some help to somebody. Leave me a comment if you liked or hated this one. Take care.

- Koz

Labels: , , , ,

Saturday, April 5, 2008

Simple Contact Form With PHP

In this post I'm going to teach you how to build a simple contact form using PHP. This post does not cover form verification or headers, but I plan on writing a few articles in the future about these topics. For now we'll just build a functional form with php integration.

The first thing that we'll need is a simple form. Lets use the following:

<form action="contact.php" method="post">
     Name: <input name="name" size="50" type="text">
<br />
      E-mail: <input name="email" size="50" type="text">
<br />
      Subject: <input name="subject" size="50" type="text">
<br />
      Message:
<br />
      <textarea rows="20" cols="50" name="message"></textarea>
<br />
      <input value="Submit!" type="submit">
</form>

Simple enough eh?

I'm going to assume that you know the different parts of the form. Just as a refresher know that the action property tells what page to send the browser to to process the form, and the method property tells you how the variables will be sent to the server. You can use either the "get" method or the "post" method. The main difference between the two is that the "get" method will include the variables in the URL in the address bar, and the "post" method will not. GET methods are typically good in inventory systems where you would like a user to be able to bookmark a specific item, while POST methods are better for form usage.

Anyway, back from one of my tangents. Save that form in whatever file you'd like and send it up to your server.

Now start a new text file and go ahead and save it as contact.php. This is going to be the file that processes the form, and mails the message to the user.

First the code, and then the explanation:


<?php

// Step 1
$name = $_POST['name'];
$subject = $_POST['subject'];
$email = $_POST['email'];
$message = $_POST['message'];

$to = "akozlik@gmail.com"; // The e-mail address you want the message sent to

// Step 2
$header = "From: " . $name . " < " . $email . ">";

// Step 3
mail($to, $subject, $message, $header);

// Step 4
header("Location: thankyou.php");

?>

Step 1:

Set a few variables and get their values using the $_POST prefix. If you used the "get" method on your form replace this with $_GET['name'] etc . . .

Step 2:
I know I said that I wasn't going to put in headers, but I felt this is a pretty good one to include in this tutorial. I go more into headers on a different post, but know that this one is great to have. The header variable winds up with the form "From: Andrew ". When you've received e-mail you've probably noticed that the sender's name shows up in the From field in your inbox. This is because of the way the header was set up. When the user sends a message from your page, the name they provided will show up in your inbox.

Step 3:
The meat and potatoes of this project is PHP's mail() function. This is setup in the format mail(to, subject, message, header). Notice that there is no "from" parameter. This is why I included the From in the header, as that's how the mail servers read that information. We simply include our variables and let our sendmail server do the rest.

Step 4:
After mail is sent, you can then redirect the user to a thank you page. Remember that this header() function must be used before any text is displayed to the browser. If you use any echo statements or straight HTML before this point, the redirect will not work and you will get an error.

Well, that's about all I have to say on the topic of simple forms. Hopefully somebody finds this to be a useful article and is able to get some work done thanks to it. As usual, I'll put my shameless plug in here and ask that you click a few ads before departing, if you like the article. Better yet, subscribe to my RSS feed located to the side of this post. Thanks for reading, and take care.

-Koz

Labels: , , ,

Friday, April 4, 2008

Importing Photoshop to Flash

I recently began working with a client who had a design for a website in Photoshop but wanted to have the site built using Flash CS3. Flash CS3 has some great features for importing to Photoshop and can make the transitions between the two programs quite painless.

After your design is done in Photoshop it's time to import it to Flash. This is quite easy. All you need to do is go to File > Import to Stage or File > Import to Library.

Before doing this I make sure that I'm inside the movie clip that I'm wanting to import to. If you have a section for an About Us page, and have an About Us movie clip, open that clip up and do the importing.

Flash will give you the option to flatten the layers or keep them as they are in Photoshop. I typically choose to keep the layers as they are so you can make any adjustments that are needed. This gives you much more flexibility with your project.

After choosing your option you'll get a window that asks you which layers you'd like to import. If you kept your layers in Photoshop organized in folders, you can choose to import them by folder. This is especially useful if your Photoshop file has each section in it's own folder.

After that it's just a matter of positioning your graphics and adding all the interactivity.

I hope this is helpful to you in your next project. Take care until next time.

Wednesday, April 2, 2008

Loading External Text in Flash CS3

I've been out of the Flash game for quite a while now. The last version I've been using was Flash MX. Imagine my surprise when I downloaded Flash CS3 and found that it now uses purely Actionscript 3.0. All my previous methods of programming Flash were rendered useless by all the new standards. Alas, I began my quest to find useful information, and hit a few roadblocks.

Adobe's livedocs are ok, but it really helps to find real world examples. I tried searching for the various things I needed, but to no avail. I finally found some screencasts on youtube that helped, so I got my problem solved. It was at that point that I decided to write my own articles to help people achieve specific tasks using Flash, PHP, DHTML, and whatever else I can come up with.

Now, enough of my Rant. Lets code!

So my main task for this article is to load an external file into a flash app, and display it in a text box. This is specifically good for loading text that will be changed periodically. Rather than open flash, edit the file, re-publish, and upload the new file, you can just pull all the data from a txt file and display it there. We can even render the text as HTML!

We'll build this app using the TextArea component. Just go to Window->Components to pull up the components window. Drag a TextArea component to the stage, and give it an instance name. We'll call ours external_faq.

Now for the code. I'll give the code, and then I'll go ahead and explain it. All of the following code goes in the timeline on the same frame as the objects it references.

var faqLoader:URLLoader = new URLLoader(); // Step 1
faqLoader.load(new URLRequest("test.txt")); // Step 2

faqLoader.addEventListener(Event.COMPLETE, onComplete); // Step 3

function onComplete (event:Event):void // Step 4
{
var faq:String = event.target.data; // Step 5
external_faq.text += faq; // Step 6
}

Step 1
We need to make a new URLLoader, so we define the variable faqLoader as a URLLoader, then call a new URLLoader() object. The URLLoader will hold the data returned by the URL.

Step 2
We go ahead and load the url, using the URLRequest() object. We use the load method of the URLLoader object, and open a new URLRequest object, which contains the path to our text file. Simple enough.

Step 3

Now we go ahead and add an Event Listener to our faqLoader to listen for when the loading as been complete. An event listener is the equivalent of using an "onWhatever" event with older Action Script. There are many different Event Listeners and Event types. For instance you could have an event:MouseEvent and check for when MouseEvent.CLICK occurs to see when a user clicks their mouse on the object the code is attached to. That's getting on a tangent though.

Step 4
We set a String variable to hold the text that is loaded from the file. This will enable us to do any string manipulation we may wish to do. However, we're going to keep this one simple, and just display the text to the TextArea component.

Step 5
Finally, we set the text property of the TextArea component to our String variable. Note that we I am not using external_faq.text = faq. I am using external_faq.text += faq. Also, if you wanted to use html formatted text, you would use the htmlText property.

Finally, the text file that you have written doesn't need any variables inside it. All it needs to contain is the text you wish to display.

I hope this tutorial is useful for anybody who had the same trouble I did. I know it's a relatively simple application, but making that migration from Actionscript versions can be tough.

On a shameless side note, if you liked the article and found it to be useful, click on an add or two at the top of this page. I'm a starving college student after all, and every little bit helps. :-D

~Koz

Labels: , , , , , ,

Sunday, August 26, 2007

Great Advice


Great Advice
Originally uploaded by akozlik
Bwah ha ha ha ha!

Tuesday, August 21, 2007

Add Digg, Reddit, and Del.icio.us to Blogger

After searching the web for a comprehensive tutorial on adding digg, reddit, and del.icio.us to your Blogger blog, I decided to write my own. I eventually found the tutorials for each respective site, but wanted to add in my own comments, as well as use the actual Blogger variables for setup. Keep in mind that this post is specifically for Blogger. I can't guarantee that it will work with Wordpress, as I don't know what variables they use. Enough of the disclaimer, lets code!

Digg

Firstly, you'll have to get the javascript from digg.com. You can go to www.digg.com/tools/integrate to get it. You do not want to use the first option, as it will not keep track of diggs for each individual post. The second option, "When the URL you wish dugg differs from the current webpage" will work perfectly for us. Copy the script from that section.

The next step is to add the link to your blogger template. Logg into blogger and click the 'Template' tab. This will allow you to edit the html on your blog. Keep in mind that the page uses XHTML, therefore all coding rules apply. i.e. all lowercase tags, make sure all tags are closed, case sensitive, etc.

Scroll down the the <-- begin .post --> section of the code. Below this, you will see a tag that says <$BlogItemBody$> Below this is where you will want to put in your code. I found that using a table to maintain structure gave me the appearance I wanted. It also left room for additional links in the future. I used the tag.

<table width="100%">
<tr>
<td width="25%">
</td>
<td width="25%">
</td>
<td width="25%">
</td>
<td width="25%">
</td>
</tr>
</table>

In between the first set of tags you'll want to add the script for digg. Paste the <script%gt; tags there.

Next, change the digg_url = 'WEBSITE_URL' variable to: digg_url = '<$BlogItemPermalinkUrl$>' This will automatically copy the individual posts direct url to the digg button. When the script calls the diggthis.js script on digg's server, this is the variable it will pass.

All you need to do now is save all the changes and republish your blog. After doing so, you should see that you now have a fresh digg button under each posts. Now you can successfully connect to the digg network and get traffic to your site!

Reddit

You'll follow the same techniques listed above to install the reddit button onto your blog. To find the script to copy go to www.reddit.com/buttons. You'll be given a list of different buttons you can use to hook reddit up to your site. Personally, I like style 2 because it maintains the same style as the digg tag. Nothing brings style out like consistancy. This type of button is also beneficial because you can see how many people have dugg or redd your site. Anyway, back to the task at hand.

Copy the <script> tags under whichever style you wish you use. You must include the green text in order to connect each individual post to your blog. Paste this text in it's entirety between the second set of td tags listed above in the digg section.

All you need to do now is change the script variables. Change the script so it reads as follows:

<script>reddit_url='<$BlogItemPermalinkUrl$>'</script>
<script>reddit_title='<$BlogItemTitle$>'</script>
<script language="javascript" src="http://reddit.com/button.js?t=2"></script>

Where t= the style number you wish to use.

Save, re publish, and presto! You now have an active reddit link on your blog!

Del.icio.us

I've found that adding a link to your del.icio.us profile could be useful to some. As such, I'd like to explain how to hook it up to your blog. Unlike the digg and reddit buttons, I feel that this button looks much better if placed in your right sidebar. I've placed it under my Atom rss subscription link, but you can put it wherever.

Firstly, if you're not already subscribed to del.icio.us, do so now. If you're unfamiliar with the site, take a look around. It's actually extremely useful, especially for school.

After logging in, click on the 'settings' link at the top right corner of the page. From there, scroll down to the Blogging section and click 'network badges'. After selecting the options you want, copy the javascript code that's given to you.

Back in your template page, scroll down until you see the <MainOrArchivePage> tags. Below this is where you will paste your script. I pasted mine under the <p id="blogfeeds"> tag, but you can place yours wherever. This post assumes that you're using a default setup, so if you're using a template just experiment. After you've pasted the code save the changes and republish the blog. After doing so, you'll find that you have a nifty little del.icio.us link on your sidebar. We even managed to make it look like it belongs there, so the blog doesn't look like it belongs to an amateur! I know that sounds funny with me using one of Blogger's default layouts, but graphic design was never really my strength.

I hope this post has been helpful to some. We'll see if it gets around as an easier alternative to some of the other instructions out there. If the post has helped please digg, reddit, or del.icio.us the post to get it around. Take care, and keep coding!

Andrew

Labels: , , , , , , ,

Gmail scam

Just read an interesting article about a new Gmail phishing e-mail that's being sent around the net. The full article can be read here: http://5thirtyone.com/archives/845#comment-50706

I decided to do some investigative work and see what I could figure out about the person running the scam. Their server's based in China, so obviously nothing will ever be done about it. It's unfortunate that there's no international law against spamming/scamming/phishing, etc. All people have to do is purchase an offshore server and voila! Instant identity theft. The results of my investigation, and my reply to the post, are posted below:

===============================================================
Just figured I’d putt around on the fake website. I tried going directly to the login.php page and got a table that looks like this:

Warning….You may ingore this…!!!!You have set to get upload/attachments in your email from form, however, you have not set temp folder path, where your image would be save Please Set this path in variable “$TempFolder”

Warning….You may ingore this…!!!!However, If you don’t specify the path, then uploaded files will be store in the folder ” /home/fabio20/public_html/gmailupgrades// ” Is this ok ?Just for your information

What do you wish to do with uploaded files, after sending those file with email as an attachment to you ? Do you wish to keep upload files or wish to delete? If you wish to delete your uploaded files after sending an email to you,set option to “0″,like,”$DeleteUploadFiles=0″, if you wish to keep the uploaded files set this to “1″, Currently it is set to “0″

Obviously the guy’s running a linux server with the username fabio20. A whois.net search on the domain name returned these results:

Registrant Contact:
name– DNS MANAGERorg– ABSOLUTEE CORP. LTD.
country– CN
province– Hongkong
city– Hongkong
address– FLAT/RM B 8/F CHONG MING BUILDING 72 CHEUNG SHA WAN RD KL
postalcode– 999077
telephone– +00.85223192933
fax– +00.85223195168
E-mail– gm2827655711104@absolutee.com

It’s the same information for all sections of the whois.net result.

I checked the domain the e-mail was registered at, and didn’t pull up an actualy website. Rather, I googled the domain section of the e-mail and found that a lot of scammer e-mails come from that domain. It’s probably something offshore, maybe Hong Kong also. I didn’t bother doing the whois.net search on it, but if anybody’s bored you can do it.

Just wanted to throw this information out there for everyone to look at. I know it’s not super important or anything. It’s too bad that these people make so much money from scamming and phishing. If only people would begin to wisen up and not trust e-mails asking for verification of usernames and passwords. Alas, this problem will always be around.
===============================================================

Just make sure you don't fall for this scam. I'm sure a lot of people are going to anyway, because the site is actually pretty convincing. You can check out the original site at www.gmailupgrades.com *DO NOT INPUT YOUR ACTUAL LOGIN INFORMATION*

Remember, information is power.

-Andrew