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








Help With Dynamic Variable Syntax.


I'm having a bit of trouble with some variable functions. Basically, what I want to do is define a variable on a button click and then run a function. When the function is run, it should take that variable that I defined on the button click and use it as the instance name for a movieclip to modify the properties of that movieclip.

I've done it before, but it seems to need a different syntax when I'm using the variable first in the path to the object. Here's my basic code on the button:


Code:
on (release) {
_root.nodeSelection = "facilities";
_root.openNode();
}
And normally, this is how I would think openNode would work:


Code:
function openNode() {
var openY = [_root.nodeSelection]interior._y;
trace(openY);
}
Obviously, however, this doesn't work because of the syntax error of using the brackets [] in the first part of the path, when normally, I could use it at the end and it would work fine. And, I know the variable has to be enclosed in the [] because it has something to do with having to add quotes around the variable, so I've tried it the other way and it doesn't work like this.



Code:
function openNode() {
var openY = _root.nodeSelection[interior._y];
trace(openY);
}
How would I structure the syntax in this situation so that the button I'm pressing dynamically assigns which movie clip will be modified? Does anyone have any ideas? Please? Thanks in advance...




ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 09-26-2008, 04:03 PM


View Complete Forum Thread with Replies

Sponsored Links:

AS2 Syntax And Dynamic Variable Names
Hi all,

Trying to learn AS2 and hoping someone can help me by explaining the problems with the following sample code and what would be needed to make it work (i.e. to create dynamic variables and movie clips from an array).

Thanks for your time!









Attach Code

// create array
var myArray:Array = ["a", "b", "c", "d"]

// create variables and movie clips
for (var i = 0; i<stn_Array.length; i++){
var [myArray[i]+"_colour"]:Number = 0xFFFFFF;
createEmptyMovieClip(myArray[i]+"_mc",i)
myArray[i]+"_mc".lineStyle(9,myArray[i]+"_colour")
myArray[i]+"_mc".moveTo(100,100*i);
myArray[i]+"_mc".lineTo(150,100*i);

myArray[i]+"_mc".onRollOver = function (){
//do something
}

myArray[i]+"_mc".onRollOut = function () {
//do something
}
}

View Replies !    View Related
Variable Syntax Help.
Inside an MC named mc_folio I have a button which does this :


Code:
on(release){
_root.mc_folio.gotoAndplay("preview");
image=m1
}
And an frmae which displays an image using this :


Code:
loadMovie("pics/large/"image".jpg", "preview");
The image is not loading properly... can anyone tell me why?

The image loads fine if I do this :


Code:
loadMovie("pics/large/m1.jpg", "preview");
Cheers, Robb

View Replies !    View Related
Variable Syntax
Hi

Actionscript 2
MX 2004 Pro

Im creating a dynamic menu which incrementally generates buttons and calls variables (section_1=Text 1, section_2=Text 2 etc) from an external file.

Im wanting the buttons to be labelled with the variable content rather than the variable name. At the moment the buttons are labelled section_1 and section_2 but i want them to be labelled Text 1 and Text 2. Im sure its just a simple syntax error.

my current code is

item.labelName = ["section_"+i];

Many thanks

M

View Replies !    View Related
Including A Variable In Dot Syntax
Hello,
how do I include a variable in my dot syntax?

var1 = "greenball";
_root.var1._x = 20;

In the second line above I want to change the _x value for the movie clip with the instance name greenball. Flash tries to change the _x value for a movie clip with the instance name var1.

How do I get around this? Thanks in advance

View Replies !    View Related
Variable Syntax Question
I'm trying to have my movie go in different directions depending upon the value of a variable. I have 4 buttons that change the value of the variable. In another movie clip I'm trying to put a frame action that checks the value of the variable and makes one thing or another happen, according to that value.
Does this syntax look correct:

if (_root.myVariable = go) {
tellTarget ("clip1") {
gotoAndPlay (1);
}
}

Should 'go' be in quotation marks, either when I set it or when I check it?
thanks for the help.
-ml

View Replies !    View Related
Function Name In A Variable Syntax
HI,
If I have a mc which which contains a button and..
On my maintimeline I declare several functions

function DoStuff() {
what ever in here
}

as I have multiple instances of my mc which I wish to execute different functions when the button closes them I store the name of the function to execute in a variable on load

onClipEvent(load){
FunctionToDo = "DoStuff";
}

what do I put on my button to call the function?

thanks mark

