-
F*cking Variables
Hi, I've got a movie which displays thumbnails of different projects.
I've a container (mc) with different pictures in every frame.
And using this script to place them in a grid:
if (n<e) {
duplicateMovieClip(bilder, ["bilder"+n], n);
if (n == 12 || n == 24 || n == 36 || n == 48 || n == 60 || n == 72) {
y++;
}
setProperty(["bilder"+n], _y, 50*y);
setProperty(["bilder"+n], _alpha, -10*n);
setProperty(["bilder"+n], _x, 50*(n-12*y));
}
n++
And in that mc (bilder), i've set so that it goes to the next frame for each "n++".
Which works good, except that I also want to be able to sort them in different ways.
I started to make a dynamic list with the vars:
o1=14
o2=92
and so on...
After that I made a different code which are going to sort them in a new order, with the code:
if (np<e) {
if (np == 12 || np == 24 || np == 36 || np == 48 || np == 60 || np == 72) {
yp++;
}
setProperty(["bilder"+["o"+np], _y, 50*yp);
setProperty(["bilder"+["o"+np], _x, 50*(np-12*yp));
}
np++
where ["o"+np] should be the variable o1 for example and set "bilder14" to be first in the list.
But it doesn't work... which is driving me insane!!!!
Can anyone solve this????
is it possible to use multiple text and variables in "setProperty"?
Or should this be solved in a totally different way?
-
Senior Member
For one thing, you're missing a closing ] bracket.
-
hi, thanks for replying.
The actual script works, just forgot one right now.
the thing is that it works if I don't use the variables in "setProperty".
Any ideas?
-
Senior Member
What Flash version are you publishing for? Setproperty has been deprecated, hasn't it? Maybe you're publishing in Flash 7 and it's not allowing that command.
Trying publishing in Flash 5 and see if it makes a diff.
-
setProperty works in flash player 7
-
Hi, thanks for the tips.
but the scripts works really good except for the fact that I want to create a variable ("o1") so that setProperty uses it, by using a letter and a variable which increases by 1 to use "o2" next time.
example:
this script to works:
L=5
setProperty(["clip"+L], _y, 10*L);
L++
which should place the MC "clip5" to 50 in _y.
and MC "clip6" to 60 in y.
what doesn't work is if I want the variable H5
which could H5=85 to act as an extension on "clip".
like clip85
H40=50
L=40
setProperty(["clip"+["H"+L], _y, 10*L);
L++
action:
clip50 to be placed in _y 400
Does this make sense?
I can hardly understand myself...
I'm trying to place a series of MC's in different orders by using a variable serie to place without having to write 100 lines of setProperty...
I can send the fla-file if you think that you could help me!
Cheers
-
You need to use the eval(). Dont ask me why but you do. Something like Flash doesnt appreciate that youre actually refering to a mc until you do the eval.
Code should look something like this:
o = "name" + L;
newName = eval(o)
changedItem = setProperty(newName,,,,,)
HTH
-
I can hardly understand myself...
So do I…
I can send the fla-file if you think that you could help me!
Along with more clear explanations.
You need to use the eval(). Dont ask me why but you do.
Wow! What will happen if ask why should I need it. And may I show you that it's possible to do things without eval()?
Last edited by sergwiz; 02-28-2004 at 11:00 AM.
-
Hey, It worked!
thank you so much!
now I just have to deal with some other code issues. but compared to this it will be smooth...
-
Hi, sergwiz.
I don't quite understand you, but sure if you know a way around eval().
please...
But it actually works now..
with just 2 lines of extra coding...
/frenne
-
I would help you if you could explain to me what you are trying to do. I look at this code and I don't understand it.
if (n<e) {
duplicateMovieClip(bilder, ["bilder"+n], n);
if (n == 12 || n == 24 || n == 36 || n == 48 || n == 60 || n == 72) {
y++;
}
setProperty(["bilder"+n], _y, 50*y);
setProperty(["bilder"+n], _alpha, -10*n);
setProperty(["bilder"+n], _x, 50*(n-12*y));
}
n++
What is it "e"?
What is it bilder? Is it a name of MovieClip? If yes, then it should be this way:
duplicateMovieClip("bilder", "bilder"+n, n);
this["bilder"+n]._y = 50*y;
this["bilder"+n]._x = 50*(n-12*y)
How can work this setProperty(["bilder"+n], _alpha, -10*n);, if n>=10?
It would be better if you show your fla file.
-
Hi, its probably easier if I explain to you in plain text.
This section of the movie is a portfolio with around 100 projects which should easily be upgraded and can be sorted in different ways provided with dynamic text files.
By accomplishing this I've created a MC which in the first frame sets different variables to certain values, like "e" which is the total framecount of the movieclip "bilder". that mc contains thumbs of every project which should be published.
So, what the code which you quoted does is:
duplicates the mc "bilder" and places it in a grid with 12 thumbs horizontially and a couple of rows vertically depending on the framecount (e).
each movieclip get an offset value in alpha, like -220. So that I can in the next loop fade all clips in a "flow".
in the next loop I want to sort the text in different patterns, which is provided by a external text.
And that works with eval().
Do you understand me?
I'm from Sweden, I usually speak swedish. Please be patient
you wrote:
What is it bilder? Is it a name of MovieClip? If yes, then it should be this way:
duplicateMovieClip("bilder", "bilder"+n, n);
this["bilder"+n]._y = 50*y;
this["bilder"+n]._x = 50*(n-12*y)
the script I have now works, is it better to code it like you suggested it?
is it quicker or has any other advantages?
-
Senior Member
I recommend staying away from SetProperty unless you are publishing for Flash 4. It's the old way of doing things. If you want to access clip properties AND also access variables inside the clip, it's way simpler to use dot notation.
Example:
_root["clip"+L].myvar = 0;
or
_root["clip"+L]._alpha = 50;
As for what is eval(), eval means "evaluate by name" and is the old Flash 4 way that has now been replaced by just using these: [ ]
So, eval("bilder"+L) is the same as ["bilder"+L]
-
Senior Member
by the way, I just wanted to add that what really messed me up when i learned to use dot notation and [ ] was that you're not supposed to use a dot in certain places where logically it looks like there should be.
In the example I showed above, note that there is no period between "_root" and the variable to be evaluated as a clip name "["clip"+L]".
I know that makes no sense, but that's how Flash likes it. This for example would NOT be accepted:
_root.["clip"+L].myvar = 0;
~Ray
-
Hi, I have recoded my movie, and it is actually smoother since I swapped the setProperty.
Thanks!
but still the code doesn't work without eval().
could be since I need to form a variable by using a letter and a variable. I don't really know why...
But hey, it works. Thanks all, I would really be stuck otherwise
/Henrik
-
Ray Beez,
Cheers for the info about eval() and the new dot notation replacing setProperty. Will start using it in my next flash project - ah the joys of learning new code
-
thank you so much
It help me to much. It made 2 days I am on my Mysql links project. and it was the last fence.
Thanks
The Xbox H4cker on Nice/france
XecuterII
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|