Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trace command in FLash and general using a var 1

Status
Not open for further replies.

fireburner69

Programmer
Aug 22, 2002
108
GR
Ok I have this probleme which I can not understand fully!
I have a FLash movie! and I create some var!

For example!

for(x=0;x<10;x++) {
duplicateMovieCLip(_root.button,&quot;button&quot;+x,x);
}
all is smooth!
Inside the button Movie Clip I have a field named &quot;name&quot;.
I try to change the the text!
I used again to make it a loop like this

for(x=0;x<10;x++) {
&quot;_root.button&quot;+x+&quot;.name&quot; = &quot;Active&quot;;
}

So all the button will have the label active inside!
This is not possible!
an error comes up like this

&quot;Left side of assignment operator must be variable or property.
&quot;_root.button&quot;+x+&quot;.name&quot; = &quot;Active&quot;;
&quot;

So this is not possible!

And in the other hand!
I have this array!

_root.users
from 0 to 10
and when I trace one of the I use this method again!
for(x=0;x<10;x++) {
trace(_root.users.+x);

}

The answer to this is NaN
??? I do not understand what this is!
And whan i use &quot;_root.users.&quot;+x
this comes up _root.users.0 to 9 !!
But I want the var not the name!!
what can I do?



 
Assign values like this:

Code:
for(x=0;x<10;x++) {
    _root[&quot;button&quot;+x].name = &quot;Active&quot;;
}

... using '+' the way you were just creates strings not references.

Same for the array - you're just creating a string again. Try this instead:
Code:
for(x=0;x<10;x++) {
    trace(_root.users[x]);
}


 
So the tric here is! when I want to set a var! I will use this kind of type!~
_root.[&quot;name&quot;+x].name! ?

I can not understand the dif between! the string and the var!

I check it and It's work! Really thanx!

But Can you inlighten me! into this?
Please!
The string is just a name!
like
_root.button4.active that does not have a value inside!?
and var is a name which holds value inside? right?

If this is right! how can I understand when I create a string and not a var?
 
You need to tell Flash when something is just a value and when it is actually a path to something meaningful like a variable or movieclip. A string is not a name it is a value which can be assigned to something with a name.

Flash treats this as a string:

&quot;_root.button4.active&quot;

...but this as a variable:

_root.button4.active

So Flash will lookat this and think 'huh?':

&quot;myValue&quot;=24

...but will look at this:

myValue=24

...and think &quot;right, we're creating a variable called 'myValue' and assigning it the value of 24&quot;





 
question
if I type this
what will flash thing!
&quot;myvar&quot;+x = 24;
This will be a var or string?
 
String.

But:

this['myVar'+x]=24

...is a variable.

You have to force Flash into evaluating things as variables in cases like this - let it know that the part in quotes is to be treated as a variable. You can do this as above by specifying the path the variable lives on (this or _root or whatever) or by using:

eval(&quot;myVar&quot;+x)=24
 
Well you really helped me!
I was very confused about this thing!
ANd I surelly made alot of error back!
Well now on I know
Thanx very much! :))))
I am currently creating a php-flash-mysql Chat! :)
So I have to play with alot dynamicaly vars! and mcs!
So this is very helpfull!
Thanx! :)
 
Hi fireburner69,

I really needed badly the same kind of functionality you wrote, and that is, creating dynamic buttons and with texts. Can you please send me a sample .fla file of this?

It will be easier for me to learn the .fla.

Thank you very much in advance.

Neil
 
Ok Just hold on few min in order to make a fla only with the button and stuff ok?

I will include some info in order to understand better! :)

You can send me your email so it will be better to send it to you :))
 
Hi fireburner,

Thanks for the reply. My email is at neil-on-idg@restricted.dyndns.org.

Thanks again. :)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top