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




Weird Bug In ActionScript Envolving Array. Please Help.



I'm using Flash MX 6.0 and Flash MX 2004 Professional

Try this:


Code:
normal = new Array(01,02,03,04,05,06,07,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
Now check syntax.
It should appear "This script contains no errors".

Now try this:

Code:
normal = new Array(01,02,03,04,05,06,07,08,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);
Now check syntax. It says ERROR.

Code:
Scene=Scene 1, Layer=ac, Frame=1: Line 3: ')' or ',' expected
normal = new Array("01","02","03",04,05,06,07,08,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60);

Scene=Scene 1, Layer=ac, Frame=1: Line 15: Unexpected '}' encountered
}
The only diference is that I have a "08" instead of "8" in the Array. Is that a Flash bug or an error in my code?

Thanks.



FlashKit > Flash Help > Flash ActionScript
Posted on: 09-10-2004, 05:02 PM


View Complete Forum Thread with Replies

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

Weird Array Issue
im having a very strange array issue right now. any help on this would rock...

i am creating new movieclips, and then trying to store a reference to each one within an array called "openWin_array"

Here is that code...


Code:
cw_mc = windows_mc.attachMovie("contentWindow_mc", "contentWindow" + content_loc + "_mc", contentLoc + 1);

addToArray(openWin_array, cw_mc);
I pass the array and what needs to be added within the array to a function i setup called "addToArray"...here is that function


Code:
_global.addToArray = function(array, obj) {
// just keep adding stuff to array
r = array.push(obj);
trace(array);
};
now, it seems like this should work fine, but it doesn't? It will add the mc to the array, but it will delete the previous entry within the array....

for instance, the first time an mc is created...it will push the value into the array, and then the second or third time, it will push the new value into the array at the end, but all previous entries are deleted? What the crap is that? What am i doing wrong?

please help...

String From Array Is Being Weird :S
Hi all, I'm trying to get my simple tickerbox to work. It should tick out the message that was found in an array. This is my code:

PHP Code:



function TextScroll(Val) {    for(i=0; i<MyArray.length; i++) {        if (MyArray[i][0] == Val) {            rollScroll(MyArray[i][0],MyArray[i][1]); // Name, text        }    }}function RollScroll(NAME,TEXT) {    var a:Number = 0;    var thisText:String = TEXT;    _root.scroll.name.text = NAME;    onEnterFrame = function() {        _root.scroll.input.text = thisText.substr(0,a);        a++;    }} 




Well, all seems to work UNTILL i get to
PHP Code:



onEnterFrame = function() {         _root.scroll.input.text = thisText.substr(0,a);         a++;} 




Because I use substr() on my variable (which was defined as a string) I get the message "Undefined". When I leave the substr() away it goes well, but then I won't have my ticker effect.

Any thoughts? Thanks A LOT in advance!

Weird Array Issue
im having a very strange array issue right now. any help on this would rock...

i am creating new movieclips, and then trying to store a reference to each one within an array called "openWin_array"

Here is that code...


Code:
cw_mc = windows_mc.attachMovie("contentWindow_mc", "contentWindow" + content_loc + "_mc", contentLoc + 1);

addToArray(openWin_array, cw_mc);
I pass the array and what needs to be added within the array to a function i setup called "addToArray"...here is that function


Code:
_global.addToArray = function(array, obj) {
// just keep adding stuff to array
r = array.push(obj);
trace(array);
};
now, it seems like this should work fine, but it doesn't? It will add the mc to the array, but it will delete the previous entry within the array....

for instance, the first time an mc is created...it will push the value into the array, and then the second or third time, it will push the new value into the array at the end, but all previous entries are deleted? What the crap is that? What am i doing wrong?

please help...

Weird Array Problem.
actionscript Code:






Original
- actionscript Code




num = 0;
picsArr = new Array(6);
picArr[0] = "-";
picArr[1] = "-";
picArr[2] = "-";
picArr[3] = "-";
picArr[4] = "-";
picArr[5] = "-";
trace(picsArr[num]);






num = 0;picsArr = new Array(6);picArr[0] = "-";picArr[1] = "-";picArr[2] = "-";picArr[3] = "-";picArr[4] = "-";picArr[5] = "-";trace(picsArr[num]);



that traces undefined but I have no idea why

Weird Switch/Array Problem
Hello, I have a switch statement that dumps into an Object, wich dumps into an Array. Inside the switch everything works fine but when I return the Array of objects outside the switch, the only object that gets sent is the last object repeated throughout the array. I hope this is clear, I will send my code.

var deckSize:Number = 50;
var Card:Object = new Object();
var Deck:Array = Array();
//
function simulationDeck() {
//
for (i=0; i<deckSize; i++) {
randomCard = random(5);
switch (randomCard) {
case 0 :
Card.type = "Tank";
Card.weight = "Heavy";
Card.Image = "Heavy_Tank.jpg";
break;
case 1 :
Card.type = "Tank";
Card.weight = "Medium";
Card.Image = "Medium_Tank.jpg";
break;
case 2 :
Card.type = "Tank";
Card.weight = "Light";
Card.Image = "Light_Tank.jpg";
break;
case 3 :
Card.type = "Mine";
Card.weight = "NA";
Card.Image = "Mine.jpg";
break;
case 4 :
Card.type = "Range Rocket";
Card.weight = "NA";
Card.Image = "Range_Rocket.jpg";
break;
}
Deck[i] = Card;
trace("Card "+Deck[i].type);
}
for (i=0; i<deckSize; i++) {
trace("Card 2 "+Deck[i].type);
}
return Deck;
}

The first trace works fine, but then I check it outside the Switch and the deck Array gets rewritten with the last item in the list. Any Thoughts? Thanks for you applies!

Grabbing Php Data Into Weird Array
Hey guys,

Basically, I'm trying to loop through the msgx variables where msg0, msg1 come up. Problem is ev.target.data doesnt read my var msg as msg+k but just as msg

I tried it with static msg0's and msg1 and it works.

btw ars traces out null



ActionScript Code:
var prek:Array = new Array();

for(var k:Number = 0; k < b +1; k++) {
    var msg:String = "msg"+k;
   
    trace(msg);
   
    var ars:String = ev.target.data.msg;
   
    trace(ars);
   
    prek.push(ars);
   
   

}

Weird Prob With Array + Grid
Hi,
I am having a small problem which is best explained with the code :

PHP Code:



/*in the library is a linked mc.letBox, within the mc is a standard dynamic txt box, code on frame1 of letBox is:*/
label.text = _name;

/*on fr1 of the fla is this code:*/
myLVs = new LoadVars();
myLVs.load("myAlphabet.txt");
myLVs.onLoad = function(success)
{
    if (success)
    {
        
        myArr = new Array();
        myArr = this.myLets.split(",");
        trace(myArr)
        cols = 9;
        rows = 3;
        butHeight = 30;
        butWidth = 30;
        for (var r = 0; r<=rows; r++)
        {
            for (var c = 0; c<=cols; c++)
            {
                if (i<myArr.length)
                {
                    attachMovie("letBox", myArr[i],i,{_y:r * butWidth, _x:c * butHeight});
                }
                i++;
            }
        }
    }
}; 




myAlphabet.txt looks like this:
&myLets=A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U, V,W,X,Y,Z

Everything works as it should except for one small thing, the first element of myArr is not being assigned to the first mc, it is just empty!!!
I have run all the relevant traces, the txt file loads in OK, the split function works and myArr() is created and the grid is created, but the first element ( letter A ) is just not there and a cannot figure out why !!

I have posted an fla for those with the time to take look

Cheers

Vosgien

[AS 2.0] Weird Array Push Problem
here's a weird problem: in the second loop, the trace shows that i'm accessing the right element, put the array isn't populated with the push!!! what am i doing wrong?


Code:
prodXML.onLoad = function(success:Boolean)
{
var prod:Array = prodXML.firstChild.childNodes;
var path:Array = new Array();
var image:Array = new Array();

if (success)
{
for (i=0; i<prod.length; i++)
{
path.push(prod[i].attributes.path);

trace ("path[" + i + "]: " + path[i]);
// this returns correctly: parts/ and fruits/ respectively

var prodItem:Array = prod[i].childNodes;

for (j=9; j<prodItem.length; j++)
{
image[i].push(prodItem[j].attributes.image);

trace ("image[" + i + "][" + j + "]: " + image[i]);
// this returns "undefined": WTF?!

trace ("image: " + prodItems[j].attributes.image);
// this returns correctly: cc-22.png, cc-29.png, cc-21.png and cc-28.png
}
}
}
}

XML FILE:

<stuff color1="0xC1272D" color2="0x971B1E">
<frog_wrenches path="datacore/parts/">
<item image="cc-22.png"/>
<item image="cc-29.png"/>
</frog_wrenches>
<robot_berries path="datacore/fruits/">
<item image="cc-21.png"/>
<item image="cc-28.png"/>
</robot_berries>
</stuff>
i am totally stumped here! i'm sure it's some dumb little thing (isn't it always?).

thanks in advance.

WR!

Array.shuffle() Weird When Elements Are Objects
I asked this question on ultrashock, but I'll ask it here too, great answers here.

I have this method which shuffles an array:

Code:
// returns an array with elements shuffled in a random order
Array.prototype.shuffle = function() {
var shuffled_arr = []; // create an empty array
var copy_arr = this.slice(); // make a copy of the array
for (var i=0; i < this.length; i++) { // loop through each element of the array
shuffled_arr[i] = copy_arr.splice(Math.floor(Math.random() * copy_arr.length), 1);
} // end looping through each array element
return shuffled_arr;
} // end shuffle() method
This works great when the elements of the array are numbers or strings.

However, if each element is an object, e.g.

Code:
var my_arr = new Array();
for (var i=0; i < 10; i++) {
my_arr.push({x: i * 15, y: 0});
} // end loop

// return a shuffled array
var new_arr = my_arr.shuffle();
the object properties of each element get all messed up. new_arr[0].x and new_arr[0].y are no longer defined.

Instead, if you trace the properties of each element,

Code:
for (var i=0; i < 10; i++) {
var thisItem = this.ran_arr[i];
for (var prop in thisItem) {
trace("thisItem has property " + prop);
} // end
trace("shuffle: " + thisItem.shuffle);
}
you see the properties are "0" and "shuffle". Further, the last trace tells me that "shuffle" is a function (as it should be).

I'm not exactly sure what's going wrong here. I reckon it has something to do with my shuffle() method, but I can't seem to see what's wrong with it. Anybody have any ideas?

Copy A Multi-dimensional Weird Array
Hey Fk, I have got a big weird array and I need a copy of it but I can't use the = because then I can modify one of the two array without modifying the other one. Please...help ^^

Weird Timer Actionscript
I made this flash and coded it (stupidly) using (stupid) newbie language.
Well, the logic seemed on the line, but then there comes a fault. I must have left something out...
Could someone take a quick peek at my ASing?
Thanks
Loads
TONGXN

[MX] A Really Weird Actionscript Question?
Hi,

I did a web site about 4 years ago using minimal actionscript, It still works just fine when viewed from a Win Flash player, but not a Mac. On the Mac (OSX) none of the buttons function, yet when the site was done 4 years ago, they did.

My suspicion is that some change to the Flash Player (probably ver. 7 back then) on the Mac, has a conflict with the actionscript operating the buttons.

Can this be so? Has anyone heard of such a thing?

Thanks guys!

Weird ActionScript 3.0 Issue
Hi,

As of a couple of days ago, with any AS 3.0 scripting I do in the Action Panel regardless of how simple or complex, when I hit the Check Syntax button, I get the dialog box warning: "The script contains errors. The errors encountered are listed in the Compiler Errors Panel."

The problem is .. no errors are listed in the Compiler Errors Panel.
I've even gone so far as to load in samples from Adobe.com and regardless of the file, if there's ActionScript added to the timeline through the Actions Panel, I get "The script contains errors..." dialog box.

ActionScript 2.0 files are fine.

The problem does not occur on my Mac, just on my Windows PC running Creative Suite CS3 on Windows XP.

The only change I've made recently is to install the Dreamweaver and Fireworks CS4 betas. (I've done the same on my Mac, with no issues there).

Any ideas? I've uninstalled the CS4 betas and reinstalled Flash CS3, but that hasn't solved the problem.

ActionScript Gurus: Please Help, Very Weird Problem
I have been trying to fix this for about 8 hours now, and if I look at this any more I am seriously going to go crazy. Please help.

Site: www.berkeleyscion.com

I have a flash navigation bar that gets variables from a URL (via ASP, flash.swf?url=blah method. The movie gets a variable in the first frame on the timeline, and then forwards the movie to the appropriate frame_label on the same timeline. Easy as pie? Not quite.

In theory, by clicking the "Financing" button, the page should load and the bar should display the sub-menu items under the Financing section. However, for some reason, the menu ALWAYS goes to the "New Vehicles" submenu, regardless of the main/sub menu component that you click on. Here is the kicker: in order to have the correct submenu display, I have to click on each button twice/reload the page, and the menu displays properly.

The movie and page are definitely getting the variables, as the appropirate content is loaded, and the correct sub-menu item in the flash navigation bar is highlighted. However, the movie does not react to that variable the first time the page is loaded, but displays the correct segment when the page is loaded again/refreshed.

Could someone please take a look at this for me? You can download the file here:

www.berkeleyscion.com/navbar.zip

TIA

Weird ActionScript Not Working Or Just Fault?
The title explains it:

[code]on (release) {
_parent.gotoAndPlay("AuroraCo", 1);
}
CODE]

Now I checked the syntax and everything else, but this AS is not working. Its set on a MC inside a MC.
And I tried using _root.gotoAndBLAH.. didn't work either.

So why a'int this working?

Weird Problem, Actionscript 3.0 Not Compiling Actions?
Good Day All,

I'm at work with a couple of developers here, and we have one machine that just won't compile any AS 3.0 code. Even trying to do something this simple is working on other PCs but not his.



ActionScript Code:
myText.text = "blah blah"


When we hit ctrl-enter to run the file and use the debugger it says waiting to connect to player...

We have recently had this software installed less than a week ago, but I checked all the paths in the preferences/AS 3.0 settings and they all match as the same.

Any ideas?

Help: Weird Or Not So Weird Thingy With Dynamic Text Animation
http://www.david.bullaro.com/

there are 3 buttons on the right side education, experience and awards. Each loads an MC that then motion tweens into view from the side. The MC dynamically loads a text file. At the end the text blinks once. I understand the blink because i needed to reload the text for that keyframe but is there anyway around that blink?

TIA.

Actionscript Array Bug?
I think I found a bug in actionscript 2's array implementation. The following is solid according to flash's own documentation, however, it won't work. It only produces undefined results.

function convertToCartesian( r:Number, theta:Number ):Array
{
var cartesianPoints:Array;

cartesianPoints[0] = int(r * Math.cos(theta));
cartesianPoints[1] = int(r * Math.sin(theta));

trace( cartesianPoints[0] + ", " + cartesianPoints[1] );

return cartesianPoints ;
}

Has anyone else experienced something similar?

Array In ActionScript
I have a problem, just need to convert a code from Delphi into ActionScript, in Delphi is used an array like this:
Ar:array[1..300,1..300] of extended;

how to create that var in action script (bidimensional)? I was searching in many books but didn't find...
Thank you!

Array With Actionscript?
Can I include scripting in an array? Instead of going to an external link, I would like the link to execute a command in the movie, like:

links[1]=this._parent._parent.videoPlayer_mc.streamMedia(" videos/bounce10.flv", 10);

not

links[1]="www.actionscripts.org");

[F8] Weird Weird Loading Problem
Hey all,

Check out this project I'm working on:
http://www.niekdekker.com/overig/

The weird thing is, and you can see this, that the movie just stays white while it's loading. When the movie is fully loaded the movie begins.

And I am CERTAIN this has nothing to do with the way I built my flash. Even if I remove all the loading code it's still just white until it's all loaded. Think about it: There's isn't even a white frame in the entire movie!

So I dont' know what I am doing wrong.
Does anybody recognize this problem?

Thanks in advance,
Niek Dekker

Weird, Weird Stupid Problem
Ok, guys so I pressed something on my keyboard in actionScript 3 while writing code, and some weird sybmols popped up all over the place, I can't get rid of them :/

there is >> after every indent and line, and also some sort of backwards "P" on every new line.
does anyone know how to get rid of these? Cause they are crowding the code, and it's really hard to read and write.

Thanks deewds

Weird Weird Mask Problem
For some reason, all of a sudden, I'm experiencing a weird problem:

If I load an external swf into a movie clip that has a mask, the swf fails to show up. Delete the mask, and the swf appears. Put the mask back in, and POW! no swf.

The odd thing is, a project I authored a few weeks ago, with masks, works just fine!

Anybody else experience this issue??

I'm running OSX Tiger on a G5 dual processor.

Weird Weird Mask Problem
For some reason, all of a sudden, I'm experiencing a weird problem:

If I load an external swf into a movie clip that has a mask, the swf fails to show up. Delete the mask, and the swf appears. Put the mask back in, and POW! no swf.

The odd thing is, a project I authored a few weeks ago, with masks, works just fine!

Anybody else experience this issue??

I'm running OSX Tiger on a G5 dual processor.

Actionscript And Array Problem...
Frustration == yes

this is a statistics project that allows the user to compile hypotesis testing equations. after both equations are filled, a check button appears, and is supposed to trace some information and then true or false.

the function checkMe() checks the x and y coords of each movie clip acording to variables such as pos1, pos2, and posy1, and posy2.

when the correct equations are entered, it only recognizes posistions 3,4,7, and 8 as correct (array slots 2,3,6, & 7). any help or nit-picking would be much appreciated.

for testing purposes, the correct equations are:

Ho : u <= u0
Ha : u > u0

the file can be downloaded here:
http://www.columbia.edu/~bmd36/flash/

I Suck With Actionscript:Array Help
Sup, I'm an ordinary BASIC programmer who is in high school converting over to flash then to C++...etc.

I need a fast array scanner that will duplicate several different movies if a different number is found (100x100 array). I got some ideas for the array searcher, but the code is longer than I think actionscript is capable of.

Right now the code searches line by line. But I'm thinking about making a seperate little script so that when it detects changes in variables, it inputs the number and the position of the variable change into another array.

Any help?

Help With Actionscript Array Increment
How can I set

code:
path.forward_btn.onRelease = function() {


and

code:
path.back_btn.onRelease = function() {


to only increment iSectionIndex no more than once per folio clip X horizontal slide. I"m having a problem where the array is advancing ahead of itself because you can just keep clicking the buttons. At least I think this is the issue.

code:
var aSectionTxt;
var iSectionIndex = 0;
_global.portfolioSection = function(a) {
targetX = 527;
path = _root.sectionMC_03.folioClip;
maxWidth = path.section_mc._width-529;
velocity = 4;
aSectionTxt = a.concat();
path.section_mc.initEnterFrame();
path.forward_btn.onRelease = function() {
if (targetX>-(maxWidth-370)) {
targetX -= 370;
//
var dir = 1;
if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
iSectionIndex += dir;
}
// iSectionIndex must be set here -- not at the end of the enterframe func.
path.section_mc.initEnterFrame();
}
};
path.back_btn.onRelease = function() {
if (targetX<527) {
targetX += 370;
//
var dir = -1;
if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
iSectionIndex += dir;
}
// iSectionIndex must be set here -- not at the end of the enterframe func.
path.section_mc.initEnterFrame();
}
};
};
MovieClip.prototype.initEnterFrame = function() {
path.section_txt.text = "";
if (mcMovieToRemove != null) {
removeMovieClip(mcMovieToRemove);
}
this.onEnterFrame = function() {
//trace("Running Enter Frame");
this._x += (targetX-this._x)/velocity;
if (this._x<(targetX+1) && this._x>(targetX-1)) {
//trace("Stopping Enter Frame");
this._x = targetX;
setSectionText();
delete this.onEnterFrame;
}
};
};
_global.setSectionText = function() {
if (typeof (aSectionTxt[iSectionIndex]) == "string") {
path.section_txt.text = aSectionTxt[iSectionIndex];
} else {
mcMovieToRemove = path.attachMovie(aSectionTxt[iSectionIndex].linkage, "mcSectionMovie", 10);
mcMovieToRemove._x = aSectionTxt[iSectionIndex].x;
mcMovieToRemove._y = aSectionTxt[iSectionIndex].y;
}
};


I think the key is to change...

code:
if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
iSectionIndex += dir;
}


to include...if iSectionIndex + dir >= 0 && iSectionIndex+dir<=aSectionTxt.length AND this._x EQUALS targetX... or something like that then it would work. I just need iSectionIndex not to increment while this._x is busy reaching targetX and then I think everything would work. Or like if targetX-this._x/velocity = 0 then iSectionIndex += dir.

Actionscript Help With Array Increment
How can I set


ActionScript Code:
path.forward_btn.onRelease = function() {

and


ActionScript Code:
path.back_btn.onRelease = function() {

to only increment iSectionIndex no more than once per folio clip X horizontal slide. I"m having a problem where the array is advancing ahead of itself because you can just keep clicking the buttons. At least I think this is the issue.


ActionScript Code:
var aSectionTxt;
var iSectionIndex = 0;
_global.portfolioSection = function(a) {
    targetX = 527;
    path = _root.sectionMC_03.folioClip;
    maxWidth = path.section_mc._width-529;
    velocity = 4;
    aSectionTxt = a.concat();
    path.section_mc.initEnterFrame();
    path.forward_btn.onRelease = function() {
        if (targetX>-(maxWidth-370)) {
            targetX -= 370;
            //
            var dir = 1;
            if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
                iSectionIndex += dir;
            }
            // iSectionIndex must be set here -- not at the end of the enterframe func.
            path.section_mc.initEnterFrame();
        }
    };
    path.back_btn.onRelease = function() {
        if (targetX<527) {
            targetX += 370;
            //
            var dir = -1;
            if (iSectionIndex+dir>=0 && iSectionIndex+dir<=aSectionTxt.length) {
                iSectionIndex += dir;
            }
            // iSectionIndex must be set here -- not at the end of the enterframe func. 
            path.section_mc.initEnterFrame();
        }
    };
};
MovieClip.prototype.initEnterFrame = function() {
    path.section_txt.text = "";
    if (mcMovieToRemove != null) {
        removeMovieClip(mcMovieToRemove);
    }
    this.onEnterFrame = function() {
        //trace("Running Enter Frame");
        this._x += (targetX-this._x)/velocity;
        if (this._x<(targetX+1) && this._x>(targetX-1)) {
            //trace("Stopping Enter Frame");
            this._x = targetX;
            setSectionText();
            delete this.onEnterFrame;
        }
    };
};
_global.setSectionText = function() {
    if (typeof (aSectionTxt[iSectionIndex]) == "string") {
        path.section_txt.text = aSectionTxt[iSectionIndex];
    } else {
        mcMovieToRemove = path.attachMovie(aSectionTxt[iSectionIndex].linkage, "mcSectionMovie", 10);
        mcMovieToRemove._x = aSectionTxt[iSectionIndex].x;
        mcMovieToRemove._y = aSectionTxt[iSectionIndex].y;
    }
};

Actionscript - TextField - Array
Hi,
I am trying to pull out the contents of an array ("category" in my case) and display it inside a textfield ("testText"). The elements of teh array should appear one after the other inside the textfield. I created a textField inside a movieclip and then was trying to animate the movieclip. But how do I change the contents of the text field? I tried something like the following, but the elements sweeps past so fast that only the last element of the array is visible.

this.onEnterFrame = function(){
for(var i:Number=0; i<category.length; i++){
testMovie.testText.text = category[i];
}
};


Any help is appreciable. Thank You.
Abi.

Actionscript Eval And Array[] Enigma
i stumbled into a little puzzler......
i am using the following actionscript:

_root.num_04="violet"
colorName = eval("_root.num_" + _root.menusArray[4][1] ) ;
_root.array1 = colorName;
_root.array2 = _root.menusArray[4][1];
set("_root." + colorName, []);
set("_root." + colorName + "[1]", _root.menusArray[4][1]);
set("_root." + colorName + "[2]", _root.menusArray[4][2]);
_root.array3 = _root.violet[2];
_root.array4 = eval("_root." + _root.num_04 + "[2]");


menusArray[4][1] holds a text value like "04"
menusArray[4][2] holds a text value like "Company"
[array1....array4 are just dyn text boxes to display values for debugging]


results of dyn text boxes:

array1 ==> [violet ] ...correct
array2 ==> [04 ] ...correct
array3 ==> [ ] .......nothin!
array4 ==> [Company ] ...correct


the question is......why no value showing up for array3?
its got something to do with how the definition of the array is constructed.....using 'eval'

i then added this line of actionscript to further understand what was happening.....

_root.violet[2] = "New Value";
after this addition......
array3 ==> [New Value ]
but....
array4 ==> [Company ] ...not affected!?!

so......
either the definition using 'eval' make the difference
or
the difference lies in the 'eval' used to define the final value....
...as in the diff betw....
_root.array3 = _root.violet[2];
and....
_root.num_04="violet"
_root.array4 = eval("_root." + _root.num_04 + "[2]");


any thoughts would be appreciated.


[Edited by howardroarklives on 04-09-2002 at 03:01 AM]

MX ActionScript Question, Array To Send XML
Hello!

In my flash movie, I have an array of data.. At the end of the movie, I want to take this array and have it in an XML object so that when the user clicks a certain button, that XML object is sent to a server-side PHP file. Could someone please help me with this ASAP??

Thanks,
Susanna

Actionscript 2.0 Dimentional Array Dilema
Not sure if this being AS2.0 matters:

I have a 2D array that i am shifting and pushing

basically I want to take the first row and put it in the back of the array

so 1,2,3,4
to 2,3,4,1
to 3,4,1,2
and so forth.

code:

var temp1:Number = _root.idArray[0][0]
var temp2:String = _root.idArray[0][1]
x = _root.idArray.length
function doArray(){
_root.idArray.shift();
//_root.idArray[0][0] = shifted
_root.idArray.push();
_root.idArray[x][0] = this.temp1
_root.idArray[x][1] = this.temp2
}


THIS doesnt work
i think my code for the push should look something like
_root.idArray.push({temp1,temp2})

but when compiled i get an identifier problem

HELP!!!!!

Array Of Record (Delphi => ActionScript)
Have a var in Delphi:

c:array [0..90601] of record x,y:integer end;
.
.
procedure Tform1.LgCub;
var x,y:extended;
...
for g:=0 to 90601 do
begin
j:=c[g].x;k:=c[g].y;
x:=(k-150)*scala;
y:=(150-j)*scala;
natm:=0;
....

How can I declare the analog of it (c) in ActionScript?
Thanks.

Pass Array From ActionScript To JavaScript
Hi, All:

Can anyone explain how to pass an array into JavaScript using the getURL function? Current code looks something like this, but it does not work:

getURL("javascript: myFunc(" + myArray + ");")

However, this call seems to produce this actual code in both IE and Firefox:

getURL("javascript: myFunc([object Object]);")

Both browsers choke on [object Object]. In Firefox, it explicitly thinks some other delimiter should appear around [object Object].

I searched the knowledge base and it says that arrays can be passed between JavaScript and Flash without any problem, so I am not sure exactly what we re doing wrong in this call. Any help would be appreciated. Thanks!

AJK

Actionscript: Storing Objects In An Array
bit of a programming question here :
I have a data object class in which I would like a property to be an array of objects , each with their own properties and methods. It seems that in actionscript , once put inside an array, an object loses its type - does anyone know if is there any way round this?

Would it be bad to just create a generic object for each array element and dynamically assign properties to it?



Adv Actionscript: Calling Functions From Array Or XML
The question is twofold. I've written a group of functions. I want to call the functions based off of entries in an xml file. So, XML 1 will call function 4. XML 2 will call function 1, etc...

What happens is this, the string in the xml file relates to a function in my actionscript, however Flash is only recognizing the string as a string, and not as one of the functions in my code. I've tried strict datatyping the xml text to a variable...

Code:

var functionname:Function = xmlNode.childNodes...nodeValue


I then push the variable to an Array, and call the element in the array on a button click. If I trace my variable, it has the same name as my function, but my function isn't running

...2nd part, Other languages have what's called "collections"...for example, when compiling in .Net, or a similar language, I can use a global "collection" reference to access any of the function written in the code. Does Actionscript have a similar reference? (not only for functions, but for say Movie Clips, images, sounds, etc)

thnx,
-j

Actionscript Movieclip Array Access
ok, so i have a MENU movieclip, which contains some button movie clips.
i create the movie clips using actionscript, and store them in an array (which is in fact just an array of strings that hold the mc identifiers).
I access these movie clips (in the MENU movieclip), by using
Code:

this[button_mc[i]].property

however, i can't seem to access them in a similar way in _root.

I would of thought it would be something like
Code:

_root[MENU.button_mc[index]].property, but no dice.

I could access the movie clips using the actuall string identifiers, but that gets rid of the niceness of using the array.

Why does flash suck in this way?

Actionscript also sucks. I spend so much time debugging spelling mistakes in my variable names.

But yeah, flash is ace.

Links To Html Files In An Actionscript Array
I am a noob to flash! I downloaded a flash component from flashden and I am trying to edit it to suit my needs. I am able to change everything i need to except add links to other html pages in my site in the array in actionscript.

Can someon eplease help me?

Here is my code:




//The script for the button effects
import SubBtn;
//script for fade transitions
import caurina.transitions.Tweener;

/***********************************

Hello,

Thanks for buying this menu.
So how do you implement this menu?

1. change the paramenters bellow to suit your needs
(the paramenters which should be changed is marked)

2. if you are using this menu as part of a bigger project
you have to copy the external classes into your project directory
(that is the entire folder caurina and the class SubBtn.as)

3. in the _menuItemsAndContent array in the change variables
section beneath you should put in a name of the
menu item along with an MovieClip accosiated with that item. So when the item
is clicked you can retrieve that mc.

another way to change the content would be to listen to the item id
and determin what to show according to that. Then not accosiate any MovieClip
and just leave the mc as a null.

alternatively you can listen for the name of the item.
if you dont what to accosiate the item with a MovieClip just put in null as
I did in the sample.

4. When an item is clicked the function onSubMouseClick is called and
you should determin what to happen, as this is only a menu!
So go to the onSubMouseClick function bellow the change variables section
and see how to retrieve the items' data when they are clicked.

Cheers

***********************************/


/***********************************
--> CHANGE VARIABLES SECTION
***********************************/
var _spacing:int = -2; //the spacing of the menu items
var _btnAlpha:Number = .6; //the alpha of the menu items
var _overColor:String = "#f2a800"; //the over hex color
var _outColor:String = "#878a7c"; //the "not" over hex color



//there are currently 5 items in the menu
var _menuItemsAndContent = new Array({name:"Home", mc:new MovieClip}, //name and mc, leave mc empty if you don't use it
{name:"about us", mc:null},
{name:"portfolio", mc:null},
{name:"services", mc:null},
{name:"contact us",mc:null});
/***********************************
END OF CHANGE VARIABLES SECTION
***********************************/


function onSubMouseClick(event:MouseEvent):void {
//here are the the 3 methods that can be used to change the content

//returns item id/it's position in the _subBtnsAndPos array
trace("id " + event.currentTarget.name);
//returns the items name
trace("name " + _subBtnsAndPos[event.currentTarget.name].name);
//return the MovieClip that has been accosiated with the item or null
//if you haven't use that feature
trace("MC " + _subBtnsAndPos[event.currentTarget.name].mc);
}





/***********************************
THE PART OF THE SCRIPT
WHICH SHOULD BE CHAGED STARTS HERE
***********************************/
var _subMenuYPos:int = openMenu.y + openMenu.height + _spacing + 0;//pos of the items
var _subBtnsAndPos:Array = new Array();//the sub items and their data
var _subsHolder:Sprite = new Sprite();//holds all items
var _isOpen:Boolean = false;//to see if the menu is opened or not

addSubMenues(_menuItemsAndContent);//call the addSubMenues which creates the items
_subsHolder.alpha = _btnAlpha;//uses the alpha from change variables section
openMenu.buttonMode = true;

//ads events
openMenu.addEventListener(MouseEvent.ROLL_OVER, onOpenMenu);
_subsHolder.addEventListener(MouseEvent.ROLL_OUT, onCloseMenu);




//OPEN MENU
function onOpenMenu(event:MouseEvent):void {
tweenOutSubs("in");//the function which tween the items in and out
}
//CLOSE MENU
function onCloseMenu(event:MouseEvent):void {
tweenOutSubs("out");
}
function tweenOutSubs(type:String):void {
if(type == "in") {
if(!_isOpen) {
//if the items are not visible they are tweened
//on to the stage, by looping through the _subBtnsAndPos array
_isOpen = true;
for(var i:int; i < _subBtnsAndPos.length; i++) {
_subBtnsAndPos[i].object.alpha = 0;
_subBtnsAndPos[i].object.visible = true;
Tweener.addTween(_subBtnsAndPos[i].object, {y:_subBtnsAndPos[i].pos
,alpha:1, time:1, transition:"easeOutQuart"});
}
}
}
else {
//the same thing but now they are tweened out
_isOpen = false;
for(var o:int; o < _subBtnsAndPos.length; o++) {
Tweener.addTween(_subBtnsAndPos[o].object, {y:0,time:.5, alpha:0, transition:"easeOutQuart"});
}
}
}




//ADD SUB
function addSubMenues(arr:Array):void {
//the sub items are created with the addSubMenu function
for(var i:int; i < arr.length; i++) {
addSubMenu(arr[i].name, arr[i].mc);
}

var maxWidth:int;
for(i = 0; i < _subBtnsAndPos.length; i++) {
if(_subBtnsAndPos[i].object.width > maxWidth){
maxWidth = _subBtnsAndPos[i].object.width;
}
}

//adding hit area
var appHit:Shape = new Shape();
appHit.graphics.beginFill(0xCC0000,0);
appHit.graphics.drawRect(0, 0, maxWidth, _subMenuYPos + _subBtnsAndPos[_subBtnsAndPos.length-1].object.height);
appHit.graphics.endFill();
_subsHolder.addChildAt(appHit,0);
removeChild(openMenu);
_subsHolder.addChild(openMenu);

addChild(_subsHolder);
}
function addSubMenu(name:String, mc:MovieClip):void {
//call to SubBtn (external class) which deals with the mouse over effects
var sub:SubBtn = new SubBtn(_overColor, _outColor, name.toLowerCase());
sub.addEventListener(MouseEvent.CLICK, onSubMouseClick);
sub.name = String(_subBtnsAndPos.length);
sub.visible = false;

//the item is pushed into the _subBtnsAndPos array so they can be
//retrieved later on
_subBtnsAndPos.push({object:sub, pos:_subMenuYPos, mc:mc, name:name.toLowerCase()});
_subsHolder.addChild(sub);

//adds to the menu height to possition the next button bellow this one
_subMenuYPos += sub.height + _spacing;
}

Actionscript Compare Two Arrays And Create New Array
I have two arrays which contain something like:

array_one = (a->b, b->c, c)

array_two = (a, b, b->c, c)

and I want to concatenate these (I can do that) but remove duplicates. So at the moment I have:

array_three = (a->b, b->c, c, a, b, b->c, c)

whereas I want it to be:

array_three = (a->b, b->c, c, a, b) the order doesn't matter.

Can someone show me how to do this please? I think I either need to compare each element before concatenation, or somehow remove duplicates afterwards?

[F8] Setting Array Keys Dynamically In Flash Actionscript
I'm creating an array object in ActionScript. I need the keys AND the properties of those keys to be dynamic.

Here is a hard-coded example:
MyArray[0].Title = "This is the title"

...but I want the key ("Title" in this example) to be dynamic. Here's how I would think it could work:

index_num = 0
prop_name = "Title"
eval("MyArray["+ index_num +"]."+ prop_name +") = "This is the title!"

...but that doesn't work.

How do I do this??

Thanks in advance!!!

Creating Multi-Dimensional Delimited Array In ActionScript
Hi, I haven't even gone so far as to try any kind of prototyped idea of this as I just do not want to get myself bogged down on any wrong route, as from past experience, I don't want to waste a weeks worth of time and hair.

here's the problem.........


I am currently poulating a Flash production for a client with XML generated data, simply so that I can give my client a piece of work which they themselves can update easily. The problem comes from the fact that I could have quite a lot of information hanging around in the form of a multi dimensional array structure where the XML data will be placed after parsing.

Ideally I would like the ability to create a delimited Multi-dimensional array, which can dynamically update it's size, without me having to declare an array of 32000 cells each time, which could waste system resources to a stupid proportion.

any help with this would be appreciated.

I have tried:-


Code:
_global.myArray = new Array();
but it didn't seem to initialise the array unfortunately....


Tanks!!!

[Flash8] Actionscript - Passing Array Variables By Value Not Reference
It took me hours to figure our why this was returning the wrong value - when assigning one array to another it passes by reference not Value. I need a way to force it to pass by values. e.g. copy the existing array and have the second array reference it, so i am free to modify the first array without changing the values of the second

// CODE Sample - show that array assignment = passing by reference.

function one(){

var test1 = Array();
test1["one"] = 1;

var test2 = test1;

trace(test2.one); // output = 1 // this make sense because it gets the value from test1
test1.one = 1000;

trace(test2.one); // output = 1000 // !!!! this should be 1 === passed by reference. If by value this would be independent from test1.one
}

one();

/// end CODE SAMPLE

From the example above You see that in Actionscript when assigning one variable to another it does it my reference not value. So when you chage the value of one array it changes the value of the other automatically.

I need to have the "test2" variable reference the "test1" array only by value so if modify "test1" the values of "test2" won't be modified.

If this is a setting to change this or a way to have the variable reference only by value this would be extremely helpful.

Thanks

KJ

Loading XML Child Nodes Attributes In A Array In Flash Actionscript
hi guys .i want to load all the attributes by the name "pagename" within this xml file into an array : my_array
pls help.

xml file:

Code:

<?xml version="1.0" encoding="UTF-8" ?>
- <earnvaluemanagement>
- <module id="01" title="Overview" foldername="content/module_01">
- <chapter id="01_01" title="Introduction">
<page id="01_01_01" title="Introduction" pagename="m01_c01_p01.swf" />

<page id="01_01_02" title="Introduction" pagename="m01_c01_p02.swf" />

<page id="01_01_03" title="Introduction" pagename="m01_c01_p03.swf" />

<page id="01_01_04" title="Introduction" pagename="m01_c01_p04.swf" />

</chapter>


</module>


- <module id="02" title="Earned Value Management Concepts" foldername="content/module_02">
- <chapter id="02_01" title="Overview">
<page id="02_01_01" title="Overview" pagename="m02_c01_p01.swf" />

<page id="02_01_02" title="Overview" pagename="m02_c01_p02.swf" />

<page id="02_01_03" title="Overview" pagename="m02_c01_p03.swf" />

<page id="02_01_04" title="Overview" pagename="m02_c01_p04.swf" />

<page id="02_01_05" title="Overview" pagename="m02_c01_p05.swf" />

<page id="02_01_06" title="Overview" pagename="m02_c01_p06.swf" />

</chapter>


- <chapter id="02_02" title="Framework of EVM System">
<page id="02_02_07" title="Framework of EVM System" pagename="m02_c01_p07.swf" />

<page id="02_02_08" title="Framework of EVM System" pagename="m02_c01_p08.swf" />

<page id="02_02_09" title="Framework of EVM system" pagename="m02_c01_p09.swf" />

<page id="02_02_10" title="Framework of EVM system" pagename="m02_c01_p10.swf" />

<page id="02_02_11" title="Exercise" pagename="m02_c01_p11_exercise01.swf" />

<page id="02_02_12" title="Exercise" pagename="m02_c01_p11_exercise02.swf" />

<page id="02_02_13" title="Summary" pagename="m02_c01_p12_Summary.swf" />

</chapter>


</module>


- <module id="03" title="Scope of the Project: Work Breakdown Structure" foldername="content/module_03">
- <chapter id="03_01" title="What is WBS?">
<page id="03_01_01" title="What is WBS?" pagename="m03_c01_p01.swf" />

<page id="03_01_02" title="Preparing a WBS" pagename="m03_c01_p02.swf" />

</chapter>


- <chapter id="03_02" title="Preparing a WBS">
<page id="03_02_03" title="Preparing a WBS" pagename="m03_c01_p03.swf" />

<page id="03_02_04" title="Preparing a WBS" pagename="m03_c01_p04.swf" />

<page id="03_02_05" title="Preparing a WBS" pagename="m03_c01_p05.swf" />

<page id="03_02_06" title="Preparing a WBS" pagename="m03_c01_p06.swf" />

</chapter>


- <chapter id="03_03" title="WBS and Earned Value">
<page id="03_03_07" title="Preparing a WBS" pagename="m03_c01_p07.swf" />

<page id="03_03_08" title="Preparing a WBS" pagename="m03_c01_p08.swf" />

<page id="03_03_09" title="Exercise" pagename="m03_c01_p09_exercise01.swf" />

<page id="03_03_10" title="Exercise" pagename="m03_c01_p09_exercise02.swf" />

<page id="03_03_11" title="Exercise" pagename="m03_c01_p09_exercise03.swf" />

<page id="03_03_12" title="Summary" pagename="m03_c01_p10_summary.swf" />

</chapter>


</module>


- <module id="04" title="Plan and Schedule the Project" foldername="content/module_04">
- <chapter id="04_01" title="Understand and Plan The Project">
<page id="04_01_01" title="Understand and Plan the Project" pagename="m04_c01_p01.swf" />

<page id="04_01_02" title="Understand and Plan the Project" pagename="m04_c01_p02.swf" />

</chapter>


- <chapter id="04_02" title="Schedule the Project">
<page id="04_02_03" title="Schedule the Project" pagename="m04_c01_p03.swf" />

<page id="04_02_04" title="Schedule the Project" pagename="m04_c01_p04.swf" />

<page id="04_02_05" title="Schedule the Project" pagename="m04_c01_p05.swf" />

<page id="04_02_06" title="Exercise" pagename="m04_c01_p06_exercise01.swf" />

<page id="04_02_07" title="Exercise" pagename="m04_c01_p06_exercise02.swf" />

<page id="04_02_08" title="Summary" pagename="m04_c01_p07_summary.swf" />

</chapter>


</module>


- <module id="05" title="Estimate and Budget Project Resources" foldername="content/module_05">
- <chapter id="05_01" title="Why Budgeting?">
<page id="05_01_01" title="Why Budgeting?" pagename="m05_c01_p01.swf" />

<page id="05_01_02" title="Why Budgeting?" pagename="m05_c01_p02.swf" />

<page id="05_01_03" title="Why Budgeting?" pagename="m05_c01_p03.swf" />

</chapter>


- <chapter id="05_02" title="Earned Value CAPs (Control Account Plans)">
<page id="05_02_04" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p04.swf" />

<page id="05_02_05" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p05.swf" />

<page id="05_02_06" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p06.swf" />

<page id="05_02_07" title="Earned Value CAPs (Control Account Plans)" pagename="m05_c01_p07.swf" />

<page id="05_02_08" title="Exercise" pagename="m05_c01_p08_exercise01.swf" />

<page id="05_02_09" title="Exercise" pagename="m05_c01_p08_exercise02.swf" />

<page id="05_02_10" title="Summary" pagename="m05_c01_p09_summary.swf" />

</chapter>


</module>


- <module id="06" title="EVMS Concepts and Methods" foldername="content/module_06">
- <chapter id="06_01" title="EVMS Criteria">
<page id="06_01_01" title="EVMS Criteria" pagename="m06_c01_p01.swf" />

<page id="06_01_02" title="EVMS Criteria" pagename="m06_c01_p02.swf" />

</chapter>


- <chapter id="06_02" title="EVMS Basic Terminology">
<page id="06_02_01" title="EVMS Basic Terminology" pagename="m06_c02_p01.swf" />

</chapter>


- <chapter id="06_03" title="Earned Value Methods">
<page id="06_03_02" title="Earned Value Methods" pagename="m06_c02_p02.swf" />

</chapter>


- <chapter id="06_04" title="Project Status">
<page id="06_04_03" title="Project Status" pagename="m06_c02_p03.swf" />

<page id="06_04_04" title="Exercise" pagename="m06_c02_p04_exercise01.swf" />

<page id="06_04_05" title="Exercise" pagename="m06_c02_p04_exercise02.swf" />

<page id="06_04_06" title="Summary" pagename="m06_c02_p05_summary.swf" />

</chapter>


</module>


- <module id="07" title="Monitoring Performance Against the Baseline" foldername="content/module_07">
- <chapter id="07_01" title="Performance Measurement">
<page id="07_01_01" title="" pagename="m07_c01_p01.swf" />

<page id="07_01_02" title="" pagename="m07_c01_p02.swf" />

</chapter>


- <chapter id="07_02" title="Variances and Performance Indices">
<page id="07_01_03" title="" pagename="m07_c01_p03.swf" />

<page id="07_01_04" title="" pagename="m07_c01_p04.swf" />

</chapter>


- <chapter id="07_03" title="Estimate at Completion">
<page id="07_01_05" title="" pagename="m07_c01_p05.swf" />

<page id="07_01_06" title="" pagename="m07_c01_p06.swf" />

<page id="07_01_07" title="" pagename="m07_c01_p07_exercise01.swf" />

<page id="07_01_07" title="" pagename="m07_c01_p07_exercise02.swf" />

<page id="07_01_08" title="" pagename="m07_c01_p08_summary.swf" />

</chapter>


</module>


- <module id="08" title="Integrated Baseline Review and Change Control" foldername="content/module_08">
- <chapter id="08_01" title="Integrated Baseline Review">
<page id="08_01_01" title="" pagename="m08_c01_p01.swf" />

<page id="08_01_02" title="" pagename="m08_c01_p02.swf" />

</chapter>


- <chapter id="08_02" title="Change Control">
<page id="08_01_03" title="" pagename="m08_c01_p03.swf" />

<page id="08_01_04" title="" pagename="m08_c01_p04.swf" />

<page id="08_01_05" title="" pagename="m08_c01_p05.swf" />

</chapter>


- <chapter id="08_03" title="Cost Performance Report">
<page id="08_01_06" title="" pagename="m08_c01_p06.swf" />

<page id="08_01_07" title="" pagename="m08_c01_p07.swf" />

<page id="08_01_08" title="" pagename="m08_c01_p08.swf" />

<page id="08_01_09" title="" pagename="m08_c01_p09_exercise01.swf" />

<page id="08_01_09" title="" pagename="m08_c01_p09_exercise02.swf" />

<page id="08_01_010" title="" pagename="m08_c01_p010_summary.swf" />

<page id="08_01_010" title="" pagename="m08_c01_p011_course_summary.swf" />

</chapter>


</module>


- <module id="09" title="Assessment" foldername="content/module_09">
- <chapter id="09_01" title="Assessment">
<page id="09_01_01" title="" pagename="assessment.swf" />

<page id="09_01_02" title="" pagename="Thank_you.swf" />

</chapter>


</module>

[f8]weird DuplicateMovie...very Weird...
Hi,

I'm trying to create an application where users can add a textfield from the context menu and then extend the textbox to suit their needs. I have managed to do this pretty much but something very odd is happening when the clip is duplicated...see SWF.

Where am I going wrong if I just want the clip to be duplicated and I don't want the original clip visible otherwise the context menu would be pointless.. Notice what happens when you right-click a second time and try to extend the clip.

Code:
root_cm = new ContextMenu();
root_cm.hideBuiltInItems();
root_cm.customItems.push(new ContextMenuItem("Add card", itemHandler));
function itemHandler(obj:Object, item:ContextMenuItem) {
for (i=0; i<100; i++) {
card1.duplicateMovieClip("card1"+i, i);
}
};
_root.menu = root_cm;

And this code inside the MC

Code:
this.drag_mc.onPress = function ()
{
this._parent.swapDepths(_root.getNextHighestDepth());
this._parent.startDrag();
dragging = 1;
};
this.drag_mc.onRelease = function ()
{
trace("new_y=" + this._parent._y);
this._parent.stopDrag();

dragging = 0;
};
stop();

Finally I use this to enlarge the textbox:

Code:
onClipEvent (enterFrame)
{
if (pressing == true)
{
_parent.textbox._width = _x + 37;
_parent.textbox._height = _y + 32;
_parent.drag_mc._y = _y + 15;
_parent.drag_mc._x = _parent.textbox._width / 2;
} // end if
if (_parent.dragging == 1)
{
} // end if
}


Help would be much appreciated as I have been trying for a while now...

Weird Problem, Really Weird.
Okay, using this script on the frame...

ActionScript Code:
var Stamina = 100;
and this on a MC...

ActionScript Code:
onClipEvent (load) {
    walkSpeed = 1.5;
    runSpeed = 1.8;
    moveNum = 0;
}
onClipEvent (enterFrame) {
    if (Key.isDown(Key.RIGHT)) {
        this._x += walkSpeed;
        _root.Stamina -= .1;
    } else if (Key.isDown(Key.LEFT)) {
        this._x -= walkSpeed;
        _root.Stamina -= .1;
    } else if (Key.isDown(Key.UP)) {
        this._y -= walkSpeed;
        _root.Stamina -= .1;
    } else if (Key.isDown(Key.DOWN)) {
        this._y += walkSpeed;
        _root.Stamina -= .1;
    } else if (Key.isDown(68)) {
        this._x += runSpeed;
        _root.Stamina -= 2;
    } else if (Key.isDown(65)) {
        this._x -= runSpeed;
        _root.Stamina -= 2;
    } else if (Key.isDown(87)) {
        this._y -= runSpeed;
        _root.Stamina -= 2;
    } else if (Key.isDown(83)) {
        this._y += runSpeed;
        _root.Stamina -= 2;
    }
}

For some reason, the number never goes down by .1, it goes down by something like .100000000001. Is there a way to fix it? And how would I use Math.floor, Math.ceil, or Math.round to fix it?

StaminaBox is the name of the TxtBox

Array, Array HELP - Importing A External File Into N ARRAY - Almost There
I am reading and external file with the following code:

ActionScript Code:
on (release, keyPress "<Enter>") {
lv = new LoadVars();
lv.onLoad = function() {
questions1 = this.filelist0.split(",");
answers1 = this.filelist1.split(",");
for(i=0;i<questions1.length;i++)
//trace(questions1[i]+"   "+answers1[i]);
trace(questions1[i]);

//assumes same number of scores in each list
};
lv.load("questions.txt");
}


When I parse the file it puts it into an columar format as it should...however I need it to look like this:

questions1=new Array ("2+4=?","What is the capital of Illinois?","What color is the sky?","10x(5+2)=?");

answers1=new Array ("8","springfield","blue","70");


How do I do that?

Text file look like this:

&questions1=2+4=?,What is the Capital of Illinois?,What color is the sky?,10x(5+2)=?")&
&answers1=8,springfield,blue,70&

Actionscript Help For: "Id"attribute In XML Array
Ok, the idea here is to have a .jpg load into the .swf (no "onpress" here)
I've got it to work so far; however I want to be able to have specific .jpg's load according to the "Id" attribute in the .xml file.
So if i want the .jpg with an attribute of "Id=002" to load all I would need to change in the action script would be a variable of "002"
any ideas?

thanks
James

link to all working files thus far.
http://www.anicespot.com/test/

--------------
actionscript
--------------
images_xml = new XML();
images_xml.onLoad = ViewImage;
images_xml.load("images.xml" ) ;
images_xml.ignoreWhite = true;
function ViewImage(success) {
if (success == true) {
rootNode = images_xml.firstChild;
Image = rootNode.firstChild;
updateImage(Image);
}
}
function updateImage(Image) {
imagePath = Image.attributes.jpegURL;
image_area.loadMovie(imagePath);
}

-----
XML
-----
<?xml version="1.0"?>

<Images>
<image Id="000" jpegURL="images/image1.jpg"> /image>
<image Id="001" jpegURL="images/image2.jpg"> /image>
<image Id="002" jpegURL="images/image3.jpg"> /image>

</Images>

Pls Help: Need To Create New Array Taking 3 Random Entries From An Existing Array
Hello

I have a 2d array:

qTeeth[1] = [How many teeth do we have?, 1-10, 11-20, 21-30, 11-20]
etc.

It goes [question, option1, option2, option3, real answer]

I now just want to extract 3 or so of these entries and create a new array with them. Since I want to just use 3 or so questions randomly from a large array of questions.

Does anyone know a good tidy script to do this with??


Thanks in advance,
Ben.

If I Type Array[1]=array[2] Their Values Are Permanently Linked. How Do I Change This
e.g.

Code:
array[2][0] = 4;
array[1] = array[2];
array[1][0] = array[1][0] + 3;

trace("array[1]= " + array[1]);
trace("array[2]= " + array[2]);


Result:
array[1]=7;
array[2]=7;


The result I want is:
array[1]=4;
array[2]=7;




How do I achieve this?

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