Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Trouble Adding Commas To String



I'm using code I found on this site to add commas to a large number (so that a number like 1000000 appears as 1,000,000). Below is the actionscript I'm using. When I define the variable debt as any number, the script works perfectly. But if I define debt as a variable passed to the movie from a PHP file, then the script puts the commas in the wrong places (i.e., 10,000,00). Can anyone explain to me why this would happen, and how to fix it? var input = debt;var inputString = input.toString();var finalString = "$";var count = 0;var tempString = "";for (var i = inputString.length-1; i>=0; i--) {count++;tempString += inputString.charAt(i);if ((count%3 == 0) && (i - 1 >= 0)) {tempString += ",";}}for (var k = tempString.length; k>=0; k--) {finalString += tempString.charAt(k);}return(finalString);



KirupaForum > Flash > ActionScript 1.0/2.0
Posted on: 04-18-2006, 06:52 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Adding Commas To Turn String Into Dollars
Hi all,

I have a dynamic textfield that is bringing in a number from a txt file.

the number is displaying like this:

1853600

I want it to look like this:

$1,853,600

I can have it display as dollars in another field if that's how this gets done.

oh...How would I adjust it to deal with a number in the tens of millions?

Thanks

-Lemorris

Remove Commas From String
Is there a "find and relace" function that I can use in actionscript to remove the commas from a string that the user enters into a text field?

I need to remove all commas from a text string.

Thanks

Adding Commas To Numbers
Anyone know of a Good Function to Add Commas to Numbers ?

Searching A Text String Seperated By Commas
I'm trying to find if a text field with text seperated by commas contains certain text.

if (myText.text == "three") {
trace("true"); //if myTxt.text is "three"
} else {
trace("false"); //if myTxt.text is "one, two, three"
}

Is there a way to find in the above example, if "three" is contained within the text field?

Thanks in advance.

Adding Commas To A Dollar Amount
anyone know of some existing code that parses a dollar amount and adds commas to it? ie 12000 equals 12,000

Thanks!

AP

Adding Commas To Dynamic Numbers
I have this calculator that takes a number from one text box, multiplies it by the value of a 2nd box and outputs into another text box the total value.

When the total value appears, I used the Math.round function to round the final number to the nearest whole number.

My question now is... how do I add commas if the total is greater than 999. Example : 1,000 100,000 1,000,000


The code is pasted below. Any help would be greatly appreciated.

Tom

AverageTotal = (Math.random(Breech))*(Math.random(Average));

Adding Commas To Dynamic Numbers
I have this calculator that takes a number from one text box, multiplies it by the value of a 2nd box and outputs into another text box the total value.

When the total value appears, I used the Math.round function to round the final number to the nearest whole number.

My question now is... how do I add commas if the total is greater than 999. Example : 1,000 100,000 1,000,000


The code is pasted below. Any help would be greatly appreciated.

Tom

AverageTotal = (Math.random(Breech))*(Math.random(Average));

Adding Commas To Numerical Data In Textfield
I have laboriously searched the forum archives here, and on actionscript.org, and have not come up with a clear answer.

Here is my dillema. I have one input text box that the user can enter numbers and a decimal point into. I have another unselectable input text box that those numbers appear in when a button is pressed. Well, when they appear, I simply want them to appear with commas (i.e. 1,270,655).

If there is a thread already explaining this CORRECTLY, please simply, post the link here. However, if you know what I need, please reply away. Thanks for the time.

Trouble With String.indexOf And String.lastIndexOf
Hi,

I have an input text field used for time. I'm trying to set it up so the user has to enter a valid time into the box.

I set the box to be only 5 characters in length and to only use numbers and the ":" character.

I thought this code would insure there wouldn't be two ":" characters and the ":" would be at lease one character from the begining and at least two from the end.

But the if you enter 2:321 it comes back as a valid time.

Thanks in advance,
thurston


Code:
if(string.indexOf(":", 1) == string.lastIndexOf(":", string.length-3) ){
trace("Valid Time");
}else{
trace("Invalid Time!!!");
}

Trouble Finding A String Is A String
I'm trying to find a certain string I provide in another string, I know that in JavaScript you can use indexOf to find it:

myString = "hello world";
findString = "world";
if(myString.indexOf(findString) >= 0) {
alert("found");
}

