| Subject: | Button object as parameter of funstion |
|---|---|
| From: | "4oFF" <webforumsuser@xxxxxxxxxxxxxx> |
| Date: | Sat, 10 Nov 2007 09:20:11 +0000 (UTC) |
| Newsgroups: | macromedia.drk |
Hi there! So i'll describe my code below (i can send source with some XML to
yours e-mail):
function strReplace(strString:String,strFind:String,strReplace:String):String
{
var i:Number;
var strRez:String="";
i=0;
while(i!=strString.length)
{
if
(strString.substr(i,strFind.length)==strFind){strRez+=strReplace;i+=strReplace.l
ength-1;}else{strRez+=strString.substr(i,strFind.length);}
i+=strFind.length;
}
return strRez;
}
function load_country_info(country:String,city:String,Btn:Button)
{
var oxml = new XML();
//
ioTxt.text="";
oxml.ignoreWhite = true;
oxml.onLoad = function(success:Boolean)
{
if (success)
{
var tx:String="";
var item=Object();
var i:Number=0;
var imgContainer:MovieClip =
_root.createEmptyMovieClip("imgContainer",_root.getNextHighestDepth());
var mclImg:MovieClipLoader = new MovieClipLoader();
/*error is below*/
imgContainer._x=Btn._x;
imgContainer._y=Btn._y;
/*
so i am not available to set imgContainer._x=Btn._x;
i was trying to trace the variables - they have actual
coordinate's values
even after assignation (imgContainer._x=Btn._x;)
But if i'llmake it like this imgContainer._x=100;
everything is working
good. So hiw can i make it with Btn:Button as link ty any of buttons for
example Atyrau_button:Button
*/
while(i!=this.firstChild.childNodes.length)
{
item=this.firstChild.childNodes[i];
if
(item.nodeName.toUpperCase()==country.toUpperCase())
{
strRepl.replace(",","\n");
tx+="Population:
"+item.attributes["population"]+"\n";
tx+="Capital:
"+item.attributes["capital"]+"\n";
tx+="Money:
"+item.attributes["money"]+"\n";
//tx+="USD Exchange rate:
"+item.attributes["usdexchrate"]+"\n";
tx+="Timezones:
\n\t"+strReplace(item.attributes["timezones"],",","\n\t");
strReplRez=null;
strRepl=null;
if(city!="")
{
var
strImgDir:String=item.firstChild.attributes["dir"];
var
strImgName:String="";
var j:Number=0;
while(j!=item.firstChild.childNodes.length)
{
if
(item.firstChild.childNodes[j].attributes["name"].toUpperCase()==city.toUpperCas
e())
{
strImgName=item.firstChild.childNodes[j].attributes["img"];
j=item.firstChild.childNodes.length-1;
}
j++;
}
if (strImgName!="")
{
mclImg.loadClip(strImgDir+"/"+strImgName, imgContainer);
}
else
{
imgContainer.unloadMovie();
}
}
else
{
imgContainer.unloadMovie();
}
i=this.firstChild.childNodes.length-1;
}
i++;
}
ioTxt.text+=tx;
item=null;
i=null;
j=null;
//imgContainer=null;
//mclImg=null;
//Btn=null;
}
else
{
ioTxt.text="XML FILE NOT LOADED - ERROR.\nPlease
contact with
WEB-ADMINISTRATORS\n";
}
}
oxml.load('./countries_caspian_info.xml');
oxml=null;
}
/* COUNTRIES */
CASPIAN_MAP.onRollOver = function () {
load_country_info("","",null);
}
KZ_button.onRollOver = function () {
load_country_info("KZ","",null);
}
TU_button.onRollOver = function () {
load_country_info("TU","",null);
}
AZ_button.onRollOver = function () {
load_country_info("AZ","",null)
}
/* CITIES */
Atyrau_button.onRollOver= function() {
load_country_info("KZ","Atyrau",this);
}
Baku_button.onRollOver= function() {
load_country_info("AZ","Baku",this);
}
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| ||