Archive for June, 2010

Connecting Joomla to external db

$db is now an object of type JDatabase and you can perform database operations on it using the usual methods.

$option = array(); //prevent problems

$option['driver']   = 'mysql';            // Database driver name
$option['host']     = 'db.myhost.com';    // Database host name
$option['user']     = 'fredbloggs';       // User for database authentication
$option['password'] = 's9(39s£h[%dkFd';   // Password for database authentication
$option['database'] = 'bigdatabase';      // Database name
$option['prefix']   = 'abc_';             // Database prefix (may be empty)

$db = & JDatabase::getInstance( $option );

Loading external image with preloading and getting width and height

I’ve tried loadComplete but oddly it didnt work..then I tried on EnterFrame and oddly it worked O.o

Here is the code

//Loading Images
function LoadImage(image, targetMC) {
targetMC.loadMovie(image);
this.onEnterFrame = function() {
var Percent = Math.ceil(targetMC.getBytesLoaded()/targetMC.getBytesTotal()*100);
if (Percent == 100) {
trace(“Width: “+targetMC._width);
trace(“Height: “+targetMC._height);
delete this.onEnterFrame;
}
};

}

just then we call the function that way

LoadImage and it should work fine ^_^

Clearing XML Caching in Flash

the simplest way is to load it that way

xml.load("xmlFile.xml?"+Math.random());

since it will think that the file is new file each time…kinda not bad

Tutorial of Text Feilds inside movie clips

Here is a small tutorial of all you need for text feild inside a movie clip.

First we should create our movie clip

createEmptyMovieClip(“fudge”,i);

Now Lets create our text feild inside of the movieClip fudge

with (“fudge”) {

createTextField(“my_title”,getNextHighestDepth(),0,0,350,20);

}

Nice now we have a text feild that is called my_title and that is inside fudge we can even control several things of that text feild, like height, html, border, multiline and so on here if we continue with the with scope again

with (“fudge”) {

createTextField(“my_title”,getNextHighestDepth(),0,0,350,20);
my_title.autoSize = “left”;
my_title.wordWrap = true;
my_title.multiline = true;
my_title.border = false;
my_title.html = false;
my_title.text =” This should be a long text to test the auto height of the text feild we are creating and check if its working well”;

}

Since we put autoSize to left and multiline and autowrap to true then the textFeild will grow by height.

Now Finally, We also can add text Format to color our text and choose the font  size here is what we do

var title_format:TextFormat = new TextFormat();
title_format.color = 0xEBCF4E;
title_format.font = “Tahoma”;
title_format.size = 11;
title_format.bold = true;

But also we shouldnt forget to style the thing we’ve started so here

my_title.setTextFormat(title_format);

Now this shouldnt go with the text thing at all but I always prefer to adjust the height of the movieClip to the height of Text incase I want to use the movieClip height later so here how to do it

with (“fudge”) {

_height = my_title._height;

}

So now if I want to add any movie beneath Fudge all what I have to do is

myNewMovie._y= fudge._height+fudge._y;

Thats all folks. hope this was helpful enough for you ^^”

Reading XML from Flash

Here is the way
supposing we have XML that have this structure

<?xml version=”1.0″ encoding=”UTF-8″?>
<products>
<item Title= ” Home ” Desciption=”" />
</products>

///set up this default, not worth explaining
XML.prototype.ignoreWhite = true;
///Create a new empty XML Object
var myXML:XML = new XML();

///load in the xml file
myXML.load(“products.xml”);
//if the XML file has successfully loaded in, then this function is run through
myXML.onLoad = function(success) {
if (success) {
i=0;
//new array for the total number of childNodes
menuArray = new Array();
menuArray = this.firstChild.childNodes;
while (i<menuArray.length) {
trace(this.firstChild.childNodes[i].attributes.Title);
i++;
}
}
};

loadMovie with Fade effect

The best way to do that in actionscript 2 is to import the transition library and then check if the movie loaded and create the alpha effect

import mx.transitions.Tween;
import mx.transitions.easing.*;
loadMovie(“home.swf”, movie_loader);

this.onEnterFrame = function() {
if (movie_loader.getBytesLoaded()>=movie_loader.getBytesTotal() && movie_loader.getBytesLoaded()>1) {
Tween1 = new Tween(movie_loader, “_alpha”, Strong.easeIn, 0, 100, 1, true);
delete this.onEnterFrame;

}
};
Stop();

Protected: Important Effects for flash

This post is password protected. To view it please enter your password below:


Get Alias Path In Drupal

I’ve added this to the module (also to template.php)  and its working well

function get_url_alias( $src ){
if ( $query = db_query( "SELECT * FROM {url_alias}
WHERE src='%s'", $src ) ){
if ( $rs = db_fetch_object( $query ) ){
return $rs->dst;
}
else {
return $src;
}
}
else {
return $src;
}
}

Return top

INFORMATION

Change this sentence and title from admin Theme option page.