I tried that in flash (replacing alert with trace) and it doesn't work

can anyone help???

Adding More String
I am creating a program that has a Output Box . A Input Box, and a Send Button. I created a Script that allows the user to put some string into the Input Box, and once they press send, it will display on the output box. I want to have it where once they press send. They can type in some different text and instead of the different text replacing the previous text displayed in the box, it only adds on . For example

send.OnPress = function() {
outputbox.text = inputbox.text;
}

Say I typed in Hello into the inputbox.text. Then the string "Hello" will display in the output box. Now say I typed World the second time. Then the word "World" will replace "hello". I want it to instead say "Hello World" once I type in the word world the second time.






























Edited: 03/14/2007 at 12:51:48 PM by numerical07

String Trouble
I need a good way to isolate the last 4 letters of a string (file extension) any ideas? nothing I try seems to work...

String Trouble
Hi everyone,

I use this code to create a short text of 90 characters and than add three dots.

text = _root.shorttext1;
short = new String(text);
subshort = short.substr(0, 90)+" ...";

Problem is that i don't want to cut off the text in the middle of a word. How can I make sure flash never leaves half a word, but instead makes the string shorter so that it ends on a space character.

So instead of "word word word word word word word wo..."
I want "word word word word word word word ..."

thanks in advance

S