View Replies !    View Related
Constant Variable Syntax
sorry for the next dumb question...

whats the syntax of constant variable in AS?
the following are not working (its the code from my object class)

Code:
class MyObj {

// None of this line works.
private var constant num = 9;
private var const num = 9;
private constant var num = 9;
private const var num = 9;
}
help?

View Replies !    View Related
_root. (variable) Syntax?
Flash 5 syntax help please.

Early in a movie I set the variable _level0.name="jim";

Later, I need to tell a movieclip (which is nested inside others) with that variable name to gotoandplay the frame labeled "fadein"

If I write it out with no variables it works and looks like this:

_root.menu.pics.jim.gotoandplay("fadein");

But I can't seem to figure out how to write it to make use of the _level0.name variable in place of "jim" and get it to work.

Obviously there are multiple movieclips in that position besides "jim" and I need to target a specific one at different times depending on user actions - which is why I am doing this.

Everything I write out either gives a syntax error or plain does not work. I've checked my variable output and _level0.name is being set to "jim" before the call is made.

help?

View Replies !    View Related
Syntax For Variable Text Name
Actionscript 2
Flash MX 2004

Hi

Im making a dynamic menu and the master button has a text field which i want to be filled with different variable values for each button in the menu. In my frame action i state the following values...

newsSection_1 = "recent news";
newsSection_2 = "archive news";
newsSection_3 = "other news";

to assign the variable to the button i am stating this....

item.buttonName = ["newsSection_"+i];

but rather than displaying the button names "recent news, archive news" etc it is just displaying "newsSection_1" etc. Im sure this is just because my syntax is wrong and when im setting the text for the button it is reading it as a string rather than a variable (hope i havent mixed up my jargon there).

Any suggestions?

Many thanks

M

View Replies !    View Related
Variable Syntax Problem?
Actionscript 2
Flash MX 2004

Hi there

Im having what is hopefully a simple syntax problem or global variable problem.

Im making a dynamically created menu which makes buttons from a template button. Obviously the references in the button actions have to be generic in order to handle the incremental variables.

Some of my variables are :-
newsSection_1_maintextVar
newsSection_2_maintextVar
newsSection_3_maintextVar

The template button code is this:-

<code>
on (release){
_root.subheader.text=this.buttonName;
_root.maintextnoscroll.text=eval("_root.newsSectio n_"+i+"_maintextVar");
}
</code>


With that above code it is calling 'newsSection_1_maintextVar' in every instance rather than incremented variables. I think the problem lies with introducing the 'i' variable so that different variables are called in each button. Either this is a syntax problem or it is because the variable is not global or is in a different level, but the 'buttonName' variable is being called alright and it is created in the same place as the 'i' variable. Any thoughts?



The code which initiates the 'i' variables (and which is itself held within a master button which creates the sub menu) is this:

<code>

on (release) {
_root.menu_mc.removeMovieClip();
var menu = this.createEmptyMovieClip("menu_mc", 1);
menu._x = 159;
menu._y = 161;
for( var i=1; i <= newsCount; i++){
var depthCount = menu.getNextHighestDepth();
var item = menu.attachMovie("itemClip", "item_" + i, depthCount);
item.buttonName = this["newsSection_"+i];
item.buttonVar = this["newsSection_"+i+"Var"];
item.targetClip = this;
item._y = i*25;
}
}
</code>

Many thanks

M

View Replies !    View Related
Syntax For Variable Condition
Flash MX 2004 Pro
Actionscript 2

Hi

Ive got a generic button which is produced dynamically for various variables. I want all of these buttons to go to the same point in the timeline except for 1 button. So i need to be able to check the variables and if the variable is "quicklinks" then it goes to a different point on the timeline.

I think i am making a mistake with my syntax in the variable recognition part straight after the if statement.

if (sectionName+"Section_"+numberVar+"Var")=="quickli nks"{
_root.gotoAndPlay("MAIN");
}


Im sure its a very simple correction required, like square brackets or something.

Any suggestions?

Many thanks

M

View Replies !    View Related
Using Variable Values In Dot Syntax?
I need to figure out how to use the value of a variable as part of a dot syntax reference. Here's kinda what i need to do:

//set a variable to a value
var currentPage:String="page1";
//use the value set to currentPage to access a dynamic value
_root.blahBlah.page1.visible=false;
//based on what the value of currentPage is, work on different objects
_root.blahBlah.page2.visible=false;
_root.blahBlah.page3.visible=false;
//(where page2 or page3 come from the value of the String)

