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




Adding A Variable Number To A Mc Path



I extarcted a number that I want to add on to a instance name to find the x of that mc

Code:
function checkHomePos() {
if (_root.pannelDrag) {
this.whatPanel = _root.currentPanelView;
n = Number(this.whatPanel.substring(1));

this.homeX=_root["bgP"+n]._x;
trace("BGP :" +_root["bgP"+n]);
trace("N :"+n);
trace("HOMEX :" +this.homeX);
}
}
_root.createEmptyMovieClip("menuChecker1", _root.depth++);
menuChecker1.onEnterFrame = checkHomePos;
Ok I have a variable n which holds a number. Now I want to find the x position of the mc bgPn
All my bgP clips are named bgP1 to bgP20 so I want to be able to us the number in n to add on to the end of bgP so it will represent the bgP clip I need.



KirupaForum > Flash > Flash 8 (and earlier) > Flash MX
Posted on: 11-11-2002, 01:03 PM


View Complete Forum Thread with Replies

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

Adding A Number At End Of Variable Name
Hey all,

i hope that this is a really easy problem to sort out. I want to be able to add a number dynamically at the end of a variable. This code work fine at the moment;

_root.orderItem1 = _root.itemTitle[0]
_root.orderPrice1 = _root.itemPrice[0]

orderItem1 and orderPrice1 are displayed in a text box. However I want to be able to add a number at the end of the variable name based on another variable named _root.orderNumItems

so the 1 and [0] values i want replaced with the number stored in _root.orderNumItems (the 0 will obviously be _root.orderNumItems-1)

I thought i could just write

_root.orderItem[_root.orderNumItems] = _root.itemTitle[_root.orderNumItems-1]

but flash doesnt like it, please help me as i dont want to just write the code hundreds of times over for each number,

cheers

griff

Adding A Number To Make A Variable
Hello,


I've got a small problem and its annoying me because i dont know what to do!


ActionScript Code:
var xmlName1 = "number1"
var xmlName2 = "number2"
var xmlName3 = "number3"

var NameNumber = 2


something_txt.text = xmlName+NameNumber

instead of reading out, "number2" i get NaN, i know why, just i dont know what else to do to make it work.

Can somebody help!!!!!!!!!!

Thankyou

Adding Or Subtracting 1 Or Any Number To Your Variable.
_level0.book.gotoAndStop(_level0.page++);

I have my input field called page that I type a number into it and it will make the book movie instance goto that frame number thats in the page input field. Problem is that the frame it goes to is 1 less than the frame i want it to go to.

If I type in 5 in the input field, it makes the book movie go to frame 5 but I want it to go to frame 6 so I am trying to add 1 to it.

Also how would I make it go 1 less.

Also what ever number less or more I want it to go to. Like 6 more than whats type in the page input field.

Thanks

Using Eval Function And Variable In A Path (target Path)
Hello,

I have to reprogram some of my website and it calls to conjugate strings in a way that's beyond my understanding. Please help me with some suggestions. Kind regards.

the original code is:

code:
if (_global.useCount<10) {
//hide
var diff = 10-_global.useCount;
for (diff; diff>0; diff--) {
eval(String(11-diff))._visible = false;
}
}

There are buttons named 1 to 10 and this turns off the ones that are not used. Now I want to nest those buttons in subclip "buttonsRow", instead of having them on main timeline. How do I rewrite that code to make it work with new path?

I have already tried the "associative array" method, but it don't really know how to pack the whole eval function in there. I've tried many combinations, like:

code:
this.buttonRow[eval(String(11-diff))]_visible = false;
//or
this.buttonRow["eval(String(11-diff))"]_visible = false;
//or
buttonRow[eval(String(11-diff))]._visible = false;
//or
buttonRow["eval(String(11-diff))"]._visible = false;
//or
buttonRow[eval(11-diff)]._visible = false;
// or
buttonRow[8]._visible = false;
//the last one at least turns off button 8, lol

Some of those return syntax error and some just don't work. Anyone have any ideas? Thank you again.

