Can Someone Help Me Get My Syntax Correct When Using Variables When Calling An Array?
I have 24 tests total, 6 for each of 4 exams. So I have created arrays with the following names:
exam1test1questions[X] exam1test2questions[X] exam1test3questions[X]
... and so on all the way down to ...
exam4test4questions[X] exam4test5questions[X] exam4test6questions[X]
Okay, so now in the middle of my quiz, I have buttons to set the values of exam and test, for example: exam = 3 and test = 5, and temp = 2 (where temp is the number question I'll be using).
Now I want to use these variables so that it can pull questions from the correct array.
Now when I use this: trace (this['exam'+exam+'test'+test+'questions'].length); It will correctly give me the length of whatever array I'm using.
My problem is, how can I write this so that it will display the contents of a position in the array, for example:
X = this['exam'+exam+'test'+test+'questions['+temp+']'] does not work, while X = exam3test5questions[2] does work.
Can someone help me with my syntax, to make exam3test5questions[2] work using the exam, test, and temp variables? Thanks!!
FlashKit > Flash Help > Flash ActionScript
Posted on: 04-28-2003, 10:19 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Correct Syntax For Variables
I'm trying to do something like this:
ActionScript Code:
var t = 1;onMouseDown = function () {var "dot"+t = "some value";t++;}
whats the correct syntax for declaring a variable thats name changes according to a different variable.
Thanks
Help Figuring Out The Correct Syntax On A For Loop With An Array
Ok the setup is I have 132 movie clips on the stage. Each is labeled m1, m2, m3 and so on. I want to build all those movie clips into an array. So this is what I'm trying to do. If anybody knows why this code won't work or a better way to make this, I would appreciate the help. Thank you.
var screens:Array = new Array();
var i:int;
for (i = 1; i < 133; i++)
{
screens.push("m"+i);
}
----OR----
var screens:Array = new Array();
var i:int;
var count;
for (i = 1; i < 133; i++)
{
count = ("m"+i);
screens.push(count);
}
I know this code is way off. Thanks again for any help.
Correct Syntax For 'and'?
hello boardsters...
i have a preloader which is checking to see if an external txt file is loaded in, by checking for a variable named &eof at the end of it- but it also needs to check if a certain frame in the file is loaded.
so, my code so far says:
if (eof == 1) {
gotoAndPlay ("loaded");
}
how do i phrase it correctly? i want to say, "if eof is loaded, AND frame 20 is loaded, go to..." but i'm pretty sure i can't just stick and 'and' in...
a little help anyone?
cheers m'dears
louise
Correct Syntax ?
Thanks for reading this!
I have an MC on the main timeline named "dance" and another named "dance_control". When "dance_control" is activated it *should* tell "dance" to jump five frames forward from its current keyframe.
Whats wrong with my control script?
_root.dance.gotoAndPlay("_currentframe++5");
Thanks!
Correct Syntax
I'm trying to make this code dynamic.
this.myImageVar = _level0.myMC.myArray3[x];
I want to make the name of the array dynamic so I can reuse the code for other arrays.
Like so:
this.myImageVar = _level0.myMC.myArray + myArrayNum + [x];
What would be the correct format for this?
Thanks in advance
What Is The Correct Syntax?
Hello,
I have a movie clip on a timeline and when the clip finishes playing I want it to point to a specific clip on the main timeline to start playing again.....what is the correct syntax please?
Many thanks
Correct Syntax?
hi, i was wondering if there is anything wrong with the code below. i hav tried every little change to correct it, but it still wont work. i am using actionscript 1
please help!
on (release, releaseOutside) {
/map:scale_target = "150";
/banner:bottom6._visible = true;
/banner:bottom7._visible = false;
if (/map:x_target>="1257") {
/map:x_target == "1257";
}
if (/map:x_target<="-598") {
/map:x_target == "-598";
}
}
Correct Syntax?...
I have a code that starts off:
Code:
begin_btn.onRelease = function() {
......
}
What's the correct syntax to (in addition to "onRelease") have the same function happen when the "enter" key is pressed as well? I assume that I don't have to copy and paste the whole function again, just changing the "onRelease", right? Or no?!
Thanks!...
What Is The Correct Syntax?
I have a for loop that I'm using to move a series of movieclips across the stage. I need to get the x position of the movie clips before they start moving. I was trying something like this:
Code:
for(i=1; i<=5; i++){
var myitem = "mc_"+[i];
var myitemX = mymc._x // the problem seems to be with the syntax here
}
How can I get the current x position of all 5 of my movie clips within this loop?
Thanks!!!
Correct Syntax
What's the correct syntax for something like this (underlined):
Code:
for(index = 1; index <= 5; index++) {
for(subindex = 1; subindex <= ["variable" + index]; subindex++) {
//code
}
}
What Is The Correct Syntax ?
If I use this, I get the correct results:
Code:
loadResults.onLoad = function():Void {
for(index = 1; index <= loadResults.nrTables; index++) {
trace(loadResults["table" + index + "_nrLines"]);
}
}
But if I use the same command in the 'for' loop, flash crashes:
Code:
loadResults.onLoad = function():Void {
for(index = 1; index <= loadResults.nrTables; index++)
for(index2 = 1; index2 <= loadResults["table" + index + "_nrLines"]; index2++) {
//code
}
}
I also used instead of 'loadResults["table" + index + "_nrLines"]', 'this[loadResults["table" + index + "_nrLines"]]' and '_level0[loadResults["table" + index + "_nrLines"]]' but neither worked.
What is the correct syntax for the 'for' loop ?
Correct Syntax For This?
Anyone have any idea why this only works for a preplaced movieclip called "bill", but not for any dynamically created called "enemy_X" (x as in a number).
Code:
_root[enemyType]["animation"+animId].end
the snippet is in a MovieClip.Prototype, im not really sure when to use 'this' and when to use '_root'.
is that the correct syntax for accessing something which is setup like this?
i can't say i know how to use the hard brackets either, any thoughts?
Code:
bill.animationStand = function() {};
bill.animationStand = {start:1, end:10, looping:true};
Correct Syntax
Hi, I was wondering what would be the correct syntax for loading text from an external source that has a link on it, but the link has to be a javascript function call to open up a centered smaller pop-up window. and the actual url is a var I'm grabbing from a Load Vars function for example:
content=<li><a href="javascriptpenWindow('my_lv.link','myWin',' left=250, top=300,height=515,width=615, scrollbars=yes,toolbar=no,location=no,status=no,di rectories=no,menubar=no, resize=yes"><u>Nacho Libre</u></a>
"content " is my var. the url "my_lv.link" is the load vars call
I tried this but i'm not sure if the URL should be in quotes since it is a var .
Thanks, Nigel
Help With The Correct Syntax?
I know this is the code I want I'm just clueless on how to format it correctly? Can somebody give me a helping hand?
PHP Code:
on (release) {
sectionnav.alphaTo(0,1,"easeInOutQuart");
sectionnav.onTweenComplete = function()
{
prodnav.ySlideTo(0,2,"easeInOutQuart");
prodnav.onTweenComplete = function()
{
container_mc_main.ySlideTo(-680,2,"easeInOutQuart");
container_mc_main.onTweenComplete = function()
{
gotoAndStop("product");
};
What Is The Correct Syntax ?
If I use this, I get the correct results:
Code:
loadResults.onLoad = function():Void {
for(index = 1; index <= loadResults.nrTables; index++) {
trace(loadResults["table" + index + "_nrLines"]);
}
}
But if I use the same command in the 'foor' loop, flash crashes:
Code:
loadResults.onLoad = function():Void {
for(index = 1; index <= loadResults.nrTables; index++)
for(index2 = 1; index2 <= loadResults["table" + index + "_nrLines"]; index2++) {
//code
}
}
I also used instead of loadResults["table" + index + "_nrLines"], this[loadResults["table" + index + "_nrLines"]] and _level0[loadResults["table" + index + "_nrLines"]] but neither worked.
What is the correct syntax for the for loop ?
Is This Correct Syntax?
I need to get a value from a flashvar 'author' in the root of the movie.
is this the correct syntax
_root.author
I need to read the value from in a nested movieclip
Thanks!
_
Correct Get URL Syntax?
This is embarrassing--I'm not new to Flash but have just gotten an upgrade from MX to MX04 and the AS is killing me. I've got this code on a button---on(release) {
getURL("http://www.apple.com", "_blank")
}
This is the error I get back-
**Error** Symbol=movie1, layer=links, frame=1:Line 1: Syntax error.
Button.onPress getURL("http://www.apple.com", "_blank");
What is the correct syntax?
Also, what is the earliest player I can export to for max backward compatability?
Thanks
Correct Syntax
I want to make 5 out of 10 movieclips invisible.
I know this works for each movie :
item1._visible = false;
item2._visible = false;
etc
But whats the correct syntax to do it in the loop. This seems to clear all 10 movieclips.
ActionScript Code:
for (var y = 0; y<5; y++) { ["item"+(y)]_visible = false; }
any ideas greatly appreciated. Thanks.
Is This Syntax Correct?
getURL("monday.html", "soundframe");
i can't remember if the target .... soundframe in this case ..... needs to have quotes around it and/or an underscore _ preceding it (i.e. _blank, _parent)
thanks
Correct Syntax
I have a loop that attaches an item from the libary
ActionScript Code:
for(x=0;x<myLv.n;x++) { new_mc = _root.priceList.attachMovie("price_slot", "mc_"+x, x);}
I then want to refer to each of the movieclips path with something like this:
ActionScript Code:
_root.priceList.["mc_"+x].listContainer.attachMovie
What is the correct syntax for what I am trying to write. I know the code works because if I write
ActionScript Code:
_root.priceList.mc_1.listContainer.attachMovie
It does what I want. Any help much appreciated, thank you.
Correct Syntax
Whats the correct syntax for something like this:
ActionScript Code:
new_mc2.specs.text = myNv["model"+(y)"spec"+(p)];
my myNv variables are written something like this: model1spec2.
Thanks.
Correct Syntax
Whats the correct syntax for declaring a variable within a loop? Something like this:
ActionScript Code:
var p = 0; while (p<10) { var ["variable"+p] = "test"; p++ }
Thanks. Much appreciated.
Correct Syntax
I've used things like "mc_"+x; before but I'm trying to do the other way round like this:
ActionScript Code:
_global.imageName:String = (nextId + ".jpg");
Whats the correct syntax for this?
Correct Syntax
I am trying to position movieclips in a row but each of the loaded content is of different widths. I would like to position each clip so that it touches the edge of the one previously loaded before it. Something like this:
ActionScript Code:
for (y=0; y<5; y++){ var emptycontainer:MovieClip = _root.holder.createEmptyMovieClip("empcontainer"+y,y);var container:MovieClip = _root.holder["empcontainer"+(y)].attachMovie("testclip"+y, "instance"+y,this.getNextHighestDepth());if (y > 0){("empcontainer"+(y))._x = (("empcontainer"+(y-1))._x)+ ("empcontainer"+(y-1))._width);}}
The problem is the position line. I know it doesn't involve all these brackets but what is the correct syntax:
ActionScript Code:
("empcontainer"+(y))._x = (("empcontainer"+(y-1))._x)+ ("empcontainer"+(y-1))._width);
Correct Get URL Syntax?
This is embarrassing--I'm not new to Flash but have just gotten an upgrade from MX to MX04 and the AS is killing me. I've got this code on a button---on(release) {
getURL("http://www.apple.com", "_blank")
}
This is the error I get back-
**Error** Symbol=movie1, layer=links, frame=1:Line 1: Syntax error.
Button.onPress getURL("http://www.apple.com", "_blank");
What is the correct syntax?
Also, what is the earliest player I can export to for max backward compatability?
Thanks
Correct Syntax Help
data = new Array([0, [50,75,100]]);
trace(data[0[0]]);
data = new Array(['something', [50,75,100]]);
trace(data['something'[0]]);
Correct Syntax
hey USers, I am having a small problem. I am passing a varible around called current_section. It contains the instance name of my current section I am playing around. I am trying to do a few things with this varible one send this MC to a new frame using
_root[current_frame].gotoAndPlay(2);
and
_root[current_frame].getBytesTotal();
When I trace current_frame I am getting the correct name of the instance but when I trace the total bytes I get nothing nor will it play the next frame.
Can anyone help with some ideas on this. I am slowing going crazy with this concept. I have it working with:
_root[current_section]._x ="posX";
but nothing on the other two? got any ideas flashers?
Correct Syntax?
hi, i was wondering if there is anything wrong with the code below. i hav tried every little change to correct it, but it still wont work
please help!
Code:
on (release, releaseOutside) {
/map:scale_target = "150";
/banner:bottom6._visible = true;
/banner:bottom7._visible = false;
if (/map:x_target>="1257") {
/map:x_target == "1257";
}
if (/map:x_target<="-598") {
/map:x_target == "-598";
}
}
What Is The Correct Syntax For This Code?
I wanna load a external swf dynamically and have assign a variable call "folder1" on the _root of the Master movieclip. Therefore, to load the external swf, i have the following code:
Code:
path = "archives/"+[_root.folder1]+"/slot.swf"
loadMovie (path, "_root.section01");
Apparently, this is incorrect, so what is the correct syntax?
chup
What Is The Correct Syntax For This For Loop?
I cannot seem to get the following for loop to work. I'm sure it's something stupid. What am I missing?
Code:
for(n=1; n<=2; n++){
path = "_root.mc_nav.mc_"+[n];
trace("path = " + path);
txtpath = "txt" + [n];
trace("txtpath = " + txtpath);
path.createTextField("txtpath", n, -50, -8, 100, 20);
path.txtpath.setNewTextFormat(txtsm);
path.txtpath.selectable = false;
path.txtpath.embedFonts = true;
path.txtpath.antiAliasType = "advanced";
path.txtpath.text = "who we are";
trace("text =" + path.txtpath.text);
}
Also I was trying to set my "path" variable like this:
Code:
var path:String = "_root.mc_nav.mc_"+[n];
When I do that I get an error. Is that because "n" is actually a number and it cannot see it as a string?
Include: Correct Syntax?
Hi.
I want to keep my code outside of my flash movies, but my #include directive keeps returning Malformed #include directive. What's wrong? I've saved the code as plain text ("pieceofcode.as") and in my flash movie I'm referring to it with #include "pieceofcode.as";
Correct Syntax Please For Setproperty
Hello, I have this code that I am trying to integrate that is 3 levels down from the root. It is:
Y = getProperty('/dragMC/buttonMC',_y);
newY = oldY + (Y - oldY)/20;
setproperty('/scrolledMCrecipient/scrolledMC',_y,newY);
oldY = newY;
play();
How can I correctly code this since this was originally on the root movie?
Quick, What The Correct Syntax For This?
I am pretty sure there is some way to do this... Just trying to shorten up my syntax a bit.
Code:
if (theNumberVariable < 700 &| > 685) {
//Do stuff if theNumberVariable is from 685 to 700.
}
Whats The Correct Syntax?
I have a function that I want to use for all my menus:
ActionScript Code:
function button(menuvar){ trace(menuvar); _root.menuvar.gotoAndPlay("open");}
So if I call the function from a rollover I can send the menu name as a parameter to the function.
ActionScript Code:
on (rollOver) { _root.button("aboutmenu");}
However, its not working. When I trace the variable menuvar it shows as aboutmenu. My movieclip IS called aboutmenu. If I change the target from
_root.menuvar.gotoAndPlay("open");
to
_root.aboutmenu.gotoAndPlay("open");
it does work. So I'm guessing I've got the syntax wrong or I need to define the variables differently or something.
Any help would be much appreciated.
Correct Syntax For Sending ASP To Flash
Hi All ---
I have seen this a number of different ways...all of which don't work for me. Can someone please provide me with the correct syntax for sending a variable from ASP to Flash?
For example:
Dim myVar
myVar="myVar=Help"
response.write myVar
Does the above code need a "&" before the variable to send it to flash so that flash will recognize the variable?
Any assistance is greatly appreciated as I am losing hair quickly
Cheers.
SDL
Hi...whats The Correct Syntax For Pulling My.....
Hi...whats the correct syntax for obtaining a variable from another level ?
Im having problems with level 3 not understanding the variable that sits on level one...
Ive done this before..so im feeling really dumb
Anyone ?
Correct Syntax Of LoadVariables And Expression
What is the correct syntax for using an expression instead of a string to define a text file to load in an loadvariable?
Here's what I have:
descriptionName = _root["Desc_SUBproducts"+whatCat][whatSubprod];
//descriptionName returns the correct string
/Below is what doesn't work
loadVariables(descriptionName, this.descriptionfield);
Correct Syntax Of Mouse Over State For An MC
Hello there
I am wanting to make a MC a button where something will execute on the mouse over state, however when i use the following code nothing works as flash does not seem to like nClipEvent (mouseOver)
onClipEvent (mouseOver) {
colour_1.gotoAndPlay("Launch");
}
Does anyone know the correct syntax to allow my mc to have a Mouse over state on the MC
P.S also what would be the correct syntax for MouseOut on the MC
NB - I am aware that if I embed a button iinside the MC, i would not have this problem, however in this case I can not have a button emvbedded inside the MC
Thanks
Correct Syntax For Property Setting?
Hi,
Im trying to get the correct syntax for this...,
Could anyone help....deadline looms ahead for me.
Basically a bubble mc called bbl_1 on the root timeline gotta be duplicated in random _x positions while the _y coordinate stays the same. It duplicates allright but, no random positioning.
The code:
onClipEvent (mouseDown) {
_root.main.bbl_1.duplicateMovieClip("bbl_"+"x", x);
_root.main["bbl_"+x]._x=random(400);
x++;
}
HELP please!
Correct Syntax For Property Setting?
Hi,
Im trying to get the correct syntax for this...,
Could anyone help....deadline looms ahead for me.
Basically a bubble mc called bbl_1 on the root timeline gotta be duplicated in random _x positions while the _y coordinate stays the same. It duplicates allright but, no random positioning.
The code:
onClipEvent (mouseDown) {
_root.main.bbl_1.duplicateMovieClip("bbl_"+"x", x);
_root.main["bbl_"+x]._x=random(400);
x++;
}
HELP please!
[MX04] Correct Syntax In A Function
I have a function as below
Quote:
function calculateTax(gross, perValue, x) {
blagh blagh
net = ((gross*perValue)*1-tax);
return [net+"x"];}
I'm not sure I have the correct syntax for this part:
return [net+"x"];
basically if x = 1 then I need:
return net1;
Correct Syntax For Frame Jump?
I want it so that when a button is pressed the target movie clips goes to frame 4, I have this but it doesnt appear to work:
e.target.frame = 4;
Thanks
Correct Syntax To Add CuePoints Needed
I would like to add cuePoints to an .flv file that will trigger movieClip behavior but I can't figure out the correct syntax to get it all to work.
Here's what I have so far:
Code:
import mx.video.FLVPlayback;
var flvplayer4:FLVPlayback;
var flvpListener:Object = new Object();
flvpListener.complete = function(){
gotoAndStop("tvRoom");
}
flvplayer4.addASCuePoint(20,"start");
flvplayer4.addASCuePoint(45,"end");
flvpListener.cuePoint = function(eventObj:Object){
var cueName = String(eventObj.target.name);
if(cueName=="start"){
song_bg_mc.gotoAndPlay(2);
} else if(cueName=="end"){
song_bg_mc.gotoAndPlay(1);
}
}
flvplayer4.addEventListener("cuePoint", flvpListener);
flvplayer4.addEventListener("complete", flvpListener);
The end of video event works but the other code doesn't trigger the movieClip behavior.
All help will be greatly appreciated.
Thanks!
Is My Syntax Correct Or Even Close? Passing Var From MC To MC
ok,
I've been trying to read up on as much of this as I can and I want to know if I've got this idea correct...
In my timeline I've got two movie clips on two different layers. For this example I'll call them movie1 and movie2 respectively. In movie1, I have a series of buttons and menu choices that when clicked on, create a variable (myVar). Movie2, among other things, is a dynamic text field that requires the vars from movie1 to display the text. Would I call the var into movie2 from movie1 with the following:
Code:
myNewVar = _root.movie1.myVar
I get the idea that there should be more, but am I on the right track? If not, can someone point me in the right direction? Thanks!
The Correct Syntax For Joining A Path And A Variable Name Together
I am working on a prototype function for loading jpeg thumnails. It works fine so far, everything loads but i can not get them to load next to each other. Here is the code :
Code:
MovieClip.prototype.loadJPG = function(path, trgt, seed, maxSeed, format, startX, startY) {
mcName = seed;
path.createEmptyMovieClip(mcName, 1);
// note here ///////////////////////
pathName = path+"."+mcName;///
//////////////////////////////////////
path._x = -1/path._x;
path._y = -1/path._y;
path._x = startX;
path._y = startY;
loadMovie(trgt+seed+format, pathName);
onEnterFrame = function () {
if (seed<maxSeed) {
prevPathName_x = pathName._x;
prevPathNameWidth = pathName._width;
seed += 1;
mcName=seed;
//and here /////////////////////////
pathName=path+"."+mcName;///
//////////////////////////////////////
path.createEmptyMovieClip(mcName, seed);
loadMovie(trgt+seed+format, pathName);
pathName._x=prevPathName_x+prevPathNameWidth+5;
}
};
};
// usage below
_root.loadJPG(_root.empty, "thumbnails/DCP_", 1, 10, ".jpg", 100, 50);
Up untill now i was sure that
pathName=path+"."+mcName;
was the correct syntax for joining a path and a variable name together, but it doesn't appear to work because i can't controll the postitioning of the created mc's using the code:
Code:
prevPathName_x = pathName._x;
prevPathNameWidth = pathName._width;
//... skip a little...
pathName._x=prevPathName_x+prevPathNameWidth+5;
so my question to you is how do i join path and mcName to make one path?
ie _root.empty + 1 = _root.empty.1
Thanx in Advance
Help I Can't Activate A Movie Via A Button..SYNTAX Should Be 100% Correct.....but
I have no idea why, and Im very frustrated because I am doing everything right and this shouldnt be difficult.
I have a movie clip, which on frame one has a STOP();
On frame 2, starts a movie. I named the frame animation "zoomer".
I made a button that says
on(release){
_root.menu.inter.gotoAndPlay("zoomer");
}
And it doesnt play!!!!
does anyone have any idea why?
I typed root (to go to the beggining, and then entered into the menu movie clip, inter movie clip, and then told it to play zoomer, yet it doesnt.
I've made sure to name the frame and the spelling should be all right. any clue anyone?
|