View Replies !    View Related
Syntax For Adding To Variable Name + I?
Hi I have this

checkBox1="No";
checkBox2="No";
checkBox3="No"; .... trying to write a loop for it ...


for(i=1;i<76;i++){
checkBox['i']="No"; //doesn't work
}

What is the syntax for checkBox + i so that I can make it loop ??

cheers

View Replies !    View Related
Variable String Syntax
I'm changing the contents of a dynamic textbox based on a user selection in a combobox. The combobox is populated via an XML file.

"_level1.villanameB_dt.text" is the name/location of the textbox.
"_level0.map.image_tn.propName.thumbnail_image.nam etext" is that value that I want in the above textbox.

This is the code that will work, but I have to hardcode "thumbnail2":

Code:
var propName:String = 'thumbnail'+comboBox.selectedIndex;
_level1.villanameB_dt.text = _level0.map.image_tn.thumbnail2.thumbnail_image.nametext;
Now if I try to replace "thumbnail2" with a variable, it doesn't work, though if I trace "propName" it correctly shows my selection ("thumbnail1", "thumbnail2" etc.)

Code:
var propName:String = 'thumbnail'+comboBox.selectedIndex;
_level1.villanameB_dt.text = _level0.map.image_tn.propName.thumbnail_image.nametext;
I don't understand why the code directly above returns "thumbnail2" for trace(propName), but doesn't change the textbox. If I hardcode "thumbnail2" into the script rather than use the propName variable, it returns the proper value in the text box.

Any ideas? Thanks!

View Replies !    View Related
Path In A Variable Syntax Help Please
Hi,
I am posting again with a hopefully better explanation as I did not get a correct answer.
Please if you are not familiar with this don't answer.

So let me start by saying if you have the name of a mc stored in a variable the way to communicate with that mc would be for example
_root[MCnameVariable]._x = 50;

This works fine if the variable contains just the name of the mc
BUT I now have a situation where I need to store the name of the mc and its parent.

If I just store the name of the parent and mc together in the variable like this
MCnameVariable = _parent._name + "." + this._name;

The _root[MCnameVariable]._x = 50; syntax will not work

what is the correct way to do this?
please help

mark

View Replies !    View Related
Syntax For Using A Variable In A Path
I have an MC that contains a text box called: myText

The name of the MC varies throughout the movie depending on which button has been pressed.

When I try to display some text in the text box Flash cannot find it. Eg:


_root.myVariableName.myText = “My new text”;

But this does not work. I have also tried things like:


_root.(myVariableName).myText = “My new text”;//does not work

_root.[myVariableName].myText = “My new text”;//does not work

_root.'myVariableName'.myText = “My new text”;//does not work


Anybody know the correct syntax for using a variable in a Path??

View Replies !    View Related
Variable Syntax.... N00by Help...
ok, havin another n00by problem...

i wanna declare and assign a global var in one script, and i have:

_global.subs = "0";

ookie... looks good... i think...
then later, i wanna USE it in another script.... and i have something like:

if (subs = 0) {
subs = "4";
}

and it does not appear to work.... do i always have to write _global. in front of subs? (that cant be it.. i think i tried that...)

also tried _root.subs......

or do i need to re-declare subs as a global at thestart of the second script to remind flash about it...? if so, how can i do it without overwriting the contents, like in: _global.subs = "0";

?

man, i thought i had all these issues solved...

thanks in advance..

View Replies !    View Related
Functions And Variable Syntax
This is a quick one...


I am looping to find the name of 1 of my 12 movieClips.


Code:
for (x=1; x<=12; x++) {
_root["mc"+x].alphaTo(100, x*.10, "linear", x*.10);
_root["mc"+x].onEnterFrame = function() {
this.onRollOver = function() {
this.i += 2;
this.swapDepths(this.i);
this.scaleTo(154, .75, 'easeOutElastic', 0);
this.gotoAndStop("sub");
HERE IS WHERE I WANT TO ADD CODE: ["mc"+x]Move();
};
this.onRollOut = function() {
this.scaleTo(100, .25, 'easeOutBack', 0);
this.gotoAndStop("main");
};
};
}

function mc1Move() {
something for the funtion
}

function mc2Move() {
something for the funtion
}
I want to add a function call based on the name of the clip that is "this" at the time. And I want it to call its variable named function.

Does this make sense?

View Replies !    View Related
Syntax Problem With Variable AS2
Hi there,

