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;
}
}

important variables to be added to page.tpl.php

importent variables to be added to page.tpl.php

$base_path: The base path of the Drupal installation. At the very least, this will always
default to / if Drupal is installed in a root directory.

$breadcrumb: Returns the HTML for displaying the navigational breadcrumbs on the
page.

$closure: Returns the output of hook_footer() and thus is usually displayed at the bottom
of the page, just before the close of the body tag. hook_footer() is used to allow
modules to insert HTML or JavaScript at the end of a page. Note that drupal_add_js()
will not work in hook_footer().

$content: Returns the HTML content to be displayed. Examples include a node, an
aggregation of nodes, the content of the administrative interface, and so on.

$css: Returns an array structure of all the CSS files to be added to the page. Use $styles
if you are looking for the HTML version of the $css array.

$directory: The relative path to the directory the theme is located in; for example,
themes/bluemarine or sites/all/themes/custom/greyscale. You’ll commonly use this
variable in conjunction with the $base_path variable to build the absolute path to your
site’s theme:
<?php print $base_path . $directory ?>
will resolve to
<?php print ‘/’ . ’sites/all/themes/custom/greyscale’ ?>

$feed_icons: Returns RSS feed links for the page. RSS feed links are added via
drupal_add_feed().

$footer: Returns the HTML for the footer region, including the HTML for blocks
belonging to this region. Do not confuse this with hook_footer(), which is a Drupal
hook that lets modules add HTML or JavaScript that will appear in the $closure variable
just before the closing body tag

$footer_message: Returns the text of the footer message that was entered at Administer
ä Site configuration ä Site information.

$front_page: The output of url() with no parameters; for example, /drupal/.
Use $front_page instead of $base_path when linking to the front page of a site, because
$front_page will include the language domain and prefix when applicable

$head: Returns the HTML to be placed within the <head></head> section. Modules
append to $head by calling drupal_set_html_head() to add additional markup.

$head_title: The text to be displayed in the page title, between the HTML
<title></title> tags. It is retrieved using drupal_get_title().

$header: Returns the HTML for the header region, including the HTML for blocks
belonging to this region.

$is_front: TRUE if the front page is currently being displayed

$left: Returns the HTML for the left sidebar, including the HTML for blocks belonging
to this region.

$logged_in: TRUE if the current user is logged in; FALSE otherwise.

$logo: The path to the logo image, as defined in the theme configuration page of
enabled themes. It’s used as follows in Drupal’s default page template:
<img src=”<?php print $logo; ?>” alt=”<?php print t(‘Home’); ?>” />

$messages: This variable returns the HTML for validation errors, success notices for
forms, and other messages as well. It’s usually displayed at the top of the page.

$mission: Returns the text of the site mission that was entered at Administer ä Site configuration
ä Site information. This variable is only populated when $is_front is TRUE.

$primary_links: An array containing the primary links as they have been defined at
Administer ä Site building äMenus. Usually $primary_links is styled through the
theme(‘links’) function as follows:
<?php
print theme(‘links’, $primary_links, array(‘class’ => å
‘links primary-links’))
?>

$secondary_links: An array containing the secondary links as they have been defined at
Administer ä Site building äMenus. Usually $secondary_links is styled through the
theme(‘links’) function as follows: and are placed beneath primary links as they are the sub links for them
<?php
print theme(‘links’, $secondary_links, array(‘class’ => å
‘links primary-links’))
?>

$site_name: The name of the site, which is set at Administer ä Site configuration ä Site
information. $site_name is empty when the administrator has disabled the display on
the theme configuration page of enabled themes.

$site_slogan: The slogan of the site, which is set at Administer ä Site configuration ä
Site information. $site_slogan is empty when the administrator has disabled the display
of the slogan on the theme configuration page of enabled themes.

$styles: Returns the HTML for linking to the necessary CSS files to the page. CSS files
are added to the $styles variable through drupal_add_css().

$tabs: Returns the HTML for displaying tabs such as the View/Edit tabs for nodes. Tabs
are usually at the top of the page in Drupal’s core themes

$title: The main content title, different from $head_title. When on a single node view
page $title is the title of the node. When viewing Drupal’s administration pages,
$title is usually set by the menu item that corresponds to the page being viewed

access config variables

to access config variables we put it like this
add the variable to configruation.php
$my_variable
then
$GLOBALS['mosConfig_my_variable']

Return top

INFORMATION

Change this sentence and title from admin Theme option page.