Adding Numbers To A String
How do I add a number to a string . Here is what I have
Code:
on (rollOver) {
isOver+="b"+1;

I want it to show in a variable as b1 and when you roll over it again it will show b2 . As is now it just keeps adding it like b1b21b12 or something like that .

Adding Javascript To A String?
on (release) {
var strURL = "http://207.21.247.39/html/seriespop.asp?seriesid="+id;
getURL (strURL, "_blank");
trace ("URL "+strURL);
}

I have this script to pull up a URL - how to I a [javascript: openWindow] command to this string???

I would be grateful for any suggestions!

Cheers

Adding "'s To An XML String
I have in my AS an HTML string sent from javascript.

The string in Firefox works great, but in IE the class names and other parameters loose thor "'s ... example class="test" is now class=test

so what is the easiest way to put the quotes BACK in attributes of this XHTML XML string?

Adding Spaces To A String
Hi, I have a simple question... hope you can help me...
I have a string like this: "a b". As you can see, it has a lot of space between the two letters. Now, when I assign that string to a TextField, it crops all the spaces in the middle leaving just 1 simple space like so: "a b".
What I need, is a way to put lots of spaces between two characters in a TextField. In other words, I need the TextField to show the real content of the string... does anyone knows how to do that?

Thanks

EDIT: Ok, even the forum trimmed my question... the real string has a lot of blank spaces between the letters "a" and "b", that's what I want the TextField to show...

Adding Info To A String
Okay,
I have a string of info I am importing into Flash and need to know how to add additional info to a specific string from the XML with AS3. Does anyone know how to use RegExp? I can't seem to get it to work. I need to add a file extension, height and width to an image that lacks this info. Thanks for any help or suggestions.

David

Code from main timeline with failed RegExp code (no errors, just does not work):


ActionScript Code:
import com.me.xml.*;
import com.me.php.*;
import fl.controls.*;
import fl.data.*;



var info_txt:TextArea = panel_mc.main_mc.info_txt;
var episode_cb:ComboBox = panel_mc.main_mc.episode_cb;
var date_txt:TextField = panel_mc.main_mc.date_txt;
var view_btn:Button = panel_mc.main_mc.view_btn;
var grabber:Grabber = new Grabber();
var reader:RSSReader = new RSSReader();


function dataGrabbed(event:Event):void
{
    info_txt.text = "processing xml data";
    reader.addEventListener(Event.COMPLETE, rssProcessed);
    reader.processXML(new XML(grabber.data));   
    }
   
   
function RegExpExample():void {
    var formalGreeting:String = 'img src="http://image.shopzilla.com/resize?sq=100&uid=\d{9}"';
}

function informalizeGreeting(str:String):String {
    var pattern:RegExp = new RegExp('img src="http://image.shopzilla.com/resize?sq=100&uid=\d{9}"', "gim");
    return str.replace(pattern, 'img src="http://image.shopzilla.com/resize?sq=100&uid=/d{9}/.jpg" width="100" height="50"');
}

function rssProcessed(event:Event):void
{
    var episodeDP:DataProvider = new DataProvider();
    for each(var item:XML in reader.episodes)
    {
        episodeDP.addItem({label:item.title});
    }
    episode_cb.dataProvider = episodeDP;
    episode_cb.addEventListener(Event.CHANGE, changeSelection);
    episode_cb.selectedIndex = 0;
    updateText();
    view_btn.addEventListener(MouseEvent.CLICK, viewOnline);
}

function viewOnline(event:MouseEvent):void
{
    navigateToURL(new URLRequest(reader.episodes[episode_cb.selectedIndex].link));
}

function changeSelection(event:Event):void
{
    updateText();
}

function updateText():void
{
    var date:String = reader.episodes[episode_cb.selectedIndex].pubDate;
    date = date.substr(0, date.length-14);
   
   
    info_txt.htmlText = reader.episodes[episode_cb.selectedIndex].description;
    date_txt.text = date;   

}

grabber.load("grabber.php", "http://www.shopzilla.com/14G_-_feed_id--4/rss.xml");
grabber.addEventListener(Event.COMPLETE, dataGrabbed);

Concatenated String Trouble
I'm having trouble getting the value of a variable called from concatenated string. Here's the code:

n = random(Number(5));
// I pick a random number.

_level0.dis = ("_level0.clip"+n);
// I then concatenate a a string with the random number on the end of the string

_level0.thetext = _level0.dis;
// I then set a variable to the value of the newly concatenated variable. This is where the problems arises. _level0.dis seems to equal to the concatinated variable as a string as opposed to grabing the value fo that string.

ie.
_level0.text holds a value of _level0.clip3, as opposed to the value of _level0.clip3 which is "Hello I'm Clip 3". If I call _level0.clip3 directly then I get the proper value.

I hope this makes a little bit of sense... Any help would be greatly appreciated.

Array As String Trouble
I had the following array of movie clips:

Code:
var photoFill:Array = [card0_mc.photoFill_mc, card1_mc.photoFill_mc, card2_mc.photoFill_mc, card3_mc.photoFill_mc]
with trace(photoFill); I get:
[object MovieClip],[object MovieClip],[object MovieClip],[object MovieClip]


what I want to do is build the Array through a loop based on the length of another Array like this:

Code:
var photoFill:Array = new Array
for(var n:int = 0; n < cardDensity.length; n++){
photoFill.push("card"+n+"_mc.photoFill_mc");
}
but now with trace(photoFill); I get:
card0_mc.photoFill_mc,card1_mc.photoFill_mc,card2_ mc.photoFill_mc,card3_mc.photoFill_mc

It's turned it into a string which is giving me an error when I try to reference photoFill[i].height in another loop. The Error is:
ReferenceError: Error #1056: Cannot create property height on String.

How can I turn the string back into objects?
Thanks

String Validation Trouble
Hello,

I am trying to limit a string to only alphanumeric characters. The trouble is that it will allow illegal characters as long as legal characters are also in the string.

"THIRTY" is allowed;
"30" is allowed;
"+" is not allowed;
"30+" is allowed but should not be allowed;

Here is the state of my function:

CODEvar checkChars:Function = function(input){
        var i:Number = 0;
        while(i<txtinput.length && (" abcdefghijklmnopqrstuvwxyz0123456789").indexOf(input.charAt(i)) != -1){
            goodString = true;
            i++;
        }
        if(goodString==true){
            return 1;
        }else{
            return -1;
            errFlag = true;
        }
    }

Adding To A String Based On A Count
I have a text fields with var names line1, line2....etc

When buttons are pressed I want to add to the existing string (in the case below 'tr') of one of the text boxs dependant my lineNum variable.

i = "line"+lineCount;
i+="tr ";

I cannot get this to work when I use the lineCount to target the text box, if I just put in line1 += "tr" it works fine.

Hope someone can help
Cheers
Oll

Adding String Items In Arrays?
This is probably simple enough, just can't figure it out:

I have 4 buttons. When they are chosen they replace
newMix = [0,0,0,0]
to
newMix = ["a","b", "c","d"]

(of course some buttons may not be chosen)

what I want to happen is to ad the elements of newMix

so if someone picked a b and d, newMix = ["a","b",0,"d"] would return a value of "abd"

esentially, I'm searching for how to get rid of the commas in the array listing.

Anyone have any ideas?

Adding A Property To A Variable String
Hi there, trying to write a little code, I have it working up to the trace but I cant work out how to get the second function to work.

I want to access the following button:
'_root.mapBig.map.shanghaiButton' with a '.onRollOver' trigger, however I cant figure out how to make the sCityPath work with the .onRollOver.

function cityLoader(sCurrentCity:String):Void {
var sCurrentCityButtonName:String = sCurrentCity+"Button";
var sCityPath:String = "_root.mapBig.map."+sCurrentCityButtonName;
trace (sCityPath);
sCityPath.onRollOver = function() {
....
};
};

cityLoader("Shanghai");

Any ideas would be great.

AS2:: Adding String Values To An Array
I'm not too sure how to go about this or if it is possible. But is it possible to add the values from a string to an array?

For example my string looks like this:

var bookmarks:String = "book1, book2, book3";

And I need to add these values to the end of an array?

Thanks for any advice or help.

Trouble Passing String Var Into Function
im making a function that limmits text to a specified number...
only problem is i cant seem to pass in the text var that contains the text
any help would be awesome.
thanks in advance


ActionScript Code:
var textF1:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam neque purus, aliquam sed, sagittis tincidunt, adipiscing ac, urna. Ut libero urna, nonummy sodalesxxx";function TrimText(limmit:Number, area, textVar) {    var lengthF1:Number = [textVar].length;    trace(lengthF1);    var charLimmit:Number = limmit;    for (var i:Number = 0; i<=charLimmit; i++) {        trace(i);        if (i == 0) {            textcut = [textVar].charAt(i);        } else {            textcut += [textVar].charAt(i);            trace(textcut);            if (i == charLimmit && lengthF1>=charLimmit) {                textcut += "...";                _root[area].text = textcut;                trace(area);            } else {                _root[area].text = textcut;            }        }    }}TrimText(160,"texttest",textF1);

Dynamically Adding Custom Classes Via String
I have a bunch of MC's in my library, each with custom classes, base class MovieClip.

Normally, I would add them like this:
var myMovieA:MovieClip = new CustomMCa();
var myMovieB:MovieClip = new CustomMCb();
var myMovieC:MovieClip = new CustomMCc();

...but what if the "CustomMC" needs to dynamic? i.e. perhaps based on a string variable? Other than a long switch/case or if/then checking against the string, is there any way to achieve that?

Problems Adding Methods To String Class
I'm trying to add some new methods to the built in String class. I've tried two new methods so far. One of them (entitiesConvert, which is by far the most complex) seems to work OK (at least, it doesn't give any compiler errors). The other (pad, which is just a few lines of code) doesn't. Whenever I use the new pad() method, either inside the entitiesConvert method, or elsewhere in my code, I get a "no such method" error.

My code is below. Can anyone see what's wrong with the pad() method?

Thanks - Rowan

// String pad method.
// If len is negative, pads on the left, if positive, to the right.
// Pads to length abs(len) with the first character of str.
// str defaults to " ".
String.prototype.pad = function(len:Number, str:String):String
{
var abslen:Number = Math.abs(len);
var s = abslen-this.length;
if (s <= 0) return this;
if (!str.length)
{
str = " ";
}
else
{
str = str.substring(0,1);
}
var p = "";
while (s > 0)
{
p += str;
s--;
}
if (len >= 0)
{
return (this + p);
}
else
{
return (p + this);
}
}


// Convert HTML entities into their corresponding Unicode characters
String.prototype.entitiesConvert = function():String
{
var str:String = this;

// create the entity mapping array
// which allows decoding html entities into their unicode equivalents
var aryEntities:Object = new Object();

aryEntities["&nbsp;"] = "u00A0"; // non-breaking space
aryEntities["&iexcl;"] = "u00A1"; // inverted exclamation mark
aryEntities["&cent;"] = "u00A2"; // cent sign
aryEntities["&pound;"] = "u00A3"; // pound sign
// Lots more entities go here...

for(var entity:String in aryEntities)
{
str = str.split(entity).join(aryEntities[entity]);
}

var strptr:Number = 0;
var begnum:Number;
var endnum:Number;
var numstr:String;
var numtyp:String;
var num:Number;
while ((begnum = str.indexOf("&#", strptr)) > -1)
{
if ((endnum = str.indexOf(";", begnum + 2)) > -1)
{
numstr = str.substring(begnum + 2, endnum);
numtyp = numstr.substring(0, 1);
if (numtyp == "x" || numtyp == "X")// Hex number.
{
if ((num = parseInt(numstr.substring(1), 16)) == NaN)// Not a valid hex number.
{
strptr = endnum + 1;
continue;
}
}
else// Decimal number.
{
if ((num = parseInt(numstr)) == NaN)// Not a valid decimal number.
{
strptr = endnum + 1;
continue;
}
}
// The first version of this line causes a "no such method" error
// str = str.substring(0, begnum) + "u" + num.toString(16).toUpperCase().pad(-4,"0") + str.substring(endnum + 1);
// The second version of this line compiles without error.
str = str.substring(0, begnum) + "u" + num.toString(16).toUpperCase() + str.substring(endnum + 1);
}
else
{
strptr = begnum + 2;
}
}
return str;
}

Adding String Data To An Expression For Evaluation
Hi, I have the following function:


Code:
getInfo = function (input, arrayData, desiredResult)
{
for (i = 0; i < arrayData.length; i++)
{
if (arrayData[i].button == input)
{
return arrayData[i].desiredResult;
}
}
};
arrayData is a multidimensional array containing objects.

What I need returned is arrayData[i].desiredResult, where desiredResult is a string passed to the function. For example:

test("dogs", theArray, "color") needs to return the evaluated value of arrayData[i].color. How can I achieve this? Thanks!

Trouble With Adding A New Scene
Hi,

I have a main scene that begins with a animation. Now when i add a new scene to house a preloader and place it above the main scene and play the movie the preloader works fine but when it plays the next scene everything stops at frame 1. At 1st I thought it was my preloader but i tripled checked it and it was fine, I also just added a blank scene but i get the same problem. Im using flash 8. ne 1 ever get this problem?

thx

Having Trouble Adding A SWF File To Vb.net
Ok so I found this on a help site somewhere but I can't seem to locate the Shockwave control in VB.net. I am currently using the trial version of Flash 8 and vb.net from 2002. Are my versions incompatible?

VB.Net
Right click on the tool box. Select “Add/Remove Items…”. Select “COM Components”
Select “Shockwave Flash Object”. Click OK
Draw it on the form
Name it “SF1”

Adding Load Bar Trouble
hey guys, i think i posted this once before but i still havnt gotten a solution.
basically what i want to achieve is a site like the "Preloader and Transition for Dynamic Files" tutorial but where it says "loading" i want to replace with a loading bar. now i thought this would be pretty simple and straight forward but as hard as i try to make it work, it wont

this is my best guess so far in the 'content' actionscript

onClipEvent (enterFrame) {
if (!loaded && this._url != _root._url) {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.transition.loadBar._width = getPercent*100;
_root.transition.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
loaded = true;
_root.transition.gotoAndPlay("opening");
}
}
}

i thought that should work but it doesnt? can anyone help me out? ill really appreciate some help.

cheers, evan

Adding Load Bar Trouble
hey guys, i think i posted this once before but i still havnt gotten a solution.
basically what i want to achieve is a site like the "Preloader and Transition for Dynamic Files" tutorial but where it says "loading" i want to replace with a loading bar. now i thought this would be pretty simple and straight forward but as hard as i try to make it work, it wont

this is my best guess so far in the 'content' actionscript

onClipEvent (enterFrame) {
if (!loaded && this._url != _root._url) {
bytes_loaded = Math.round(this.getBytesLoaded());
bytes_total = Math.round(this.getBytesTotal());
getPercent = bytes_loaded/bytes_total;
_root.transition.loadBar._width = getPercent*100;
_root.transition.loadText = Math.round(getPercent*100)+"%";
if (bytes_loaded == bytes_total) {
loaded = true;
_root.transition.gotoAndPlay("opening");
}
}
}

i thought that should work but it doesnt? can anyone help me out? ill really appreciate some help.

cheers, evan

Trouble Adding .mp3 To Project
Hello, I have just started to play around with Flash this week and I am having trouble importing an .mp3 file to my project.  It gives me the error, "One or more files were not imported because there were problems reading them".  However, this is only for certain .mp3 files.  I can import some .mp3's, just not all of them.  They all exist in the same folder and I made sure that the file name were legit.  I am completey lost, so if anybody could help, I would appreciate it!

Regards,
Corey

AS2 Trouble Reading String As MvClip Via AttachMv
PLEASE HELP

I am making a slide show with like 50 slides. I am having trouble applying a mask via setMask() to a MvClip that is attached from the library.

Grabbing Correct Array And Placing Adding To String
Hey yall I am trying to grab a movie clip instance which is amongst an array and attach it to a string.

I am trying this:

Code:
stateArray = new Array(AL,AK,AZ, ect....);//names of mc instances
for (var i = 0; i<stateArray.length; i++) {
stateArray[i].onRelease = function() {
getURL("/pagoso/browsestate.aspx?cat="+cat+"&state="+stateArray[i], "_self");
};//each mc onRelease will grab "cat" from string and add its respective state Array to String
}
Results in state being undefined state;

Have tried this:

Code:
stateArray[i].onRelease = function() {
getURL("/pagoso/browsestate.aspx?cat="+cat+"&state="+stateArray[0], "_self");
};
}
Resulting in:
/pagoso/browsestate.aspx?cat=8&state=_level0.AL

