Wednesday, December 16, 2009

My Flash to EXE fullscreen scalling settings

The new version of Flash Player when rendering an EXE document doesn't want to obey the "fscommand" for some reason. I don't know why, I don't care. This works just fine:

fscommand("fullscreen", true);
fscommand("allowscale", false);
fscommand("showmenu", false);
Stage.scaleMode = "showAll";

Thursday, December 3, 2009

CSS Selectors Browser Compatibility

Compatibility is one of the most annoying parts of web scripting and programming. I've found a great reference when it comes to CSS selectors. This should help you figure out what will work in old browsers and what you'll need to find a workaround for.

Wednesday, December 2, 2009

Hiding Text on Form Submit Button

I wanted to have CSS replace a submit button for one of the forms on my site. So I decided to style it with a background image and set a text-indent to hide the text. It worked nice but in Internet Explorer, the text wouldn't go away.

I found a strange way to make the text disappear even in Explorer. Just use this bit of CSS for the submit button.

{
color: transparent;
text-transform: capitalize;
}


That should do the trick!

Tuesday, November 17, 2009

Mute Streaming Audio in Flash

Muting sounds that are streaming in Flash isn't as simple as changing the volume of an object via a "mute" button. But it is surprisingly EASY! I can't believe I didn't see it. AND the movie continues to play and unmuting just brings the sound back in.... duh!