I have a swf that I am loading into my main movie which uses an xml gallery.

The line of code that brings in the xml file is:
xmlData.load("filename.xml");

I would like to be able to reuse the swf and change out the xml file using a variable I will call from a menu. I can't work out what the correct syntax should be. What do I replace the quote marks around filename.xml with? My variable is called _global.xmlFile.

Any help greatly appreciated.

View Replies !    View Related
I Forgot The Syntax -- Variable Name And MC
I forgot how to do the following, can you refresh my memory?

I want to assign a variable name and pass it when targeting an MC, like this:

Main Timeline:
_global.myMC = movie1;

Timeline in a sub MC somewhere:
myMC.gotoAndPlay("label");

I can get it to work on the same timeline, but not in a sub MC and I recall having done this before, so what am I doing wrong, it should be simple?!

Thanks!

View Replies !    View Related
Newbie Needs Help With Variable Syntax
It all seems simple enough - what am I missing?

I declare the variable..

Code:

var redcir:String;

Later the variable is assigned a value, say

Code:

redcir = "circle2";

This happens to be a movie clip name, assigned to the variable to play said movie clip.

Then later when I try to play it...

Code:

redcir.gotoAndPlay(2);

I get this error:

1061: Call to a possibly undefined method gotoAndPlay through a reference with static type String.

View Replies !    View Related
Syntax And String As Variable Problem
Im trying to store the instance name of a mc in a variable. "OldName" so that the next clicked mc will swap depth with it.
for example these two buttons should flip the images back and forth, if I put the names in it works so target paths are not a problem. I guess its a string as variable type syntax problem, what should it be

mark

on (release) {
OldImage.swapDepths(cuba2);
OldImage = "cuba2";
}

on (release) {
OldImage.swapDepths(cuba1);
OldImage = "cuba1";
}

View Replies !    View Related
Syntax To Store A Color As A Variable
Hi,
I was attempting to help someone out on the newbie board and found my knowledge of the color object let me down, always more to learn.

Basically he has this on a button,