and if I do just stateArray it adds all the states with _level0.AL, _level0.AK ect....

How come I cant get it to just grab MC instance?

Still Having Trouble Adding Link To Swf File
Hey There,

I'm still having difficulty adding a hyperlink to an swf file... i tried adding the 'get url' action into the graphic itself, even changed it into a movie behavior- but for some reason when i go to 'basic actions', and scroll down to the 'on mouse event' or 'on clip event', they aren't highlighted- so i can't choose them.

so- essentially. i want the animation to loop, but i only want the url link to open if someone clicks on the animation. the animations i want to become hyperlinks are at the bottom of this page: http://www.lynnguppy.com/johnnyfish.htm

? any more help ? i know i'm probably missing something simple. but i guess that's why i'm a newbie.

thanks for your kind indulgence, lynn

Having Trouble With Dynamic Text Adding, Etc
Hello, Ive gotten lots of help here for my dynamic text and this is the last thing to complete my site.

What I have is a main scene with 2 movie clips
one movie clip you make a selection
the other movie clip shows the total cost, adding or subtracting the amount of your choice.

Its confusing so ill show you what code I have
On first frame of the main scene

Code:
_root.baseprice=700;
_root.surfaceprice=0;
_root.cupprice=0;
_root.legprice=0;
_root.addonprice=0;
_root.total_price=_root.baseprice + _root.surfaceprice + _root.cupprice + _root.legprice + _root.addonprice;


