inicio mail me! sindicaci;ón

Archive for Flash source

SWFAddress url sorting utility

UPDATE:

I don’t know how I missed this, but since v 2.1 SwfAddress has the getPathNames() method which does exactly what my bit of code does… ah well. Anyway I’ll leave it up as it has the basics of string splitting and other stuff…

Thanks to Cam for pointing this out… and while you’re at it check out his blog, he’s a much better coder than myself (but sucks at the guitar ;) )

Just thought I’d post this up as it might be helpful to someone…

Normally if you’re building a site using SwfAddress (and you should, not having any form of deeplinking in your flash site these days is utterly unforgivable) you could just on the swfAddress change do something like

switch(String(e.value).replace("/", "")){

case "news" :

openNews();

break;

case "shows" :

openShows();

break;

}

But what happens if you want to use subpages (/news/news-item), or subsubpages (/news/news-item/photo)… or however many… well, something like this will help you a lot.

var string:String = "/news/news-item";

function sortDeepLink(_deeplink:String):void{

var urlArray:Array = [];

if(_deeplink.charAt(_deeplink.length - 1) == “/”){

urlArray = _deeplink.substring(1, _deeplink.length - 1).split(”/”);

} else {

urlArray = _deeplink.substring(1, _deeplink.length).split(”/”);

}

switch(urlArray.length){

case 0 :

//Home address

trace(”Home”);

break;

case 1 :

//One tier address - ie. /news/

trace(”URL (one tier): ” + urlArray[0]);

break;

case 2 :

//Two tier array - ie. /news/news-item

trace(”URL (two tier): ” + urlArray[0],urlArray[1]);

break;

default :

//Invalid URL

trace(”URL invalid”);

break;

}

}

sortDeepLink(string);

//

You can extend the switch function to handle as many tiers as you need by just adding more cases - you can also add a 404 function in the default case if you want.

I’d love to know if anyone uses this, so post a comment if you do!

DropDown menu class - as3

Hey everyone!
I keep meaning to update this blog with various titbits and stuff, but I never seem to have the time - anyway, thought I’d post up this wee drop down (combo) menu class I decided to build yesterday - It’s not been from any specific project, I just decided that the flash community needs a better dropdown that the horrific one included as standard. Anyway, it’s pretty basic just now, but it’ll do the basics and it’s totally skinable which was my main aim.

EXAMPLE

Usage is pretty simple…

import com.liamr.ui.dropDown.DropDown;
import com.liamr.ui.dropDown.Events.DropDownEvent;

var array:Array = [{label: "Hello World", data:"English - (formal)"},
{label: "Bonjour", data:"French - (formal, for daytime use; 'n' as a nasal vowel)"},
{label: "hej", data:"Danish - (informal; pronounced hey)"},
{label: "dia duit", data:"Gaelic - (informal; pronounced gee-ah ditch; literally 'God be with you')"},
{label: "Hallo", data:"German"},
{label: "ciĆ o", data:"Italian - (pronounced chow; informal)"}];

var dd:DropDown = new DropDown(array, “Please choose…”, true, 100);

dd.addEventListener(DropDown.ITEM_SELECTED, newSelect);

dd.x = 10;

dd.y = 10;

addChild(dd);

function newSelect(e:DropDownEvent):void{

trace(e.selectedId, e.selectedLabel);

label_txt.text = e.selectedLabel;

content_txt.text = e.selectedData;

}

Just drag the DropDown class folder from the example fla, add the code above and you’re there…

enjoy!

SOURCE

Flash CMS - AS2 / XML / PHP

xmlAdmin_p

Been meaning to get this out for ages! But alas, I’ve been totally snowed under with work, and the fact that I’m all about the as3 now ;-) I’ve realised I’m never going to go through it and refine it and comment it for the community… so you’re getting it as it is. Anyway, it’s a xml editor (so no mysql) with a file manager so you can upload files, rename and preview them etc - It’s been used on quite a few clients sites of mine, although nothing too heavy mind you, leave that for the database powered stuff (although I have converted this to power mysql db’s pretty easily)… Anyway, hope it helps anyone :-D

Liam

Here’s a preview

http://www.liamr.com/labs/source/xmlAdmin/

the login’s “admin”

SCREENCAST

SOURCE

My First Class! - tweenTangle

Made my first class - quite excited about it really! Anyway, it started out as a need to get round the fact that flash can’t use scale9 movieclips as masks, which means we can’t get any nice rounded edge masked tweens, so I wrote this to get round it. In the end it turned out really nice, and I thought I’d share it with everybody; it’s going to kick ass for building interfaces - anyway if anyone uses it gimme a shout..

SOURCE

Edit: Link to the classes fixed - ta Iamthejuggler…

Flash Header for wordpress P2 - Flash

Right, knocked up something that would use the php script I uploaded the other day, It brings in the data and builds a menu either for pages (with home page) or posts. I’ve also knocked up something that takes the post / page data and puts it in a text field incase anyone decides to build on it and turn it into something awesome (I might later if I have time - use swfaddress and all that).

Oh, and Load Learn it’s in as2.. :)

SOURCE

Get more info on the php side of things at the previous post.

Flash Image Loader As2

Here’s just a really basic example of loading images into flash… simple.

codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0"
WIDTH="420" HEIGHT="420" id="myMovieName"> NAME="myMovieName" ALIGN="" TYPE="application/x-shockwave-flash"
PLUGINSPAGE="http://www.macromedia.com/go/getflashplayer">

Here’s the code:
//ImageLoader Function - Liamr.com/blog/?p=86

//Load in TweenLite

import gs.TweenLite;
import gs.TweenFilterLite;
import mx.transitions.easing.*

//Preview Button
preview_btn.onRelease = function(){

loadImage("http://www.liamr.com/labs/source/imageLoader/images/image_1.jpg");

}

preview_resize_btn.onRelease = function(){

loadImage("http://www.liamr.com/labs/source/imageLoader/images/image_2.jpg");

}

//Load function
function loadImage(source:String):Void{

var frameSize:Number = 10;
var frameColor:String = "0x000000";
var frameAlpha:Number = 95;

var mclLoader:MovieClipLoader = new MovieClipLoader ();
var mediaPoplistener:Object = new Object ();

mediaPop.holder._alpha = 0;

mclLoader.addListener (mediaPoplistener);
mclLoader.loadClip(source, mediaPop.holder);

TweenLite.to(mediaPop.bg, 0, {_y:0, _x:0, _alpha:50, _width:Number(Stage.width), _height:Number(Stage.height), ease:Strong.easeOut});
TweenLite.to(mediaPop.frame, 1, {_alpha:50, tint:frameColor, _height:20, _width:80, ease:Strong.easeOut});
TweenLite.to(mediaPop.loader, 0.1, {_alpha:50});
TweenLite.to(mediaPop, 1, {autoAlpha:100});
mediaPoplistener.onLoadProgress = function (target:MovieClip, loadedBytes:Number, totalBytes:Number):Void {
TweenLite.to(mediaPop.loader, 0.1, {_alpha:50});
percentageLoaded = Math.round(loadedBytes/totalBytes * 100);
mediaPop.loader.loadertext_txt.text = "Loading " + Math.floor(percentageLoaded) + "%";

}

mediaPoplistener.onLoadInit = function (target:MovieClip):Void {
mediaW = Math.round(mediaPop.holder._width);
mediaH = Math.round(mediaPop.holder._height);
frameW = mediaW + Number(frameSize*2);
frameH = mediaH + Number(frameSize*2);
TweenLite.to(mediaPop.loader, 1, {_alpha:0, ease:Strong.easeOut});
TweenLite.to(mediaPop.frame, 1, {_x:0, _y:0, _width:Number(frameW), _height:Number(frameH), tint:frameColor, ease:Strong.easeOut});
TweenLite.to(mediaPop.frame, 1, {_alpha:frameAlpha, delay:1, overwrite:false});
mediaPop.holder._x = frameSize;
mediaPop.holder._y = frameSize;
TweenLite.to(mediaPop.holder, 1, {_alpha:100, overwrite:false, delay:2, ease:Strong.easeOut});

}

}

And here is the zip (flash 8 ) …

SOURCE

Flash Security Snippet

Just found this little gem over at flashmatics.co.uk (awesome resource site), so I thought I’d post it up here. It basically checks to see whether the swf is being run from your specified domain - if not it redirects to your website. It’s perfect for stopping the use of unwanted distribution of your flash projects.
var domain:String = "http://www.yourdomain.com" //enter your domain name here

if(_root._url.indexOf(domain) == -1 ){
getURL(domain, "_self");
}

Flash String Replace - As2

Just a small function to replace text in a string, handy for things at times…

//String Replace Class

function stringReplace(block:String, find:String, replace:String):String
{
return block.split(find).join(replace);
}

myString = "I love actionscript";
output = stringReplace(myString, "love", "hate");
trace("NewString = " + output);

Flash Thumbnailer - with automatic thumbnail generation - As2/PHP

Here’s just a quick method of automatically generating thumbnails on the fly - no more fiddling about with photoshop to create thumbnails… :P.

EXAMPLE

SOURCE

Flash E-Card - as2 with download, video, shows and send to a friend…

Hopefully someone will find this useful, it’s the full flash source to an e-card I build for the band Driveby Argument, who are by the way utterly excellent, and I implore you to check them out. (I also did their wee flash website).
If anyone finds it useful even just a little bit then that’s awesome, and I’m glad to have helped. Although please don’t just create a carbon clone, for a start - where’s all the fun in that! If you do end up using it, send me a link or at least post a comment!

Sex Lines ECard

EXAMPLE

SOURCE

Next entries »