Well, I searched and searched and finally found something. Thanks (http://www.actionscript.org/forums/showthread.php3?t=32982)! I made some simple modifications.

This is my code. I made a MC with 2 frames and buttons in it. In frame 1, a button that calls "mute();" here's the button code for the one that's in frame 1.

on (release) {
nextFrame();
this._parent.mute();
}
And frame 2 has this:

on(release) {
prevFrame();
this._parent.unmute();
}

And here's the code in the root. I could easily make a volume slider that sets the "level" variable, and would then set. But for most stuff, we simply need the sound to be either there... or not.

level = 100;
globalSound = new Sound();
globalSound.setVolume(level);

function mute() {
trace("mute");
//previewaudio.stop();
globalSound.setVolume(0);
}
function unmute() {
trace("unmute");
globalSound.setVolume(100);
}

Enjoy!

Monday, October 19, 2009

Vertical Ticker Scroll with jQuery

Ever wanted to make those cool vertical scroll things? Here is a great light weight way to accomplish it:

Friday, October 9, 2009

Kern dynamic text is Flash Actionscript

I've always needed to know how to kern dynamic text is Flash Actionscript, and I knew there had to be a way. Well, here it is. I discovered this somewhere, made some tweeks, good stuff.

function kernText(myTextField, kerning) {
myTextField.html = true;
var newFormat:TextFormat = new TextFormat();
newFormat.letterSpacing = kerning;
//newFormat.font = "Arial"; // Add now whatever format needs you have.
myTextField.setTextFormat(newFormat);
}

Wednesday, October 7, 2009

Flash right-click menu

I've always been looking for a nice and easy Flash right-click menu builder. This one seems extremely straight-foward and EASY!



function calledFunction1() {
trace("calledFunction1");
}

function calledFunction2(){
trace("calledFunction2");
}
MENU = new ContextMenu();
MENU.hideBuiltInItems();
insertAfter = new ContextMenuItem("Call function 1", calledFunction1);
insertBefore = new ContextMenuItem("Call function 2", calledFunction2);

MENU.customItems.push(calledFunction1);
MENU.customItems.push(calledFunction2);
_root.menu = MENU;



Thursday, July 2, 2009

Easy way to Parse RSS in PHP

Here is some simple code for parsing RSS 2 in PHP. It's so easy, I can't believe it.

<?php
     $doc = new DOMDocument();
   $doc->load('http://www.softarea51.com/rss/windows/Web_Development/XML_CSS_Utilities.xml');
   $arrFeeds = array();
   foreach ($doc->getElementsByTagName('item') as $node) {
    $itemRSS = array (
      'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
     'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
     'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
     'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue
     );
    array_push($arrFeeds, $itemRSS);
   }
?>  

Thanks to: How to parse RSS feeds with PHP

Monday, June 22, 2009

CSS Image Replacement for Buttons

Yes, you could just use the input type="image" but if you want to replace buttons with images purely with CSS, this is a great method.


A quick note, this won't work in IE6 unless you set your button as a BUTTON not an INPUT. This is a very important point.

Friday, June 19, 2009

Keep Footer at the Absolute Bottom of Page

Have you ever wanted to have a footer always be on the bottom of the page, even if the content of the page wasn't very tall? Usually people use javascript, but below is a way to do it with only CSS. This even works on IE6!


P.S. if you view source on the above link, you will see all the CSS and HTML you need. It works great!

Wednesday, June 3, 2009

Nice Drop Down Menues

I've been on a quest for a long time to find a good, reliable and customizable dropdown menu. I've found some but this is a great one to try out:

Thursday, May 28, 2009

PHP Mail on Windows Server

I had a weird problem with my PHP mail() function on a windows server. When I was trying to send the emails, the email headers would show up in the body of the email itself. After a lot of frustration, I figured out a solution that worked for me.

After each header, you usually add a "\r\n". It seems like the \n was giving us the problem so I took it off. So after each header I had instead "\r". It worked... so there you go.

For example:

$headers = 'From: someemail@email.com' . "\r";
$headers .= 'MIME-Version: 1.0' . "\r";
$headers .= 'Reply-To: replytoemail@email.com' . "\r";

Wednesday, May 20, 2009

Ajax with jQuery

jQuery makes it really easy to implement AJAX.  Check out this out for more information: http://docs.jquery.com/Ajax

If you're not sure what jQuery is or AJAX, check out some of our other posts in those categories.

Tuesday, May 12, 2009

Social Bookmarking Links

Here is a great resource if you'd like to add buttons to your site for social networking links.  For example, if you have an article and want to create a Digg This link.  There are a lot of ways to do this but here is one simple way:

Tuesday, April 28, 2009

CMS Recommendation: ExpressionEngine

I just wanted to give a quick recommendation to a Content Management System that we've been using and have found to be really great.  With all due respect to the druple or joomla-lovers, Expression Engine is a much cleaner way to go.  It does come with a premium, but they have a core version for free which is more than enough for most smaller sites.


Check it out.  Like all CMS's there is a learning curve but this CMS gets my recommendation.

Ternary Operator (Short IF Statements) in PHP

This is a cool little 'trick' if you want a quick IF statement in PHP.  You'd use the Ternary Operator which would evaluate similar to the IF operator.

Syntax is like this:

// Example usage for: Ternary Operator
$action = ("john" != "frank") ? 'john isnt frank' 'john is frank';


So in this case, the output 'john isnt frank' would be saved to $action.

The first portion of the before the ? is what is being evaluated.  So we check if the string "john" is not equal to "frank".

Between the ? and the : is what to do if we returned TRUE.

Between the : and the ; is what to do if we returned FALSE.

Since I have $action = at the beginning, the output is saved to that variable.

For more info on this, see the PHP documentation: http://uk2.php.net/operators.comparison (you'll need to scroll down a little)

Wednesday, April 8, 2009

Web-safe Fonts

We stumbled upon a great resource for web safe fonts (okay... we just googled it, but still...).

Take a look at this site, it is a wonderful resource and will help you match your fonts to ones that work on all computers.

CSS Position Help

Most people know this, but for those who are struggling or just need a reminder, the below link is a great resource to understanding positioning in CSS.  Take a look.

Wednesday, March 11, 2009

Editing .htaccess with PHP

Although this isn't necessarily recommended, sometimes it is needed.  Basically, we'd use PHP to edit our htaccess document to set permissions or redirects or whatever else.

Here is a post about doing it: Editing .htaccess with Php - Dev Shed

Wednesday, March 4, 2009

Flash - Old School Actionscript Tweening

ON the MovieClip itself

/* */
onClipEvent(load) {
mytime = _parent.timeSlower;
mybounce = _parent.bounceSlower;
}
onClipEvent (load) {
physics = [mybounce,mytime];
start_x = this._x;
start_y = this._y;
start_w = this._width;
start_h = this._height;
start_xscale = this._xscale;
start_yscale = this._yscale;
start_a = this._alpha;

xspeed = 0;
yspeed = 0;
aspeed = 0;
wspeed = 0;
hspeed = 0;
xscalespeed = 0;

//this._width = (this._width*1.2);
//this._height = (this._height*1.2);

//this._width = this._width/2;
}
onClipEvent (enterFrame) {
xscalespeed = ((start_xscalespeed-this._xscale)*physics[0])+(xscalespeed*physics[1]);
this._xscale += xscalespeed;

yscalespeed = ((start_yscalespeed-this._yscale)*physics[0])+(yscalespeed*physics[1]);
this._yscale += yscalespeed;

wspeed = ((start_w-this._width)*physics[0])+(wspeed*physics[1]);
this._width += wspeed;

hspeed = ((start_h-this._height)*physics[0])+(hspeed*physics[1]);
this._height += hspeed;

xspeed = ((start_x-this._x)*physics[0])+(xspeed*physics[1]);
this._x += xspeed;
yspeed = ((start_y-this._y)*physics[0])+(yspeed*physics[1]);
this._y += yspeed;
aspeed = ((start_a-this._alpha)*physics[0])+(aspeed*physics[1]);
this._alpha += aspeed;
}
/**/

Still need to establish the "time" and "bounce" variables for consistency across the board.

Monday, February 16, 2009

ASP's Fast Way To Pull Data from Database

This is a great way to pull in all records from a (MSSQL) database in ASP.

use the GetString() function for your record set!  It is pretty simple and really cool.  Here is my example:

set rs = Server.CreateObject("ADODB.Recordset")
myvariable = rs.GetString (2, , vbTab, vbCrLf, "Null")

Here is the info on the function GetString:

string = recordsetobject.GetString (StringFormat, NumRows, ColumnDelimiter, RowDelimiter, NullExpr)

For more details go here: DevGuru ADO Recordset::GetString Method

MSSQL Searching for Datetime value

This is a great resource for trying to make a query in SQL Server for the datetime data type.  Use this if you're trying to find all entries from a date like yesterday, last month, or anything else.


What I found even more useful is this little code:

query = "SELECT * FROM your_table WHERE DATEDIFF(dd, your_date_field, GETDATE()) = 0"

What that does, is get you all entries from your_table where your_date_field and the current date (today's date) are not different.  The 'dd' means day, so it is comparing the day.

This will get all entries from yesterday:

query = "SELECT * FROM users WHERE DATEDIFF(dd, datecreated, GETDATE()) = 1"

And this will get from last week:

query = "SELECT * FROM users WHERE DATEDIFF(ww, datecreated, GETDATE()) = 1"

For a full list of what DATEDIFF does take a look at this: DATEDIFF (Transact-SQL)

Have fun!

Fast String in ASP

ASP is an old framwork and really outdated but sometimes we still need to use it.  One major problem is the handling of strings.  We recently worked on a project with ASP and tried to use the standard string method to create some reports.  Basically, a report with 1,000 entries timedout, until we set the server timeout to 10 minutes...!

So here is a way to overcome this.  This is a class that you can use if you want to create strings and need to concatenate them.

Class FastString
Dim stringArray,growthRate,numItems
Private Sub Class_Initialize()
growthRate = 50: numItems = 0
ReDim stringArray(growthRate)
End Sub
Public Sub Append(ByVal strValue)
' next line prevents type mismatch error if strValue is null. Performance hit is negligible.
strValue=strValue & ""
If numItems > UBound(stringArray) Then ReDim Preserve stringArray(UBound(stringArray) + growthRate)
stringArray(numItems) = strValue:numItems = numItems + 1
End Sub
Public Sub Reset
Erase stringArray
Class_Initialize
End Sub
Public Function concat()
Redim Preserve stringArray(numItems)
concat = Join(stringArray, "")
End Function
End Class 

I will give full credit to: A Fast String Class for ASP Pages

If you want to implement this class, do something like this:

Set mystring = New FastStrign
mystring.Append("My Info")
mystring.concat()
Set mystring = nothing

This will add "My Info" to the string and then print it.  The last line is to detroy the old thing, you can also use the build in erase function.  This will make concatenating of strings much faster.

Remember I said 10 minutes...? Now it takes 20 seconds to create the report!

Thursday, February 12, 2009

Resources for RSS Feed Creation

Here are some resources on how to create a RSS 2.0 feed.

Automatic and Dynamic Title URLs from Titles using Javascript

This is a handy little javascript snipplet that will convert text in one text field to url friendly text in another.  This is very useful if you're trying to automatically create title URLs from the title of your post.  This helps with search engine optimization by giving you friendly URLs.  Below is the javascript and a test form.  You can copy it all, paste it, and test it.

<html>
<head>
<script type="text/javascript">
function urltitle(title)
{


// Create the url friendly title
var url = title
.toLowerCase() //change everything to lowercase
.replace(/^\s+|\s+$/g, "") //trim leading and trailing spaces
.replace(/[&]+/g, "and") //replace ampersand
.replace(/[#]+/g, "sharp") //replace pound
.replace(/[@]+/g, "at") //replace at
.replace(/[%]+/g, "percent") //replace percent
.replace(/[+]+/g, "plus") //replace plus
.replace(/[-|\s]+/g, "_") //replace spaces and hyphens to underscore
.replace(/[^a-z0-9_]+/g, "") //remove all non-alphanumeric characters except the underscore
.replace(/[_]+/g, "_") //remove duplicate underscores
.replace(/^_+|_+$/g, "") //trim leading and trailing underscores
;
document.getElementById('title_url').value = url;
}
</script>
</head>
<body>


<input type="text" onkeyup="javascript:urltitle(this.value);" />
<input type="text" id="title_url" />


</body>
</html>


As we usually give credits for what we find, this is where we got the original script before modifying it: Rewrite input to friendly URL

Hide Link Dotted Borders in Firefox

You may have noticed that links in firefox have a light dotted border around them.  It was intended for accessibility, so that you'd know which link you're currently focused on.  Try tabbing through a webpage and you'll see its use.

Anyway, sometimes the border is annoying, ugly, and useless.  In such cases, you can remove the border by using this piece of CSS:

outline-style:none;

Tuesday, February 10, 2009

Simple Javascript Back Link

Alright, this is pretty simply and most people know it but hey, never hurts to post.

If you want to create a link that goes back to the previous page (just like the browser back button) simply use this code in your link tag:

href="javascript: history.go(-1)"

Thursday, January 29, 2009

Dynamic buttons in Flash using ActionScript 2.0

I am often needing Flash to create dynamic buttons from an Array (or external TXT (text) document). Here's how I do it:

1. Make your button an actual MovieClip on the stage however you want them all to look/work. Create a dynamic text field (center justified - or whatever) within the button with the instance property of "text_txt" for this example. (You can name it whatever you want, but you'll need to change some of the code below).

2. In the library find your MovieClip. Open the Symbol properties dialog.

3. Select the "export of actionscript" check box. Identifier "myButton"... again, for this example only. Click OK.

4. Now return to the stage and in frame one of a layer, I've named my top-most layer "actions". Copy and paste the following:

for(i=0; i
target = this.attachMovie("myButton", "myButton"+i, i, {_x:10, _y:30*i} );
target.text_txt.text = nav[i];
target.myLink = url[i];
trace(myLink);
target.nr = i;
target.onPress = function(){
//getURL(this.myLink);
trace("Hi, I'm "+this._name+" and my number is "+this.nr+". The link is: " + this.myLink);
}
}

With some extra work we can make this a horizontal menu, getting the width of each text box and moving the rest.... I'll post that another time.

5. I created an Array that I want to use for the labels of my buttons. Eventually I will pull these labels from a database table, but for now, paste this info above the previous code.

var nav:Array = Array();

nav[0] = "nav 1";
nav[1] = "nav 2;
nav[2] = "nav 3";
nav[3] = "nav 4";
nav[4] = "nav 5";
nav[5] = "nav 6";
nav[6] = "nav 7";

6. Now we need these links to do something, right? So let's create an Array for our URLs. Paste this array just below the previous but before the button code "for" stuff.

var url:Array = Array();

url[0] = "http://www.adobe.com";
url[1] = "my link 1";
url[2] = "my link 2";
url[3] = "my link 3";
url[4] = "my link 4";
url[5] = "my link 5";
url[6] = "my link 6";


6. Ta da! That's all that is to it.

7. Publish your file.

Tuesday, January 27, 2009

Simple Javascript email verification

Here is a simple email verification script in Javascript.  Just pass in the email address and it will return true or false depending on if the email is valid.  It will also do an alert popup if it is invalid.

function echeck(str) {

var at="@"
var dot="."
var lat=str.indexOf(at)
var lstr=str.length
var ldot=str.indexOf(dot)
if (str.indexOf(at)==-1){
  alert("Invalid email address of attendee.")
  return false
}

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
  alert("Invalid email address of attendee.")
  return false
}

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
   alert("Invalid email address of attendee.")
   return false
}

if (str.indexOf(at,(lat+1))!=-1){
   alert("Invalid email address of attendee.")
   return false
}

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
   alert("Invalid email address of attendee.")
   return false
}

if (str.indexOf(dot,(lat+2))==-1){
   alert("Invalid email address of attendee.")
   return false
}
if (str.indexOf(" ")!=-1){
   alert("Invalid email address of attendee.")
   return false
}

  return true
}

Monday, January 26, 2009

Autocomplete textfields

In my search for a cool autocomplete script for my text fields, I came across one that I'd actually recommend.  If you aren't familiar with autocomplete scripts, just start typing a url into the latest version of firefox and you'll see what I mean.


The script uses jQuery, which is a javascript library.  It is really simple to use, everything is included in the download.  It comes with a demo page and you can use to make it work the way you want it.

Wednesday, January 21, 2009

Flash Random Number generator

A little actionscript to get a random number (n) is this case.




low = 0;
high = 360;

function randRange(min:Number, max:Number):Number {
var randomNum:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNum;
}
for (var i = 0; i < 1; i++) {
var n:Number = randRange(low, high)
trace(n);
}

Wednesday, January 14, 2009

Why I hate Blogger!

This is just a rant but blogger is terrible.  It has the worst text editor ever created for a blogging software.  The list can go on but I think we're going to switch to something new as soon as we have some free time (if ever!).

Wow, I just need to vent because it is a pain to use blogger.  I don't recommend it!

IE6 Problem with Form Submit Image Buttons

A lot of times we use images as our submit buttons for forms. I'm sure you've seen it a lot. Well, say you wanted to test if the form was submitted and used the standard way, lets say in PHP, of seeing if the submit button was sent, for example like this:

if (isset($_REQUEST['mysubmitbutton']))
{ ...}

With IE6 this wouldn't work if your submit button was an image. So if you had this as your submit button:

<input name="mysubmitbutton" type="image" value="1" src="someimage.png" alt="" />

Then your script wouldn't work. The reason is that IE6 WILL NOT send over the variable mysubmitbutton.

The workaround is to know that IE6 will send over other information (along with all other browsers). It sends the x and y coordinates of where you clicked on the image. So you'll see mysubmitbutton_x and mysubmitbutton_y. So if you modify your code to look for either of these variables, you'll be good to go!

Credit is to be given to this discussion forum: Differences in form handling btw Mozilla and IE?

Thursday, January 8, 2009

Get referrer with PHP

Here is some code to find out the referrer to a page in PHP.  This can be very useful if you want to redirect back after login or something like that.  You can also set it up to make sure a visitor came to the page from within your site or something like that.

<?php
session_start();

if(!isset($_SESSION[’referrer’])){

//get the referrer
if ($_SERVER[’HTTP_REFERER’]){
$referrer = $_SERVER[’HTTP_REFERER’];
}else{
$referrer = “unknown”;

}
//save it in a session
$_SESSION[’referrer’] = $referrer; // store session data
}
?>


Hope this is useful.  The reference is: Get a referral URL from the session using PHP