on (release) {
_root.mc2Color = new Color("_root.mc2");
_root.mc2Color.setRGB(0x663300);

he has various buttons for different colors.
we need to store the color set by the button in a variable and then have an OnClipEvent(load) on other mc's read up that variable and set them to that color.

what do we store in the variable, and what syntax will properly combine the variable name with the color syntax to make the change.

thanks mark

View Replies !    View Related
How To Integradte A Variable In .dot Syntax Path?help...
hello.

I'm having a little problem here...

with the old Flash 4 syntax you could acess an MC with his instance name embeded in a variable like this:

var IDpath="/cityALL/";
var IDpath2=IDpath add "/characterMC/character";


tellTarget (IDpath2) {
gotoAndPlay(_root.dir);
}

tellTarget (IDpath) {
myName=getProperty(IDpath,_name);
gotoAndPlay(5);
}

HOW IS THIS DONE WITH THE dot Syntax?
since I don't want to use tellTarget.

AND:

Can I use DOT Syntax inside a telltarget?

cheers
chris

View Replies !    View Related
Syntax For Displaying A Text Variable
Can anyone tell me the syntax for displaying a variable in a dynamic text box? I'm just not sure of the exact phrasing. Thanks.

View Replies !    View Related
Quick Variable Syntax Question
Hey...

Here's the story...

On my portfolio page I have thumbnail buttons that send the page to the image part and at the same time sets the dynamically loaded jpeg to the right one...

Like this...
code:
on(release){
_root.mc_folio.gotoAndplay("preview");
image = "31"
}

On the "preview" part I have dynamic text next to the image...
I want to be able to call the names from a single text file and have the button say something like this...
code:
on(release){
_root.mc_folio.gotoAndplay("preview");
image = "31"
desc = "THE VARIABLE FROM THE TEXT FILE"
title = "THE VARIALBE FROM THE TEXT FILE"
}

So really... I want to give a variable the value of another variable...

Understand? I hope so...

How do I do this? What is the syntax? Also... can someone also tell me the correct way to load variables? It is nested within a few MCs...

Thanks, Robb

View Replies !    View Related
Referencing Object Using Variable Syntax
I'm having trouble referencing an object using a variable in Flash MX.
In this example, I'm dynamically loading jpegs and need to test that they have finished loading.
The img var contains the url of the image to load.


On the first frame:

for(i=0; i<number_of_images; i++)
{
//duplicate the holder
duplicateMovieClip(my_movie.holder, i, i);

//create reference for the img to load
img_to_load = "my_movie.holder." + i;

//load image into the duplicated movie
img_to_load.loadMovie(img_url);
}

On another frame:
if(img_to_load.getBytesTotal() >= img_to_load.getBytesLoaded() )
{
//image has loaded
}else{
//image still loading
}


My problem is that img_to_load is a variable that returns a string and not an object - what do I need to do?

Thanks in advance

View Replies !    View Related
GetURL With Variable Syntax Question
Can someone please tell me what i am doing wrong with the syntax here.


Code:
projecturls = new LoadVars();
projecturls.load("projecturls.txt");
projecturls.onLoad = function (success) {
if (success) {
for (i=1; i<6; i++) {
level0_current_mc["c"+i+"_mc"].project_but.onRelease = function () {
getURL("projecturls.urlc"+i+, _blank);
}
}
}
}
i get the message
**Error** Scene=Scene 1, layer=actions, frame=1:Line 8: Operator '+' must be followed by an operand
getURL("projecturls.urlc"+i+, _blank);

View Replies !    View Related
Loading Variable With Url Syntax Query
Hi there could someone please help me
I trying to load a variable with a url string.

link = "http://imagical.kol.co.nz/pages/Me_B.html", "_top";

It works but it doesn't load in seperate window.
I think this is because the variable link is only holding the string inside the first set of quotation marks and does not see the second string "_top"

I tried to put braces around but I get a sandbox violation error.
link = ("http://imagical.kol.co.nz/pages/Me_B.html", "_top");

Looking forward to any ideas on the right syntax to use
Thanks
Tiaka

View Replies !    View Related
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

View Replies !    View Related
Syntax For Using Scene Variable In To Goto Statement
I have a variable named "destination" that I set based on button selections at various points.

My intent is to run some more frames then redirect the movie flow to the scene with the name that matches the value of the "destination" variable.

I can't figure out the correct syntax for the goto action, though.

Please help!!!

Thanks in advance.

View Replies !    View Related
Syntax Question: Parsing Code With A Variable
Hi All,

There's some code within a loop that creates an empty clip then attachs an image (referenced through xml).

My problem, (and it's one I should probably be able to figure out) is that I can't figure out how to target the new clips.

CODE STARTS:
loop starts
//some other code which I know works and does not conflict

image = ("image" + i);
_root.createEmptyMovieClip(image,i);

"_root."+ image + ".loadMovie(baseNode.firstChild);";

//some other code which I know works and does not conflict

loop ends


what I want is the code to end up with
_root.image0.loadMovie(baseNode.firstChild);
_root.image1.loadMovie(baseNode.firstChild);
_root.image2.loadMovie(baseNode.firstChild);
_root.image3.loadMovie(baseNode.firstChild);
_root.image4.loadMovie(baseNode.firstChild);
_root.image5.loadMovie(baseNode.firstChild);

etc etc

any help would be dandy

Cheers
FP

View Replies !    View Related
Syntax Help With Dynamic This.i
I have a photogallery where I'm dynamically loading full-size jpgs and then downsizing them to thumbnails. additionally, I'm creating another empty movie clip on top of each image so I can change the appearance of the images (alpha, blue tint, green tint, etc.)

so all of the thumb mcs are created in a loop and named mc[i] (mc1, mc2, mc3, mc4 etc.) Then another empty movieclip is created as a child of the mc and named cover[i] (cover1, cover2, cover3, cover4, etc.). If I debug and look at the objects, they all show up. Here is an example of one;

Movie Clip: Frame=1 Target="_level0.thumbs_mc.mc65"
Shape:
Movie Clip: Frame=0 Target="_level0.thumbs_mc.mc65.cover65"

So, I have a function that enlarges the image, but when the image gets clicked on, I also want to change the alpha property of the cover movieClip. Right now, I can make it work if I hard code in the cover like this;

setProperty(this.cover0, _alpha, 0);
or
setProperty(this.cover1, _alpha, 0);
etc. for each cover mc.

what I want it to do is to dynamically pull in the number of the mc that is clicked. Right now, if I trace this.i I get the correct number of the mc that was clicked. I have tried many things such as

setProperty(this.cover[i], _alpha, 0);
setProperty(this.cover[this.i], _alpha, 0);
setProperty(this.cover+i, _alpha, 0);

any many more.

This is killing me - can anyone help me with the syntax? I'm guessing it's something simple that I'm missing.

Thanks in advance.

View Replies !    View Related
Syntax Help With Dynamic This.i
Sorry for posting twice - there were database issues going on when I submitted the first time.


I have a photogallery where I'm dynamically loading full-size jpgs and then downsizing them to thumbnails. additionally, I'm creating another empty movie clip on top of each image so I can change the appearance of the images (alpha, blue tint, green tint, etc.)

so all of the thumb mcs are created in a loop and named mc[i] (mc1, mc2, mc3, mc4 etc.) Then another empty movieclip is created as a child of the mc and named cover[i] (cover1, cover2, cover3, cover4, etc.). If I debug and look at the objects, they all show up. Here is an example of one;

Movie Clip: Frame=1 Target="_level0.thumbs_mc.mc65"
Shape:
Movie Clip: Frame=0 Target="_level0.thumbs_mc.mc65.cover65"

So, I have a function that enlarges the image, but when the image gets clicked on, I also want to change the alpha property of the cover movieClip. Right now, I can make it work if I hard code in the cover like this;

setProperty(this.cover0, _alpha, 0);
or
setProperty(this.cover1, _alpha, 0);
etc. for each cover mc.

what I want it to do is to dynamically pull in the number of the mc that is clicked. Right now, if I trace this.i I get the correct number of the mc that was clicked. I have tried many things such as

setProperty(this.cover[i], _alpha, 0);
setProperty(this.cover[this.i], _alpha, 0);
setProperty(this.cover+i, _alpha, 0);

any many more.

This is killing me - can anyone help me with the syntax? I'm guessing it's something simple that I'm missing.

Thanks in advance.

View Replies !    View Related
Syntax For Dynamic _level Num
Hi...

I want to use a variable value to with _level, ie:

if (_level[soundCount].getBytesTotal() == _level[soundCount].getBytesLoaded())
soundCount is a variable & i want to check loading for
_level with the value of soundCount
this would work? or:

if (eval("_level"+soundCount).getBytesTotal() == blah blah...

which way can it be done?

please help!
AJ

View Replies !    View Related
Syntax For Dynamic Naming
Hey there,

I'm trying to set a number of arrays dynamically using FOR... loops.

I've got to the stage where I need to run two FOR loops (one within the other, one has initial i=1, the other j=1)

If I want to set an array using these two variables then, how do I do it...

I'm trying:

this["variablename"+this.i][this.j];

But it doesn't recognise it as me wanting to set an array. Any ideas?

View Replies !    View Related
Syntax For Dynamic Info
i've used php a lot and i am starting to use flash but i'm not sure of some syntax.

i'm trying to name movie clips dynamically and also get info about dynamically named movie clips.

i took a guess at the syntax and i am wondering if this looks ok to you? if not, what is wrong about it?


Code:
for (r=0, r<rows, r++) {
duplicateMovieClip(tune_box, "tune_box"+r, this.getNextHighestDepth());
current_dynamic_name = "tune_box_"+r;
previous_dynamic_name = "tune_box_"(+r(-1));
current_dynamic_name._x = -240;
current_dynamic_name._y = previous_dynamic_name._y + 65;
}


'rows' is a variable which was set earlier to show how many rows there are in an array. i want to name each movie like this...

'tune_box_0', 'tune_box_1', 'tune_box_2' etc.

i also want to be able to retrieve _x and _y info about a dynamically named 'tune_box_n' and then add a figure to it so that when i create a duplicate movieclip, the new one is moved to below the previous one by '65'.

i know what the syntax is for doing this sort of stuff in php, but how do i go about doing this in flash? this is quite important for me to sort out as i will be using this sort of stuff a lot in flash. is there a webpage (on this site or another site) which describes all of this?

cheers in advance

View Replies !    View Related
Syntax For Dynamic Path _x
Hello
I have previously coded dynamic paths using syntax such as


Code:
_root[dynamicPath].gotoAndPlay(2);
and the above works.

I am now trying to alter the X position of an MC with the target being dynamic. When I pass the target of a given MC from the MC itself I trace "/mc_instance_name"

For example from an MC in the root


Code:
onClipEvent(load){
_root.functionName(this._target);
trace(this._target) // This will read "/mc_instance_name"
}
Then in the function


Code:
function functionName(passedTargetPath){
_root[passedTargetPath]._x = 300;
}

Now I know the above (_root[passedTargetPath]._x = 300) is not the correct syntax but this is my question: How do I write this to point to the MC_instance on the root?

I've tried:
[passedTargetPath]._x = 300;
_root[passedTargetPath]_x = 300;

I also tried making a new variable since the value past includes "/" in it, I tried adding "../" to it so that it reads "../mc_instance_name"

Then using that value within a new variable but I still get syntax errors.

Thanks!!!
FA

View Replies !    View Related
Dynamic Pathnames, Dot Syntax
I'm using Flash 8, and creating a dynamic XML driven menu.

I can't for the life of me figure out the syntax to make a 2 dimensional path to a movieclip.

I can reference a movieclip dynamically with: _root["main"+i].label.text
but how can I reference a movieclip like this:

_root.main1.subBut1_1.label.text

Where "main1" AND "subBut1_1" are dynamically written.

I've tried _root["main"+i]["subBut"+i+"_"+t] and _root["main"+i].["subBut"+i+"_"+t], no dice. I would think it was pretty common to try and do something like this.


Code:
function loadXML(loaded) {
if (loaded) {
xmlNode_xml = this.firstChild;
butNode_xml = xmlNode_xml.firstChild;
prefNode_xml = butNode_xml.nextSibling;

mainBG = prefNode_xml.firstChild.attributes["mainBG"];
tempClr = new Color(mainBGclr);
tempClr.setRGB(mainBG);
mainBGclr._alpha = 100;

numMain = butNode_xml.childNodes.length;
for(i=0; i<numMain; i++){
numSubs = butNode_xml.childNodes[i].childNodes.length;
yCount = i*25;
_root.attachMovie("mainBut","main"+i,i,{_x:0, _y:yCount});
_root["main"+i].label.text = butNode_xml.childNodes[i].attributes["label"];
for(t=0; t<numSubs; t++){
ySub = (t*25)+25;
_root["main"+i].attachMovie("subBut","sub"+i+"_"+t, this.getNextHighestDepth(),{_x:0, _y:ySub});
_root["main"+i]["subBut"+i+"_"+t].label.text = "Test";
}
}
}
}

View Replies !    View Related
Dynamic Text Syntax Error
I have this code in a frame in a movieclip

this.thoughtBox.text = _root.thought.[age][math.round(math.random()*12)]




In the first frame of the main timeline i have 3 arrays, thought.young, thought.teen and thought.now

I want to be able to put "young" or "teen" or "now" into the age variable so different arrays will be accessed when i want it to. 'Cept i'm getting a syntax error for the above line of code. What am i doing wrong?

View Replies !    View Related
[Q] Syntax To Call An Array Value Using A Dynamic Name?
ActionScript Code:
var array1:Array = [1, 2, 3];
var n:Number = 1;
What is the syntax to get those values using n?
It isn't:

ActionScript Code:
["array"+n][0]
What am I missing here...

View Replies !    View Related
Syntax Question, Strict Data Typing With Dynamic Var Name
Code:
var shapeList:Array = [];

/**
* Generate a new name for object that I am storing for
* the first time
*/
var pointer:String = "Obj" + shapeList.length; // first run is "Obj0"

/**
* Create an Array object with the generated name, and
* use it to store all info about the object.
*/
// three incorect syntax below
var pointer:Array = [] // error!! "type mismatch"
var (this["Obj" + shapeList.length]):Array = []; // error!! "Identifier expected"
var eval(["Obj" + shapeList.length):Array = []; // error!! "syntax error)
I want to generate a dynamic name for an Array. It is inside a class and every variable must be explicitly type set via strict data typing. What is the correct syntax for creating a Array with the name of the Array being a dynamic string?

thanks

--mm

View Replies !    View Related
Create Dynamic Actionscript Syntax Froma String
Hi,
I am trying to create a dynamic actionscript to do specific calculation with, for example:

stringa="16+14";
stringb=some_function (stringa);//outputting 30


or, if even possible, to be able to perform all actiopnscript, like e.g.

stringa=16;
stringb="c=String(stringa);c=c.length;";
c=some_function(stringb);//c would output 2

Is this possible in Flash MX?

greetings
Patrick

View Replies !    View Related
How Do I Make A Variable Store A Variable? - Dynamic Input Stuff ...
Hey, I got a little problem which I've usually been able to work around but in this particular case there really isn't another way. I want to give in a variable, say "x+x" and then use it as "x+x" and not as their assigned values ...

my result should be that I can alter the course of a loop like this ... for example:

input in text field = x+x

for(x=0,x<=50,x++){
...

y[x]=x+x

...
}

and if I give in 2*x it would make y[x]=2*x

I have no idea if there's a way in flash to accomplish this but if there is I'd sure like to know, thanks for any help I receive, I'll check back here soon.

View Replies !    View Related
Dynamic Text Field Is Calling The Variable Name Instead Of Variable Content
I'm having a problem getting something to work. I'm sure it has something to do with string variables and my syntax, but can't figure it out.

I have variables named cust1, cust2, cust3, etc. that are being loaded from a text file (these are customer names that will display in a text ticker).

I want a dynamic text field to display the customer names in incremental order, so I created a variable that consists of the string "cust" + a numeric variable called custNumber. At the end of each pass of the movie, custNumber is increased by 1.

var custNumber = 1;
var custName = "cust"+custNumber;

I want the dynamic text field to call the variable custName, but I can't get it to work. It keeps displaying custName as a string ("cust1", "cust2", etc.).

So I created a new variable called scrollText for the dynamic text to call, and made scrollText = custName;. But it does the same as above.

How do I get my dynamic text to call the variable that I create with another variable?

I want my dynamic text field to display the variable cust1, cust2, cust3, which would be "Jones Plumbing," "Smith Electric" etc., but all I'm getting is "cust1", "cust2", "cust3" etc.

Thanks,

Thom

View Replies !    View Related
How To Store A String Plus A Variable In A Dynamic Text Variable?
Hi,

I've got a dynamic text field with the instance name rightAnswer_txt.

I declare the variable in the frame it resides in, with the following code var rightAnswer_txt:String = "";

Then, when I want to populate it using the following code:

rightAnswer_txt.text = "You scored " + rightAnswers;

the script comes out with an error saying ...

**Error** Scene=Scene 1, layer=actions, frame=7:Line 15: There is no property with the name 'text'.
rightAnswer_txt.text = "You scored " + rightAnswers;

Any idea what this means anyone please?

View Replies !    View Related
Duplicating Clip Code - Dynamic Naming And Moving - Syntax Error
This code should duplicate a clip, and increase the name by 1. What am I doing wrong?


Code:
duplicateMovieClip(thWin1, "thWin"+[_root.thWinNum], this.getNextHighestDepth());
thWin+[_root.thWinNum]._x=thWin+[_root.thWinNum-1]._x+54.8;
Thank You,
-Kirk II

View Replies !    View Related
Syntax Error - "Left Side Of Assignment Operator Must Be Variable Or Property"
What the...

I just updated from Flash 5 to Flash 6 and I go to publish a swf (that I've done heaps of times before) and it comes up with the following syntax error in the Output box:

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 4: Left side of assignment operator must be variable or property.
if (xmousepos1>xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 7: Left side of assignment operator must be variable or property.
if (xmousepos1<xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 10: Left side of assignment operator must be variable or property.
if (ymousepos1<-76 || ymousepos1>--45) {


Now, what on earth is wrong with "if (xmousepos1>xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {" etc etc ????????

If somebody could let me know, then that would be great!

Thanks heaps.

Blastbum

View Replies !    View Related
Syntax Error - "Left Side Of Assignment Operator Must Be Variable Or Property"
What the...

I just updated from Flash 5 to Flash 6 and I go to publish a swf (that I've done heaps of times before) and it comes up with the following syntax error in the Output box:

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 4: Left side of assignment operator must be variable or property.
if (xmousepos1>xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 7: Left side of assignment operator must be variable or property.
if (xmousepos1<xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 10: Left side of assignment operator must be variable or property.
if (ymousepos1<-76 || ymousepos1>--45) {


Now, what on earth is wrong with the above????????

If somebody could let me know, then that would be great!

Thanks heaps.

Blastbum

View Replies !    View Related
Syntax Error - "Left Side Of Assignment Operator Must Be Variable Or Property"
What the...

I just updated from Flash 5 to Flash 6 and I go to publish a swf (that I've done heaps of times before) and it comes up with the following syntax error in the Output box:

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 4: Left side of assignment operator must be variable or property.
if (xmousepos1>xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 7: Left side of assignment operator must be variable or property.
if (xmousepos1<xmousepos2 && ymousepos1>-76 && ymousepos1<--45) {

Scene=Scene 1, Layer=Scrolling Bar, Frame=22: Line 10: Left side of assignment operator must be variable or property.
if (ymousepos1<-76 || ymousepos1>--45) {


Now, what on earth is wrong with the above????????

If somebody could let me know, then that would be great!

Thanks heaps.

Blastbum

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved