Dynamic Variables As Field Names For Events?
My second week of using Flash so please excuse my ignorance.
I am trying to take a dynamic text variable “mcname” and insert it into a button that toggles on/off the visibility of a Movie Clip of the same name.
I cannot get the variable inserted correctly into the call. Basically it looks like this.
on (press) { this._parent._parent.”mcname”._visible = true; }
And I continue to get the Error: “Expected a field name after '.' operator.”
Ive searched the web trying to discover how to use variables as field names, but cannot find the proper coding. Any help would be greatly appreciated. Thanks
ActionScript.org Forums > ActionScript Forums Group > ActionScript 1.0 (and below)
Posted on: 03-18-2006, 04:19 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Dynamic XML Variables As Field Names In Events?
My second week of using Flash so please excuse my ignorance.
I am trying to take a dynamic text variable “mcname” and insert it into a button that toggles on/off the visibility of a Movie Clip of the same name.
Issue of correct code to call the variable. The actual value of the "mcname" (which is being pulled from XML doc with value "testvis") is not working as a movie clip name in the field name position.
I am trying to get this:
on (press) {
_root.['mcname']._visible = false;
}
To function like the standard hand coded:
on (press) {
_root.testvis._visible = false;
}
I have a menu that is being built dynamically with XML and want to pass a childnode value (in this case "testvis") to the buttons that turns off/on movie clips of same name "testvis".
simple SWF of attached FLA example here: http://www.mediaoutsource.com/flash/
If anyone can help i would greatly appreciate it.
Field Names & Variables Issue
I'm having a problem filling out my text fields correctly with the externally loaded variables from a text document. I have 336 text boxes within 2 movie clips (called "map" and then "map2") on the main stage. Each text box has an instance name. I am trying to assign them dynamically with a for loop so that I don't have to type out the two lines of code to assign and format each text box 336 times (a total of 672 lines of code!)...
The text fields are all following the naming convention "lot1", "lot2", "lot3", etc. So I'm making a string variable called "curri" and assigning it the text equivalent of "i" in the loop, and creating a variable called currLot to which I am than appending the string "curri".
The problem is I have to point to the correct field name with my variable every time the loop repeats, but I can't figure out how to use a variable as a field name. In the code below, it is actually just looking for a text field with the instance name "currLot", rather than assigning the variable to that field and looking for it that way. Make sense? How do I do this? It must be possible, but can't find any documentation on it. I tried using the String operator in the field name, but that doesn't work, and I tried a few other things with no success. My code is below, THANK YOU!
for(i=0; i<336; i++) {
curri = String(Number(i));
currLot = "lot"+curri;
_root.map.map2.currLot.htmlText = _root.lotInfo.currLot;
_root.map.map2.currLot.setTextFormat(txtFormat);
trace("wrote lot number" + Number(i));
trace(currLot);
}
Using Dynamic Variables Names
I have a list of variables loaded from a MySQL database. I can access them from my nested MC if I type in the exact variable name like this:
Code:
on (press) {
trace ("word3 = " + _parent.word3); // good!!
}
But I can't access them using dynamic variables. I've included my code showing how I've tried to access them along with their respective responses.
Code:
on (press) {
_global.i = i++;
trace("_global.i = "+i++);
//trace("word3 = "+_parent.word+i); // undefined
//trace("word3 = "+_parent["word"+i]); // no
//_parent.answer = _root["word"+i]; // literal string =[
//_parent.answer = eval("word"+i); // undefined
// _parent.answer = eval(word+i); // NaN
//trace("answer = "+(eval("word"+i))); // LOCK UP!
trace(_parent.answer);
this.gotoAndStop(1);
}
Thanks in advance.
AS2 : Using Variables As Array Names/ Dynamic Array Names
Hi,
Hoping someone here can help me with this problem:-
This code works (as part of a loop):-
attachMovie(x1r1[i], "Aln1" + i, i);
where x1r1 is the name of an array which gets cycled through.
However, this array name will change on a new level, (lvl) so what I really
need is something that works like this:-
lvl = 1;
var ex = "x"+lvl"+r1"
attachMovie(ex[i], "Aln1" + i, i);
However flash does not see ex as equal to "x1r1" for the purposes of
using it as an array name. Not even if I use "eval".
Any suggestions?
Thanks
Michael.
Dynamic Text Field Receiving Dynamic Variables...
or something like that . . .
This is my problem: I'm generating _global variables via XML. Each variable represents different types of copy, of varying lengths. For Example:
_global.introduction = xmlDoc_xml.firstChild.firstChild.nodeValue;
_global.body = xmlDoc_xml.firstChild.firstChild.firstChild.nodeVa lue;
_global.summary = xmlDoc_xml.firstChild.firstChild.firstChild.firstC hild.nodeValue;
I want to create ONE text field, with scrolling, that will act as a template to house all types of content. I've assigned a variable that equals "content" to this text field. . . My problem is, I can't get the text field variable (content) to dynamically swap for the global variable (_global.introduction) in order to display the proper content.
This seems simple, but something's not working for me. Any thoughts? . . . BIG thanks in advance!
PHP Display Variables In Dynamic Txt Field
Hi I have a question can anyone help me out?
This is the result from a phpfile:
a0=What I am&b0=Edie Brickell&c0=Pop&d0=Sound1.swf&a1=Many men (wish death)&b1=50 Cents&c1=Rap&d1=Sound2.swf&a2=Last to know&b2=Pink&c2=Rock&d2=Sound3.swf&a3=Hardcore vibes&b3=Dune&c3=House&d3=Sound4.swf&a4=Stressed out&b4=Tribe called quest&c4=Rap&d4=Sound5.swf&
I load this into flash using:
myVars = new LoadVars();
myVars.load("http://blahblah/audio.php");
I have a dynamic textfield with an instance name called: content
What I would like to do is control the contents of this textfield.
How can I display one of the variables in this textfield? I tried several things but I just can't get it to work, so any help would be great
Dynamic Text Field Variables
Folks,
I have a movie where a variable named daysleft will be loaded from an external text file into a dynamic text box, this bit works fine.
But I then need the movieclip "numbers" to gotoAndStop to the frame number imported via the variable daysleft. Although daysleft displays on the screen a trace(daysleft); says the variable is undefined.
Any idea how I can acheive what I'm trying to do.
Cheers all.
Problem Getting Variables To Display In Dynamic Txt Field
I am passing some variables from PHP into Flash using the following ActionScripting:
//load PHP variables
PHPvariables = new LoadVars();
PHPvariables.Load("variables.php");
username = PHPvariables.username;
I then want the variable 'username' to be displayed in a dynamic text field I've given the variable name "events". I used this ActionScript to do it:
//fill events text box
_root.events = username;
However, the dynamic text box is not displaying anything. Any ideas why?
My Dynamic Text Field Wont Load The Variables
ok i know this sounds n00bish..but how should i go about loading text form an external file into a dynamic text field..ive attempted to do this but it doesnt seem to work right..i did it "by the book" and it still wont work..and even if i dont check the HTML box nothing pops up in the dynamic text box...can somebody plz explain the process to make this go smoothly..like where to put (i.e. specific frame) the actions to load the variables..thanx
Trouble Loading Variables To Dynamic Text Field
I am trying to display text from a text file named units.txt (stored in the same folder) The swf has a dynamic text box called myText. The swf has buttons with this code:
on (release) {
_level0.myText = Unit1;
}
The first frame of the movie has code like this:
loadVariablesNum("units.txt",0);
(I have tried including the entire url as well as just the folder above)
This works fine when I test the movie. It also works when I test it through the index.html (on my computer). But it does not work on my website.
Does anyone know what I am doing wrong?
[CS3] Populating Dynamic Text Field With Multiple Variables
I have a Dynamic text field that is pulling in data from an external txt file. My txt file has multiple variables. Everything is fine with the txt file and loading any one of the single variables, it works fine. My questions is...
- When the movie starts I need the dynamic field to load the first variable [txt file: text=My first variable] then...
-I have three buttons and when rolled over I want the text field to replace the current variable with whichever buttons variable is rolled over, once the user rolls out I want the original [variable 1] to reappear in the dynamic text field.
For example...
onLoad, display variable 1.
onRollOver btn1, display variable 2.
onRollOver btn2, display variable 3.
then, on any rollOut go back to variable 1.
I have been having an unusually hard time getting this to work, ANY help with this would be greatly appreciated, thanks
Load Multiple Variables In One Dynamic Text Field?
Hello!
Is it possible to load multiple variables in one dynamic text field?
For example, this is in my text file:
var1= bla bla bla
&var2= bla bla bla 2
&var3= bla bla bla 3
I have a dynamic text field with the var-name ‘vartotal’.
Var total should be:
vartotal = var1 + var2 + var3
How can this be done?
Passing Dynamic Variables To Flash Text Field
Hello,
I want to pass a variable from a URL to a text field in my flash movie.
The variable that I'm passing will always be different, and I need it to load in the dynamic text field i have in flash.
this url:
www.myurl.com/mySWF.swf?code=2003
should send "2003" to a text field in my flash movie.
Any idea how to do this? I've searched all forums and couldn't find anything this specific.
Thanks in advance,
Josiah
EXTREMELY URGENT - Creating Global Variables Using Names Of Other Variables...
I have variables xtile and y tile within a movie, and I need to create a global variable that will tell all other movies that this particular movie is situated on tile [xtile][ytile], so I need to know how to create the global variable: _root.objectmovie_xpos_xtile_ypos_ytile = true;
I know how to create global variables, and how to have other movies read them, but how do I actually create a VARIABLE with this name? I tried set ("_root.objectmovie_xpos_" + xtile + "_ypos_" + ytile") = true, but that doesn't work (which I kinda knew already but thought I would give it a shot)
any ideas peeps?
please help, its vital to a project I am doing
cheers all
Field Names
Hey, right now I am we're using Flash remoting and they are returning values as their actual column names inside their DB, is that something I should be worried about?
For Example:
Code:
SELECT fname, lname, age FROM peopleTable WHERE id=12
In Flash it is getting the actual DB column name:
ActionScript Code:
var getPersonInfo_Result(msg:ResultEvent){
var returned :Object = msg.result;
for(var i=0; i<returned.items.length; i++){
var rs :Array = returned.items[i];
/* it is returning them as the column names */
var firstName:String = rs.fname;
var lastName:String = rs.lname;
var age:Number = rs.age
}
};
I only just realized this (they didn't mention it to me until I saw the cfm file). Unfortunately it would be a pretty big undertaking for me to change all the properties inside of the Class that stores all of these values. However, if it is a security breech, then it is just going to have to be done.
Should I be worried about that? Meaning, that isn't a security breech or anything is it?
DataSet Field Names
I have a DataSet component that I have loaded with arrays, that I need to send back to the server/database. The problem I'm having is in matching up the column names in the database with the data in the arrays. I've binded the DataSet to a DataGrid (temporarily) for output. I've loaded the DataSet by code as follows:
myDataSet.addItem(position1_array);
myDataSet.addItem(position2_array);
myDataSet.addItem(position3_array); ect...
Each array holds a players name, id, and scores for each match they played in a tournament. The typical output I'm getting in the DataGrid looks like this:
(not code)
Code:
5 4 3 2 1 0
___________________________________________________________________________________
5 7 7 John Doe 416
4 7 Mike Taylor 063
7 7 7 7 Dave Jones 251
Which is, of course, the contents of the DataSet. The column labels show the arrays' position number, rather than the field names that I need them to represent in the database. Notice also, that the arrays' items are listed in reversed order (column 5 - 0).
Now all of this so far, may be ok... I'm not exactly sure. The database fields for the example above are set up as follows:
Code:
PLAYERSID NAME MATCH1 MATCH2 MATCH3 MATCH4
_______________________________________________________________________________________
416 John Doe 7 7 5
063 Mike Taylor 7 4
251 Dave Jones 7 7 7 7
I've tried setting up the field names to match that in the DataSet Schema, but it wont take the data from the arrays then.
I'm not sure what I need to do here. (or if I need to do anything at this point )
From there I'll bind the DataSet component to a RDBMSResolver; RDBMSResolver to a WebServiceConnector; write the code to update the database in a ColdFusionComponent...
Is there anybody with experience using the DataSet & RDBMSResolver components that could help?
Also, if someone could show me how to set up a loop, that could pass the array data back to it's proper field name, before it's loaded into the DataSet component. That might help, too. Thanks.
Text Field Instance Names
here is my dim newby question: In flash MX, when working with dynamic text, you can use the properties panel to enter a value in the "variable" field. There is also a field for the "instance name". As far as I can understand, to access that particular text field you use the variable name in your script. When would you need an instance name for dynamic text?
Trouble With Paths, Field Names Etc
I'm trying to set up a preloader for my movie, and I'm having some trouble with paths etc. My main timeline has two movieclips, one for the preloaded content, and one for the preloader. The instance name of my content mc is ycmovie, so I've used the code below to try to access the loading details. My preloader mc contains the following:
Code:
total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
_root.ycmovie.ifFrameLoaded ("loaded") {
_root.ycmovie.gotoAndPlay("moviestart");
}
Whenever I preview I get the following message:
**Error** Symbol=loader, layer=as, frame=1:Line 7: Expected a field name after '.' operator.
_root.ycmovie.ifFrameLoaded ("loaded") {
I assumed the field name was the instance name? But obviously I'm using incorrect syntax in the path. Can anyone help me out here?
XML Field Names With Special Characters
I want to be able to generate an XML file in actionscript that I can open with excel, so I have made a small spreadsheet in excel and saved it as an xml file and am sort of reverse engineering it.
The problem is the root node of an excel spreadsheet has field names with colons in it, how can I use actionscript to create these fieldnames. It currently throws up an error because some of the field names have a colon in them.
Here is the root node of an excel spreadsheet to illustrate.
Code:
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">
I tried creating a string variable with the colon in it called temp and then use this variable as the attribute, but that does not work. Doing that just creates a field name called temp,
Trouble With Paths, Field Names Etc
I'm trying to set up a preloader for my movie, and I'm having some trouble with paths etc. My main timeline has two movieclips, one for the preloaded content, and one for the preloader. The instance name of my content mc is ycmovie, so I've used the code below to try to access the loading details. My preloader mc contains the following:
Code:
total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
_root.ycmovie.ifFrameLoaded ("loaded") {
_root.ycmovie.gotoAndPlay("moviestart");
}
Whenever I preview I get the following message:
**Error** Symbol=loader, layer=as, frame=1:Line 7: Expected a field name after '.' operator.
_root.ycmovie.ifFrameLoaded ("loaded") {
I assumed the field name was the instance name? But obviously I'm using incorrect syntax in the path. Can anyone help me out here?
Trouble With Paths, Field Names Etc
I'm trying to set up a preloader for my movie, and I'm having some trouble with paths etc. My main timeline has two movieclips, one for the preloaded content, and one for the preloader. The instance name of my content mc is ycmovie, so I've used the code below to try to access the loading details. My preloader mc contains the following:
Code:
total_bytes = _root.getBytesTotal();
loaded_bytes = _root.getBytesLoaded();
remaining_bytes = total_bytes-loaded_bytes;
percent_done = int((loaded_bytes/total_bytes)*100);
bar.gotoAndStop(percent_done);
_root.ycmovie.ifFrameLoaded ("loaded") {
_root.ycmovie.gotoAndPlay("moviestart");
}
Whenever I preview I get the following message:
**Error** Symbol=loader, layer=as, frame=1:Line 7: Expected a field name after '.' operator.
_root.ycmovie.ifFrameLoaded ("loaded") {
I assumed the field name was the instance name? But obviously I'm using incorrect syntax in the path. Can anyone help me out here?
Multidimensinal Array SortOn() No Field Names
My multidimensional array is created this way :
Code:
cards_array = new Array()
z=0
for(k=0;k<cardsColor_array.length;k++)
{
for(i=0;i<13;i++)
{
cards_array[z] = new Array()
cards_array[z][0] = cardsColor_array[k]
cards_array[z][1] = i
z++
}
}
so the cards_array.toString() looks like (after is mixed): h,10,h,5,h,9,t,7,h,6,r,2,c,7....
Now I need to sort a part of the array(is a slice of this big array not the whole) on first element, or on the second.
All of the sorting algoritms I find, help, livedocs etc... are with named elements.
My question is what is the "name" of cards_array[i][0] element to use in a sorting algoritm...Im to lazy to write my own , and the array is used in too many parts refered this way to start to change all the code to named elements...
Access Text Field Instance Names Dynamically
Hello:
I'm parsing an XML file and have 10 dynamic text fields on my stage.
Named like this: xmlTxt1, xmlTxt2, xmlTxt3....etc. (Creating dynamic text fields would be too difficult with my current layout...I think).
I'd like to loop through and assign each childnode attribute (text and font size) to my next text field name.
Since I can't use a string variable to access my text field names, I'm lost.
Any suggestions would be really helpful. THANKS!
Here's we're I'm at...this loops through my XML file.
myFormat=new TextFormat();
myFormat.size= Number(xmlNode.childNodes[1].attributes.fontsize);
var textFieldName = "xmlTxt";
textFieldName.text=xmlNode.childNodes[i].attributes.textCopy; /* this doesn't work*/
textFieldName.setTextFormat(myFormat); /* this doesn't work either*/
var textFieldName = "xmlTxt" + i;
Events Happening When A Field Loses Focus?...
If I have a field called , say, "text_txt" - is there a way to make it so that something happens (like a goto action or whatever) as soon as the focus goes OFF of that text field?...
Thanks!...
Dialog / Text Field Eating Key Down Events
Hi all,
I have a listener on the stage listening for KEY_DOWN events. I show a dialog (MovieClip containing a TextField). Click a button on the dialog to close the dialog. ("close the dialog" == remove the MovieClip from the display list.)
Now, the stage's listener no longer gets KEY_DOWN events until I click somewhere on the stage. The dialog's text field is getting the key events. (I don't normally add a KEY_DOWN listener to this dialog, but I did as a test to see if it was indeed getting the events.)
How can I get the stage to get KEY_DOWN events again without clicking it first? There seems to be no way to explictly set keyboard focus that I can find.
Responding To Click Events In An Html Text Field
I have a dynamic text field into which I've loaded an html file. In the html file are some links. However my flash program runs in full screen so when you click on the links IE launches and goes to the page but the user doesn't see it at all, cause the flash program retains focus and stays fullscreen. Is there a way to have the program respond to the user clicking on a link and minimize giving IE focus?
Variables As Mc Names
so i have this problem. i am trying to use a variable to tell my movie which movie clip to play--each nav button sets the variable determining which movie clip plays. after clicking a button, several animation type things happen to rearrange the page before the content for the specific section appears.
i have this code on a button in the first frame:
on (release) {
gotoAndPlay(2);
section = "about";
}
then around frame 30 this is in the frame:
section.gotoAndStop(2);
stop();
trace (section);
but then the section never appears. i did a trace and the right variable (about) is showing up. i tried putting the contents of the movie clips in their own frames, and that works, but it would be easier if they were in movie clips instead.
any thoughts on why that isn't working?
Instance Names As Variables
I am trying to have one movie clip give a play command to another movie clip based on a variable set by the previously played movie clip. I can make it work when I put the instance name directly into the script. However, when I switch out the instance name for a variable name it does not work. Is it possible to use a variable in the place where an instance name would normally go? I have tried using Tell Target and dot syntax.
Changing Variables Names
is it possible to change a variable name automaticlly (at desin time)?
i have a var a
i want to change it let's say to iMax, in all the actionscript of the movie.
something like find and replace.
Variables Varible Names
Ok i got a problem, i ll explain briefly my job:
i'm doing a page that can be only reached with a login and pass word... the problem is that my client don't know a single thing in flash and want to be abble to create login and pass word for new user without having to contact me each time.
so i planned to have the L/P stored in an external text file so he just have to had some..... the variable for the l/p are stated like this : log1, pass1, log2, pass2, log3 pass3 etc..... i wanted my clip to scan the login name entered in the field and compare it with the login in the text file. So to achive that i would have to but a variable in my variable name somthing like if log(x) = input go to........ else set x =x+1..... this way all the log are compared one after the other. once the log match one of the log in the txt (say input = log12) flash scan to see if pass12 = inputpass......
well it's the idea... the problem is that i can't manage to insert the variable x (the number of the log ) in my varible name so flash scan all the log(x) varibles one after the other without having to prog them all one by one
anyone knowa way to achive that ?????
Variables For Scene Names
I am now creating a single movie with multiple scenes and have a question on "gotoAndPlay".
In another post someone showed me how to use a variable in "loadMovie" instead of hardcoding which movie to load. The second to the last frame had a "Stop" action and the last frame's action read:
loadMovie(swftoload,0);
The button's action read:
on (release) {
swftoload = "land.swf"
play();
}
This action restarted the loaded movie and loaded land.swf.
I was trying to accomplish the same thing with "gotoAndPlay". The last frame's action is:
gotoAndPlay(scenename,framenumber);
My button's actions is:
on (release) {
scenename = "scene 3"
framenumber = "3"
play();
}
However, I get errors stating that the scenename needs to be quoted. Quoting "scenename" also create errors since there is no scene named "screnename".
Is what I'm trying to accomplish possible? And if so, how?
Thanks,
Robert
Variables And Instance Names
My movie sends data to the database if, and only if, the text is stored in an input text field labeled using the instance name (not the variable name). The fields are on separate frames and then shown altogether as a summary that can be printed. The only way I know how to do that is to label the input text boxes with the variable name. But if I have it labeled w/both the variable name and instance name, it won't send. If I get the user to enter data in the variable named boxes, how can I populate the summary where the text fields are labeled with the instance name?
Thanks
Variables From Instance Names
Hi, I'm trying to finish off a project for today, and I'm caught on this one last thing.
I'm trying to make a dynamic menu. There are 4 instances of the same 'button'. Actually a button inside a movie clip. Also in this movie clip is line of dynamic text that should hold the title of the button.
The variables that hold these titles ("but1", "but2", etc) are saved externally in a text file.
I can load the variables no problem. But how do I call up the variables into that piece of dynamic text?
The problem being, as it's an instance of the same button 4 times, I can't just call it directly. What I was thinking of doing was somehow calling on the instance name of that button ("but1" the same as the variable name) and using
-that- in the dynamic text. So whereever the text is (whether it's in "but1" or "but3") it will call up the appropriate variable according to the instance name of the movie clip it's inside...
... if that makes sense?
Problem being I don't know how to do that?
Any help would be great, thanks.
Variables Into Instance Names
Friends,
Let's say I have three variables:
x=1
y=2
z=3
I also have movieclips in the library called:
mc1
mc2
mc3
I want to attach them, but using a loop similar to the following but I'm not sure if it's possible or what the syntax looks like. Here's the theory:
_root.attachMovie("mc1"; "mc" + x; 50);
Would this attach an instance of mc1 and call that instance "mc1" on layer 50?
Thanks!!!
Instance Names As Variables?
Help please...
I have a textfield named myTextTx and a background that sits behind it named myTextGrow so I made the function below to trigger the myTextGrow effect to be used in a number of texts and backgrounds with my naming covention swapping the Tx and Grow parts of the instance names to trigger the right nnnGrow mc with the appropriate nnnTx textfield.
function txPulse() {
var fieldName = Selection.getFocus();
trace(fieldName);
var growName = fieldName.substring(0, fieldName.length-2)+"Grow";
growName.loopIt = true;
trace(growName); //show the correct instance name with target path
trace(growName.loopIt); //debug shows this as undefined, why?
growName.gotoAndPlay(30);
}
Any ideas why it doesn't work? The loopIt var is declared at the start of the nnnGrow MC and works because it stops at frame 29.
Thanks
Variables In Variable Names & Url's?
Hi, a few things ive been wondering about the use of variables in a few instances...
---- Example 1 ----
Say i have a loop using "Count" as a looping variable, that adds '1' every time. And i have some other variables named "Item1, Item2 , Item3" ect... And for whatever reason, i want to use "Count" in the name of the other variables, "Item(Count)" to access "Item1" when "Count=1"
Another exaple of what i mean is like if i have "Colour = Red" and another variable named "BlahRed" and i want to access "BlahRed" but by using the "Colour" variable in "BlahRed"'s name.
Like "Blah(Colour)=whatever" where of course the "Colour = Red"
What is the correct syntax for that? And i'm not talking about using an array, I just used parenthesis here because i dontk now what you'd really use...
I don't know if it's possible, but there it is.
----Example 2 ----
I know this one is possible.
Say I want to use a variable in a URL like
GETurl(http.com/ "VARIABLE" .html) ect...
Where - VARIABLE = "index" - or something
What's the correct way to accomplish that?
----
Thanks, i hope i explained the first one well enough, it's a little complicated i know. Just ask me if you need clarification
Thanks.
Getting String Names To Be Variables
This is easy for all you gurus' out there, but it would sure help a novice if someone could give me some insight. I need to take a string name and evaluate it as a variable:
For example, if I was in a loop and wanted to make all the movie clips in the loop turn invisible I would think I would write the following if my mc's were content1, content2, content3..etc:
for(k = 0; k<= 5; k++){
"content"+k._visible = false;
}
but that doesn't work. Why does it work to evaluate the name with the count in a loadMovie command like:
for(k = 1; k<6; k++){
loadMovie("tester"+rarray[k]+".swf", "content"+k);
content+k._visible = false;
}
but not in the statement I used. Thanks for helping me.
Variables In MovieClip Names
I'm trying to use a variable in a Movieclip name as seen below but the actionscript reads the line as an object rather then as a movieclip:
Code:
["image" + nowImage + "_mc"]._alpha += 5;
I've also tried like this but it reads the line as a string rather then as a movieclip:
Code:
currentImage = "image" + nowImage + "_mc";
Any help with how I can concatenate a variable and some strings and have the Actionscript read it as a movieclip rather then an object or a string?
Thanks
(They treat objects like women!)
Variables As Variable Names
Hi
I'm duplicating a movie clip like this:
cliplevel ++;
clipname = "clip" + cliplevel;
duplicateMovieClip(car, clipname, cliplevel);
And I want to access a variable inside the clip called myid like this:
clipname.myid = cliplevel;
where clipname is a variable with value = clip24 for example.
Alternatively I need a clip to be able to find out what it's instance name is.
I hope it's reasonably clear what I'm getting at.
Using Variables For Target Names
I already am using the following, which works fine.
code:
varName = "movieClip";
_root[varName]._alpha = 50;
but as I have several movies in the movieClip, ie movieClip.nested1 movieClip.nested2 and movieCip.nested3
I would have thought you could do the following...
code:
// variables set up as follows
varName = "movieClip";
varName_sub1 = varName+".nested1";
varName_sub2 = varName+".nested2";
varName_sub3 = varName+".nested3";
// then called as
_root[varName_sub1]._alpha = 50;
// instead of doing
_root[varName].nested1._alpha = 50;
But it doesn't work. Can someone help me out.
Ta
MovieClip Names In Variables
Flash MX 2004 Professional
GOAL:
I'm loading a list of filenames from an external file into a variable, then splitting the variable into an array (fileArray) with one filename in each array element.
For each element in the array (fileArray[n]), I need to duplicate a movieClip and load an external JPG (from the array of filenames) into the new movieClip.
PROBLEM:
This is where things start to break. On each iteration, the dynamically generated instance name (jpg1, jpg2, etc.) of the newly duplicated movieClip is stored in a variable (clipName).
I have no problems setting properties on the new movieClip using the variable (clipName._x = 120) instead of the literal movieClip name (jpg1, jpg2, etc.).
However, I cannot assign variables within the new movieClip (clipName.varName = fileArray[n]) or load a JPG into the new movieClip using the variable (clipName.LoadMovie(fileArray[n]) OR loadMovie(fileArray[n],clipName))
SOLUTION:
Any guidance you fine folks can give me on how to solve this problem would be greatly appreciated. I've been tearing my hair out and am now completely bald.
Using Variables For Object Names
Here is what I am asking.
Is there a way to make it so you can store an object name in a variable so that you can use a for loop?
for example
for (i=1;i<10;i++) {
currentObject = "object" + 1;
_root.currentObject._height = 100;
}
basicly putting the actual object name (object1 - object9) into a variable called currentObject..... is this possible? If so give an example how to do it.
Variables And Instance Names
I am trying to control my buttons using variables, but I'm not sure if this is right.
On button 1 I have this action:
Code:
on (release) {
portfolioselection = "Monkey"
this.enabled = false;
}
On button 2 I have this:
Code:
on (release) {
portfolioselection.enabled = true;
portfolioselection = "Thornwick"
this.enabled = false;
}
In theory, when Button 1 is clicked it should be disabled. When Button 2 is clicked it should be disabled, and Button 1 enabled. But this doesnt seem to work.
I'm not sure where I'm going wrong here. Am I targetting the variables incorrectly?
PS - I deffinatley need to use Variables because I have lots of buttons, this is just a simplified example.
Thanks,
Jamie
Literal Mc Names From Variables
this has been a long-standing problem for me in AS2.0 (flash 8). in the example below, I have 12 mClips named btn01-12. I cant seem to write functions that address the same script for all 12 in one loop. I've tried a for loop, where the var "btn0"+i yields a string, but it seems that the functions dont evaluate this as a mc instance name.
any ideas/ leads?
lloydie73
---------------------------------------------------------------
//FUNCTIONS
function rollerBtn(immune) {
if ((btn05._rotation == 0) && (immune != btn05) && (currentPage != "about")) {
new Tween(btn05.btnHeadOver, "_alpha", null, 100, 0, 5, false);
new Tween(btn05, "_rotation", null, 0, -67.5, 5, false);
}
if (btn06._rotation == 0 && immune != "btn06" && currentPage != "security") {
new Tween(btn06.btnHeadOver, "_alpha", null, 100, 0, 5, false);
new Tween(btn06, "_rotation", null, 0, -67.5, 5, false);
}
---------------------------------------------------------------
Literal Mc Names From Variables
this has been a long-standing problem for me in AS2.0 (flash 8). in the example below, I have 12 mClips named btn01-12. I cant seem to write functions that address the same script for all 12 in one loop. I've tried a for loop, where the var "btn0"+i yields a string, but it seems that the functions dont evaluate this as a mc instance name.
any ideas/ leads?
lloydie73
---------------------------------------------------------------
//FUNCTIONS
function rollerBtn(immune) {
if ((btn05._rotation == 0) && (immune != btn05) && (currentPage != "about")) {
new Tween(btn05.btnHeadOver, "_alpha", null, 100, 0, 5, false);
new Tween(btn05, "_rotation", null, 0, -67.5, 5, false);
}
if (btn06._rotation == 0 && immune != "btn06" && currentPage != "security") {
new Tween(btn06.btnHeadOver, "_alpha", null, 100, 0, 5, false);
new Tween(btn06, "_rotation", null, 0, -67.5, 5, false);
}
---------------------------------------------------------------
Variables For Clip Names
i have pictures as buttons and when they are clicked the pass a value to a function.
The function is supposed to open certain movieclips depending on what picture was clicked.
What is was wondering is if its possibale to do _root.MovieClip.gotoandplay but use a variable for the movie clip name eg
myClip = "MovieClip1"
_root.myClip.gotoandPlay(2)
Variables With Simlar Names....
OK, I've had this problem for ages. I am using variables with similar names except they are appended with a number:
Code:
trackstring = _root.myTracks.t0;
track0 = new Array();
track0 = trackstring.split("|");
trackstring = _root.myTracks.t1;
track1 = new Array();
track1 = trackstring.split("|");
trackstring = _root.myTracks.t2;
track2 = new Array();
track2 = trackstring.split("|");
trackstring = _root.myTracks.t3;
track3 = new Array();
track4 = trackstring.split("|");
As you can see I am performing an action on variables with names "t0", "t1", "t2" etc. I would prefer to use a loop and counter, possibly like this:
Code:
while (counter < 10) {
trackstring = "_root.myTracks.t" + counter;
//do something with trackstring
counter++;
}
However, this treats trackstring like it's "_root.myTracks.t1" instead of the value IN the variable "t1"...
Can anyone shed any light?
Variables And Instance Names
ok, so i have a little problem. I need to be able to access Dynamic Text boxes inside a loop. For example, assume that there are 6 dynamic text boxes with instance names option0, option1, option2, option3, option4, option5. How can I access them inside a loop? In shell scripting, you would use a '$' in this case.
for (int x = 0; x <= 5; x++)
{
//i need to control dynamic text boxes using the variable x,
//the first iteration would set the dynamic textbox with instance name,
//"option0" equal to "Hello", and so on
option$x.text = "Hello";
}
is such a thing possible?
Trying To Make Mc Names From Variables
I can do this the long way, but am trying to come up with a more precise way of writing this (as opposed to listing functions for multiple buttons). I'm trying to create the mc names using variables. (I want flash to create this mc's with a number added to the end automatically. ) I'm new to this so am stumbling. I commented the ++ out for now just so I can figure the naming out. I think I'm just missing the syntax. Help appreciated!
|