In the movie clip where I want to display the total (named "right"), i have a dynamic text field var: named "total_price" and this code in the first frame of the clip

Code:
_root.right.total_price=_root.total_price;


Now this displays the "700" like it should. But I want it to change as i make my selections in the other movie clip.
So I have this code for 3 buttons, one button makes the value 0, one 100, and one 200.

Code:
//first button
on (press) {
_root.surfaceprice =0;

//different button
on (press) {
_root.surfaceprice =100;

//last button
on (press) {

_root.surfaceprice =200;



So, in theory, shouldnt pressing these buttons change the value of the "_root.surfaceprice" in the main scene, then in turn chang the value of the "total_price" in the other movie clip?

Thank you for the help.
Brian

Trouble Adding Eventlistener In Loop
I'm having trouble adding this eventlistener in a simple loop. Can somebody tell, why the eventhandler doesn't get triggered?


Code:
// handler
function countryHandler(e:MouseEvent)
{
trace(e.currentTarget.name);
}

// add eventlistener loop
for (var i:Number = 0; i < isoCountriesArr.length; i++)
{
var tempId:String = isoCountriesArr[i];
if (map_mc.getChildByName(tempId) != null)
{
var tempCountryMc:MovieClip = MovieClip(map_mc.getChildByName(tempId));
countryArray.push(tempCountryMc)
tempCountryMc.addEventListener(MouseEvent.CLICK, countryHandler);
}
}

Trouble Adding Flvplayback Flash Cs3
Hi,
I can't seem to add the flvplayback component to the stage to a flash actionscript 3 file (for that matter my video imports seem to fail as well)---i have no trouble doing it in a action script 2 file though.

any advice?

thanks.

FMS 2 - Trouble Adding Application (CentOS)
Hi,

Very recently I managed to install on a CentOS 4.4 platform. I checked what services were running:

./fmsmgr list

21937 pts/0 00:00:00 fmsmaster
32580 pts/0 00:00:00 fmsadmin

I tried to develop my first test application found in 'Learning Flash Media Server 2' book. After creating the subfolder under applications folder, I them tried to add the application inside the Admin Console. The application was added momentarily and then disappeared. I went to check the messages log and by stopping and starting the fms server I was able to isolate the weird Failed messages below:

Jul 27 14:21:49 popcodestudio 257[21937]: Server starting...
Jul 27 14:21:49 popcodestudio Server[21937]: No primary license key found. Switching to Developer Edition.
Jul 27 14:21:49 popcodestudio 257[21937]: Server started (/opt/macromedia/fms/conf/Server.xml).
Jul 27 14:21:49 popcodestudio Server[21950]: No primary license key found. Switching to Developer Edition.
Jul 27 14:21:49 popcodestudio Server[21953]: No primary license key found. Switching to Developer Edition.
Jul 27 14:21:49 popcodestudio Adaptor[21950]: Listener started ( _defaultRoot__edge1 ) : 19350
Jul 27 14:21:50 popcodestudio Adaptor[21950]: Failed to create thread (TCProtocolAdaptor::startListenerThread).
Jul 27 14:21:50 popcodestudio Adaptor[21950]: Failed to start listeners for adaptor _defaultRoot__edge1.

Can anybody help me please, I couldn't find any help anywhere on the WEB.

Thanks a lot

Trouble Adding Numbers In Array
As an excercise, I'm trying to create a class that will take the average value of numbers in an array.
I'm stuck on adding the values of the array elements. I keep getting "NaN" for the total. Below is my code.


ActionScript Code:
private function getTotal ():Number
    {
        var total:Number;
        for (var i = 0; i<numArray.length; i++)
        {
            total += Number(numArray[i]);
        }
        trace("total= "+total);
        return (total);
    }

Having Trouble Adding Adverts And External Xml
Hello,

I am having trouble adding adverts and external files to a flash website.

I needs some guidance on how to do this properly. Can someone share their knowledge with me?

Thanks,

Sid

Trouble With Adding Buttons That Link To Other Scenes...? (PLEASE HELP)
Greetings...

I have put in the following code, to link to various scenes in my movie...
================================================
For example:

on (press, release) {
gotoAndPlay("Scene 6", 1);
}
================================================

Now, I place these actionscripts on the images that I converted to Flash Buttons and the following error comes up...

================================================
Example:

Scene=Scene 2, Layer=Presentations, Frame=485: Line 1: Mouse events are permitted only for button instances
on (press, release) {
================================================

When I play my movie, the "Buttons" that I created do act like real buttons (my mouse changes on MouseOver) but when I click them, nothing happens...

Why would this happen? I have other buttons in my movie, on other pages that link just fine and I used the same code... Why isn't it working now?


Thanks!!!
Dan

Trouble Adding Duplicated Movieclips To Array
whats up everybody,

once again its almost time to choke the young'ns. I'm on my last nerve and someone or something is gonna catch the wrath.

i have a question or problem that seems easy enough to handle. i've been trying to store my duplicated movie clips inside an array so i can access the x and y positions later. i have duplicate about 20 movie clips and need to have their names stored in an array while they're being duplicated. here's what my code looks like so far:

var intervalID;
intervalID = setInterval(checkLoadStatus, 100);

function checkLoadStatus() {
if(Title.loaded){
clearInterval(intervalID);

//split artist string into array
aArtists = Title.artists.split(",");
aPhotos = Title.photos.split(",");

// initialize stars with Title data
star_amount = aArtists.length;
trace("XXstar_amount = " + star_amount);



//declare arrays
a_Stars = new Array(star_amount);
a_centerCheck = new Array(star_amount);


for (i=0; i<star_amount; i++){

a_Stars[i] = duplicateMovieClip("star", "star" + i, 1+i );

//set length of array
a_Stars[i] = this["star" + i];

//set boolean values to check for position
a_centerCheck[i] = false;

}
star._visible = false;
trace("AAthe elements in a_Stars: " + a_Stars[1]._name);
trace("ZZthe elements in a_centerCheck: " + a_centerCheck[5]);
}
}


the problem is that flash is not storing the elements of the array. on my trace command a_Stars array keeps coming up empty while a_centerCheck displays its elements all fine. stars(the duplicated movie clip) is a child so the target is i believe to be ok. (but is probably wrong also - i just don't know).
any help, as always, is greatly appreciated.

thanks
erase

Trouble Loading A Text File When Passing The Variable In The URL String
I am trying to load variables into Flash from a text file. I pass the name of the text file as a variable in the URL string and then use that variable in the loadVariables command to pull in the text file. It works fine locally but is unreliable up on the server.

I seem to have got past this problem by moving the action to frame 2 from frame 1.

Has anyone else experienced problems with this and has found a better resolution?

Top 5 Maker: Merging Two Arrays And Adding The Values Of Matching String Entries
Hello All,
I've searched a bit and not found any discussions regarding what I'm looking for. I'm not looking for coded answers but would rather hear opinions on best approach.

I am creating a topFive Application using custom classes.
The simplest way to describe this is that two people can enter 5 strings and two top 5 lists are made, merged and a new top 5 is displayed.

Basically, I want to compare two multi-dimensional arrays that both contain a string with a value attached to it. I want to combine these arrays, and while doing so when a common string is found, I need it to add the two values and remove the two duplicates. (i'll get into an example below).

currently, multiple users (1 & 2 for now), can enter a string and a value is given to it. The strings are then made into a displayed list (outputting the multi-dimensional array into a text box "String:Value"). I plan on merging these two muli-dimensional arrays, and sorting by Value of the entry. When a duplicate entry is found, the values are added together and one entry is made with the new value and the other two entries are discarded.

I need advice on three steps:
1. Merging two MD arrays with a string and a value in each.

2. Finding duplicates by comparing the strings.

3. merging the duplicates and adding their value (creating a new entry and deleting the other two)?

Currently this is whats going on:

User 1 --->makes 5 string(str) entries ----->descending (nameValue) value added to each entry ------> entry and value make an array called u1_names. That is entered into a nameEntryClass that holds s:String and v:value


ActionScript Code:
u1_names.push(new nameEntry(str, nameValue));

trace in the app outputs User1 entries like this;

ActionScript Code:
trace(cmi.u1_names);

User1 entry 1:5,
User1 entry 2:4,
User1 entry 3:3,
User1 entry 4:2,
User1 entry 5:1


(This would be repeated for User 2)

Now before I collect the data from User 2 I want to know the best way about doing this.

So I need the App to merge, compare, add and delete redundant entries (see three steps above) from User 1 and User 2.

Is this possible?

Can anyone point me in the direction of a tutorial or a key word (I found recursive trace post in AS2 that looked close to what I'd need) that I could find more information regarding any of this..

Thanks in advance,

Having Trouble Adding Action Script To Button Symbol
Hello everyone:
I am hoping someone will read this as I am a developer in 'dires straits' with Flash ( a newbie). My problem regards a layer called "button" which has already been converted to symbol and turned into an invisible button. The problem lies when I try to use the selection tool to select it so that I can add action script to it. Instead of the actions dialogue box saying "actions-button", it says "actions-frame", and as a result, the action script doesn't work. I don't know what to do, it should be simple to select it but something is wrong. If you feel a need to help a developer in need, you can email me at support@tahutiwebsites.com, and I can e-mail you the file so that you can help. Thanks, or you can call me at 310-867-5167
Corinna

Trouble Adding Dynamically Named Elements To An Array Immediate Help Is Needed
OK, here we go... if someone can help me figure this out, I will have successfully completed my site in time for the deadline today at noon...

-- I have an array located at "_parent.emptyWindows"
-- "_parent[this._name]" gives me the name of the current MC and the value I want to add to array "emptyWindows"
-- I'm trying to add an element in this manner:


Code:
_parent.emptyWindows[_parent[this._name]] = _parent[this._name];
That is not working, but not even this is working for me:


Code:
_parent.emptyWindows["bird"] = "bird";
Here I've given an explicit value and name for the element to be added to the array, but obviously something is wrong in my context and I just am NOT finding it.

Any guesses???
Much appreciation,
The Dust

Copyright 2005-08 www.BigResource.com, All rights reserved