Random Number Variable That's Different From Previous Number
I have this line of code in my game that works great. However it would work even better if when it the code was executed the next random number was not the same as the one before it. For example if "speech" is on frame 6 when the code is executed I would like the random number to be between 2 and 12 but not 6. (I don't want the same frame to come up as it confuses the kindergarteners and preschoolers using the program.) Here's the code that's working for me now.


ActionScript Code:
speech.gotoAndStop(Math.floor(Math.random()*11)+2);

Getting The Number From A Path Name
Hey guys,

I'm trying to write a bit of code to extract the number from the end of a path string.

The path would be something like: _level0.myInput29

What works now is:


ActionScript Code:
focus = Selection.getFocus();
var myTextNumber:String = new String (focus.substr(15));
var myTextField:TextField = eval(focus);

The thing is, if the path name changes in length (e.g. if the SWF gets loaded into another SWF) this code won't work anymore because the substring index will be much greater than 15!


ActionScript Code:
//Extract the number from the inputText field in focus
    var fieldString:String = new String(Selection.getFocus());
    var fieldArray:Array = new Array(fieldString.split("."));
    var nameString:String = new String(fieldArray[1].toString());
    trace(nameString); //Returns undefined
    trace(fieldArray); //Returns _level0, myInput31
    trace(fieldArray.length); //Returns 1

How can I get this to work?

Variable Path Name --> Path=_root
instName="inst1";
path="_root";

Element.prototype.setVisible = function(){
[path+"."+instName]._visible=true;
}

I am trying to build a variable path to an instance. Normally I would do something like this[var]._x, but this doesn't work with _root.

Any ideas?

Variable Number = Frame Number#$%@&*
I have a movie Clip called “percentage bar” and a variable text box called “percentage”.
Now I get a number from VB and this number is = to the value of ”percentage” (my variable txt box).
The Movie Clip has a 100 frames… here it comes I need to have whatever the variable number (“percentage”) is to determine which frame the movie clip (“percentage bar”) is standing on.

This has to be possible, don’t it?

Variable Number = Frame Number ?
Here's an easy one for anyone who knows actionscript...
I have a variable text box called "percentage" and a movieClip called "progressbar" (100 frames).
I want the number in my variable txt box "percentage" to tell "progressbar" to go to the corresponding frame number.
for instance if the number in the txt box is 15 the movieclip has to go to frame 15.

Thanks
- a Designer, forced to be a programmer.

Variable Take On Content Of A Root Variable And Not Its Path - Simple Please Help
Hi there ok my brain has died and fallen off somewhere , what i am trying to do is this:


l=0

l++


_root.advert= "_root.var" + l ;

then i have a text box on stage , dynamic, etc var: _root.advert
, vars are stored in a text file , vars are called, var1, var2 etc , text box needs to display variable contents, but at the moment it just says "_root.var1" etc and not the content s of var1 this is very simple problem but my brains dead please help.

-arran

Adding A Number To A Value
hi , im trying to set a variable like so :

xPlace = _root.musicPlayer.volumeChanger.volScaler._x + 2.4

however ,istead of getting a nubmer i get a string : -4.44089209850063e-16

now since the X of the element im using is 2.4 i expcted xPlace to be a zero,
i noticed that i can use such statement with true numbers however not with numbers like 2.5 and 5.6 ...

how DO i write it down so it will calculate the experssion currecly ?

Adding 1 To A NUMBER
Hi. I want to be able to add/subtract 1 to a number that is in a dynamic text box, when the user presses the up or down arrows (up to add down to subtract). I know how to control the up and down arrows, my problem is adding 1. I can't seem to mathematically add 1... I can make it so that when the user clicks the up arrow, it adds a 1 to whatever was in it before, so basically, if the contents was 02 before, it would turn into 021... But I want it to go from 02 to 03, or 02 to 01! HOW CAN I DO THIS?!?!
Any help is GREATLY appreciated!!

Thanks,
Sportzguy933

Adding Number
i want a textbox to start out with the number 100000
and then on frame 2 it adds 1 to the number
so everytime i go back to frame 2 it adds another number...

also, does the textbox need to be dynamic, static, or input???

Sting Variable To Mc Path - VARIABLE TYPES
Hey all Im building a variable like this

var m = "_root.subNav.subNav" + i;

When I do a trace to find the var type it comes back as a string so my function wont execute thinking it is a string and not a path. Does anyone know how to fix this or change the variable type on the fly in AS 1.0? Ive tried:

var m =eval( "_root.subNav.subNav" + i);

But that came back undefined....
Thanks.

Number Adding Issues :/
y is it that with this code:
var x = 2;
var y = 2;
var z = x+y;
output.text=z;

the number in the output.text field will b 22
and how do i fix it so that it says 4?

Adding Number Vars
Code:
function loadIssueBody( section:Number ) {
trace ("section "+section);
for (i=0; i<issueSectionContent.length; i++) {
this.txt.htmlText += "<a href="asfunction:loadIssueBody,"+(Number(section)+1)+"">Next Page</a>";
}

Quote:




Not working. Its actually just appending teh number - like 1 becomes 11. or 0 becomes 01. Any ideas?




works. (Number(section) did it.

Adding With A Number Array
I have an array, strictly numbers, how could I add...
say array[0](value=2)+array[1](value=1) to equal 3? What I come up with is an undefined error, or not a number...


Thanks


-TJ

Number Variables Not Adding Up
Hi



I’m using loadText function to grab some variables from a php file, the problem is the variables are coming in as strings and so when I try and use them in an addition they’re just sticking them on the end rather than adding the two values together?



Is it possible to declare a _global variable as a number?



Cheers

Adding With A Number Array
I have an array, strictly numbers, how could I add...
say array[0](value=2)+array[1](value=1) to equal 3? What I come up with is an undefined error, or not a number...


Thanks


-TJ

How Do I Convert A String Variable Into A Number Variable?
How do I convert a string variable into a number variable?

Thanks in advance.

Garry

Adding Child At Certain Frame Number
Dear users,
I want to addChild at certain frame say 130.
And I used the following format

var btn1:Button = new Button();
gotoAndPlay(1);
addings();
function addings():void
{
if(MovieClip(theRoot).currentFrame == 130)
{
trace(" Frame 130");
addChild(btn1);
}
}


And I can't get the output and even I can't get the trace result
Please help me how to add childs at any frame number I want

Adding And Substracting Number Variables?
hi, I've got a question
If I want to add or substract number variables, how can I name them to indicate they are numbers and how can I do basic math with them?

If I try adding common variables like
_root.answer = _root.var1+_root.var2;
and if var 1 is = 1
and var 2 is = 2
The answer is 12 not 3

so... ? help!

Adding And Substracting Number Variables?
hi, I've got a question
If I want to add or substract number variables, how can I name them to indicate they are numbers and how can I do basic math with them?

If I try adding common variables like
_root.answer = _root.var1+_root.var2;
and if var 1 is = 1
and var 2 is = 2
The answer is 12 not 3

so... ? help!

Adding A File Path To A .load Command. How Would I Add It?
Ok, so i have a project that i am working on, and it calls a file from the same location that the MC is stored: myVars.load("test.txt");

But instead of having it only calling from the same level that the MC is stored, I want to call it from a different file path.

Is there a way to add a file path to: myVars.load("test.txt");
Do i have to add an extra line or add the path in front of the file name?

Adding An Automated Version Number On Compile
Hi there,

I'm currently working on a Flash based internet application that customers subscribe to. We have been looking into possible ways of adding a version no. to the application at compile time - this way we can track which version people are currently using.

Has anyone got any ideas on how this could be possible? Most things that I have tried change on run-time and we really do need something that will be set in concrete (at least until a developer next compiles a new version).

I'm trying to get away from having to manually add a version number (as most developers will probably forget to change it each time) - keeping it automated would be so much better.

Any suggestions would be great.

cheers

the whippet

Adding A Text Field To A Number Of FLA Files
I have a number of SWF and now I need to add an entry text field to all of
them.
I do not want to find myself creating a text field in every single FLA
I wonder if I can create in, say, in an .AS file using something like
createEmptyMovieClip and then include it into relevant FLA?
Or what other solutions are available?

Adding Unknown Number Of Files To An Array
Hi,

I'm wanting to populate an array with all files in a specific folder without knowing the file names or how many files there are.
Is this possible?

thx

Simple Rookie Question: Adding Variables To Number
hi,

this might seem to simple for anyone to ask but i just dont know it:


i have to gather a few numbers from several input-textfields and add them together to get the total number.

but if one or more input-fields are not filled out, the value of that field turns to 'undefined' and i cant add them values anymore.

how can i add only the number together and leave the undefined fields out of this equation?



ActionScript Code:
var minQuantity:Number = Number(sizeXS + sizeS + sizeM +sizeL + sizeXL + size2XL + size3X);

trace(minQuantity);

please help me out

Variable Path
hello
i have a movie clip with only one frame in it and it has a dynamic text box whose variable name is t1.The main timeline also has one frame which contains instance of that movie clip named as mc1 and also has another dynamic text box named v.in that frame i had given
v=_root.mc1.t1 to display the value of t1 in MC in the text box v.I had also tried v=_level0.mc1.t1.But noone displays the values in the textbox v.

whats the problem in that

bye
geethanandh

How Can I Use A Variable In A Path
i have a loop counting i up to the number of objects i want to scale. Is it possible to use a variable that's based upon a prefix and the number i as suffix in the path to object that is supposed to be scaled.

here's my code(variable(thing) is ok path is not working):

thing = "obj" add i;
// here is something wrong
_parent.thing._width = newsize;
_parent.thing._height = newsize;

thanks for your help!

Path To Variable
I want to set a path by having a variable dictate the path... having problems with the syntax:

dynamicNum = _root.somevar;

//this is the path depending on the dynamicNum brought back the path will change. not sure if this is the way to concat the dynamicNum...
well it must not becuz it does not work any ideas on the syntax?


_root.screenAtty + dynamicNum.popuptext.click=0;

Path As Variable
Objective
What I am trying to achieve is this. 20 buttons (dynamically generated). Each button displaying an external jpg which it loads into a picture viewer (this I have achieved). On clicking each button information about each of the pictures is loaded into a textfield from an external txt file (this I cannot achieve)

What I am Doing
I am loading 20 variables “picinfo1” to “picinfo20” from an external txt file “myData.txt”

Each of the variables contains text such as “my picture one” etc

I am dynamically generating buttons (within an mc) based on the number of variables in the txt file ie. 20

I have a textfield component called “textViewer”

If within the original button if I add the code _root.textViewer.text = picinfo1, the textViewer is populated by information stored in that variable is (obviously all the buttons display the information stored in that particular variable)

Using the looping function that I have to dynamically create the buttons I have a variable “infoCount”

When I add the following code
_root.textViewer.text = “_root.picinfo”+ infoCount - the text field just displays _root.picinfo1 , _root.picinfo2, _root.picinfo3 etc but NOT the information stored in those variables

It seems that it is being interpreted as a string NOT as a path. Is there any way that I can make Flash recognise “_root.picinfo”+ infoCount – as a path NOT a string

Sorry if this is a little confusing

paul

Using A Variable With A Path - Help
Hi there.

I know how to use a variable to reference an instance on the same timeline, like this (variable is inState):

this[inState].gotoAndPlay("rollOut");


but how would it work if i had to reference something along a path? would it be like this?:

this[_parent.InstanceName.inState].gotoAndPlay("rollOut");

Kinda confused! any help appreciated.

thanx!

S

[CS3] Variable In Path
Hi I want to do something like the following code but it doesn't work:


Code:
var page = "present" ;

mainframe.page.gotoAndPlay(2) ;


mainframe is a MovieClip object and so is present.

I want to be able the change the variable so I can play different movies/pages

Variable Path?
Hi guys, i need some hellp...
Lets say i have a variable on the _root level, in the first frame

_root.a = 0;
trace(_root.a);

This will output 0.
Now in the same frame i have a moviclip (movie_a) and within that a nother movie clip (movie_b)
if i put the following code in movie_b

trace(_root.a);

i get Undefined as my output...
Can anyone please help me in this matter?
Thank you
~Gabor

Using A Variable In A Path
I'm curious why this doesn't work.


ActionScript Code:
var whereTo = _global.addressDestination;
addressSubmit.onPress = function(){
trace(_global.addressDestination); // traces address_1_txt which is correct
_root.front_mc.whereTo.text = myAddText.text;
}

whereTo traces, so why doesn't it work?

Thanks!

Variable Within Path And More -please Help
something's fishy here. guess i'm seeing not the right path after staring at it too long:

i'm having some working functions that load external pics.
everything works but now i need to convert the filenames of the images into variables.

loadImages(thumbs, "images/pic14.jpg", 76.2, 266.4);

works. BUT


ActionScript Code:
picname = "pic14";
    loadImages(thumbs, "images/[b]picname[/b].jpg", 76.2, 266.4);

not! what am i doing wrong? i tried all [] {} and whatnot....
do i need to define the variable as expression? i'm stuck.
please help!

Put A Variable In A Path ?
Hello all,

I cant figure out how to out a variable in a path.

these ares the "fixed" paths i have now

_root.alpha[var1 + "_movieclip"].label
_root.betas[var1 + "_movieclip"].label


What i want is to replace "alpha" and "betas" by a variable "var2"

any help is welcome,

Regards,
Peter

Using A Variable In A Path
I'm curious why this doesn't work.


ActionScript Code:
var whereTo = _global.addressDestination;addressSubmit.onPress = function(){    trace(_global.addressDestination); // traces address_1_txt which is correct   _root.front_mc.whereTo.text = myAddText.text;}


whereTo traces, so why doesn't it work?

Thanks!

Using A Variable In A Path?
Hi people,

I'm currently kinda stuck on an app Im developing.

I want to use a variable within a path.

Lets say my var's name is "i" and it consists of a number that will be changed.

So its basically var i = 0 and in a loop it says i++

Now I want to target this var in a path.

Lets say app."textfield"+i.text = "test"

That actionscript is wrong, but it's there to give you an idea of what I'm trying to accomplish.

So basically: how do I target an object with a variable path?

Need To Add Variable To Path Name...
So I have a button that occurs throughout the entire movie on the main timeline. I'm declaring a variable on each frame, so if you hit that button on that frame, it should take that variable and use it in the path to something I wanted turned on via _alpha = 100.

So, I want it to be something like:

on (release)(
_root.movieContainer. + "The variable" +.thingToTurnOn._alpha = 100;
)

So, I've never done this before, and I don't know where to begin, I just know that I want that variable I declared on the main timeline to be used in that path when the button is clicked.

Xml Path As Variable?
I am trying to create an xml based site navigation that will drill down to an infinite number of xml levels. I have tried to send an xml path as a variable with the currently selected menu item but I doesn't seem to work. Here is my code, it seems as though it should work, but it does not. Any suggestions?


Code:
var nodeList = [];

var xmlSource:XML = new XML();
xmlSource.onLoad = function(success:Boolean):Void {
if (success) {
xmlRoot = xmlSource.firstChild;
xmlnodes = xmlRoot.childNodes;
total = xmlnodes.length;

for (i=0; i<total; i++) {
nodesHolder.attachMovie("node","node"+i,i);
nodeList[i] = nodesHolder["node"+i];
nodeList[i].xmlRoot = xmlnodes[i].firstChild;
trace(nodeList[i]. xmlRoot);
nodeList[i].name.autoSize = true;
nodeList[i].name.text = xmlnodes.attributes.name;
nodeList[i].onRelease = function() {
showCurrent(nodeList[i]);
};
}
resetLayout();
} else {
trace("XML Not Loaded!");
}
};
xmlSource.ignoreWhite = true;
xmlSource.load("nodes.xml");

function showCurrent(current) {
trace("Showing Current Node: "+current.xml);
currentCenterX = 0;
currentCenterY = 0;
xmlnodes = current.xmlRoot.childNodes;
total = xmlnodes.length;
trace(total);
nodeList = [];
menuItems = total;
angle = ((360/menuItems)*Math.PI/180);
radius = 250;
for (k=0; k<total; k++) {
current.attachMovie("node","node"+k,k);
nodeList[k] = current["node"+k];
nodeList[k].xmlRoot = xmlNodes[k];
nodeList[k]._alpha = 100;
nodeList[k]._x = Math.cos(angle*k-45)*(radius);
nodeList[k]._y = Math.sin(angle*k-45)*(radius);
}
}

Using A Variable In A Path
I'm curious why this doesn't work.


ActionScript Code:
var whereTo = _global.addressDestination;addressSubmit.onPress = function(){    trace(_global.addressDestination); // traces address_1_txt which is correct   _root.front_mc.whereTo.text = myAddText.text;}


whereTo traces, so why doesn't it work?

Thanks!

Path & Variable
I have been trying different ways to put variable into a 'do' sentence (the variable is a path), but I haven't been able to do it... here's the AS Code... Anyone could give a little help with that.


ActionScript Code:
do {
      u = 0;
      nombre = new Array();
      chain = "nombre" + u;
      ruta = "colector." + chain;
      this.ruta.text = aNombre[u]; //the problem
      u = u + 1;
               }while (u == vTotal)


TnX a lot..

Using Variable Within Path?
I want to set a path by having a variable dictate the path... having problems with the syntax:

dynamicNum = _root.somevar;

//this is the path depending on the dynamicNum brought back the path will change. not sure if this is the way to concat the dynamicNum...
well it must not becuz it does not work any ideas on the syntax?


_root.screenAtty + dynamicNum.popuptext.click=0;

Thanks.
GR

Variable In A Path
Can anyone give me some help.

Original code.


Code:


Thumbnailgrid.thumb4.thumb.loadMovie(baseurl+"images/hallimages/thumb/4.jpg");



I have added a variable to the call:


Code:


Thumbnailgrid.thumb4.thumb.loadMovie(baseurl+"images/hall/thumb/" + varx + "4.jpg");



That works fine.

How would I add a varible to:

Thumbnailgrid.thumb4.thumb

^Replace thumb4 with variable: varx



Thanks

Number Variable With XML?
Hi,
I am a beginer in importing XML into flash, and I need a little help. I would like to write a number in an XML document and use this number as a variable in AactionScript. Is there a way that it can be done?
Thanks.

If (variable < Number) { //help }
Okay, I'm trying to make a lives system. Here's what I have:

if (_root.lives < 1) {
gotoAndPlay("gameover")
}

It needs to go to frame labeled gameover, but it's not working. Anyone have any idea what the problem is? NOTES:

'lives' is defined as 3 at the start of the game.
Lives system is fully working except for this one little flaw.

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