Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0

Reply
 
Thread Tools Rating: Thread Rating: 5 votes, 5.00 average. Display Modes
Old 09-10-2006, 09:18 PM   #1
gobadgrs
Registered User
 
Join Date: Feb 2005
Posts: 105
Default How do I set X and Y coordinates for variables with numbers on the end?

Here is what I have.

Code:
variable = "test";
for(z=1;z<=16;z++){
attachMovie("thumbs",[variable+z],z)
so I end up getting variables named
test1, test2, test3, etc.

Thats what I want.

What I cant figure out is how to dynamically set their X and Y coordinates.

Bascially, I want the movie object to get created and then set the X and Y after its made.

So it would be somelike like this in pseudo code

make test1 variable
set x coordinate for test1 variable
set y coordinate for test 2 variable

I've tried the below wiht no success
Code:
[variable+z]._x=100;)
gobadgrs is offline   Reply With Quote
Old 09-10-2006, 09:43 PM   #2
Kraken
Flash beneath the fathoms
 
Join Date: Apr 2001
Location: Kansas City
Posts: 678
Default

It's all about scope. Where is your MC? On the main timeline? Inside another MC? Where is it in relation to the function and/or the button calling the function? You must know where things are in relation to each other in order to affect them.

The second thing is attachMovie and createEmptyMovieClip return a reference to the newly attached, or created, MC.

So, if you are attaching MCs to the main timeline, and your function is on the main timeline, do something like this:
ActionScript Code:
var myroot:MovieClip = this; var totalClips:Number = 16; for (z=0;z<totalClips;z++) {   var tmp:MovieClip = myroot.attachMovie("thumbs","thumbs" + z,30 + z);   tmp._x = 100 + z;   tmp._y = 100 + z; }

one final note, if you need to find them later, the variable "tmp" will not be around since it is a local variable. But, you can find them like this:
ActionScript Code:
myroot["thumbs" + myNum]._x = 400; myroot["thumbs" + myNum]._y = 200;
__________________
The coolest website ever!
Visit my friend Ray's site.
Kraken is offline   Reply With Quote
Old 09-10-2006, 09:44 PM   #3
Syllogism
capt. Obvious
 
Syllogism's Avatar
 
Join Date: Aug 2006
Location: South Africa
Posts: 826
Default

var home:MovieClip = this;

for(var i=0;i<16;i++)
{
var t = home.attachMovie("item","item"+i,i+1);
t._x=300;
t._y=110;
}

like so: firstly put the created mc into a variable (t, in this case) and then change the values of the variable. You may wanna do something like;

t._x = i * 50;

that way the first one's x will be 50, the second one 100, etc...
you need a mc in your library with export for actionscript ticked under linkage and with an identifier named "item" (you probably already knew that but can't hurt to be thorough)

Syllogism
Syllogism is offline   Reply With Quote
Old 09-10-2006, 09:48 PM   #4
Syllogism
capt. Obvious
 
Syllogism's Avatar
 
Join Date: Aug 2006
Location: South Africa
Posts: 826
Talking

looks like Kraken beat me to it. By 1 minute! DAMN YOU KRAKEN!!! why do you continue to undermine me !!!
Syllogism is offline   Reply With Quote
Old 09-10-2006, 10:12 PM   #5
Kraken
Flash beneath the fathoms
 
Join Date: Apr 2001
Location: Kansas City
Posts: 678
Default

I am the underminer! I am always beneath you, but nothing is beneath me!

__________________
The coolest website ever!
Visit my friend Ray's site.
Kraken is offline   Reply With Quote
Old 09-10-2006, 10:16 PM   #6
Syllogism
capt. Obvious
 
Syllogism's Avatar
 
Join Date: Aug 2006
Location: South Africa
Posts: 826
Default

What's that you're sitting on?
__________________
S y l l o g i s m, Cptn Obvious

"I think you'll find my argument is flawless [Citation][Citation][Citation]"
Syllogism is offline   Reply With Quote
Old 09-10-2006, 10:18 PM   #7
Kraken
Flash beneath the fathoms
 
Join Date: Apr 2001
Location: Kansas City
Posts: 678
Default

oh yeah...well, except the chair.

and sorry, that was a quote from the Incredibles!
http://www.nerf-herders-anonymous.ne...Underminer.jpg

I've been watching it too much with my kids lately
__________________
The coolest website ever!
Visit my friend Ray's site.
Kraken is offline   Reply With Quote
Old 09-10-2006, 10:31 PM   #8
Syllogism
capt. Obvious
 
Syllogism's Avatar
 
Join Date: Aug 2006
Location: South Africa
Posts: 826
Default

I see your location is "here" As you probably don't know "here" means god in dutch(well it does in Afrikaans anyway, which is the much cooler version of dutch). As you also probably don't know the dutch are a bunch of rabidly violent bible bashing super zealots. (you would of course not know this seeing as I just made it up)

So don't be surprised if a tall, orange-clothed, psychopath clobbers you over the head with a clog for taking the lords name in vain.

Don't say I didn't warn you.
__________________
S y l l o g i s m, Cptn Obvious

"I think you'll find my argument is flawless [Citation][Citation][Citation]"
Syllogism is offline   Reply With Quote
Old 09-10-2006, 10:40 PM   #9
Kraken
Flash beneath the fathoms
 
Join Date: Apr 2001
Location: Kansas City
Posts: 678
Default

So, wait a minute...I should be watching out for an Afrikaans-speaking religious zealot from the Netherlands wearing orange clothing and wielding clogs? Yikes!
__________________
The coolest website ever!
Visit my friend Ray's site.
Kraken is offline   Reply With Quote
Old 09-10-2006, 10:56 PM   #10
Syllogism
capt. Obvious
 
Syllogism's Avatar
 
Join Date: Aug 2006
Location: South Africa
Posts: 826
Default

No no, not Afrikaans speaking zealots. Those are fairly harmless. It's the dutch speaking ones you gotta watch out for. Afrikaans speaking people are from South Africa, When the dutch colonized South Africa 10 zillion years ago they forgot to take their language with them and it eventually evolved into (the much cooler) Afrikaans. An example:

Afrikaans: "ek gaan vir 'n rukkie buite"
translation: I'm going outside for a while.

Dutch: "ek gaan vir 'n rukkie buite"
translation: I'm going for a wank ouside.

If you don't know what wank means ask one of your kids. Anyway my point is clear. Dutch, the language for sexually obsessed deviant zealots. Afrikaans, the language for people how like to go outside for small periods of time. On reflection, it may be better to have a wild night on the town with a dutch person and settle down and get married with a nice South African girl. the whole having your cake and eating it thang.
__________________
S y l l o g i s m, Cptn Obvious

"I think you'll find my argument is flawless [Citation][Citation][Citation]"
Syllogism is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Meter with running numbers SamCamp ActionScript 2.0 0 02-10-2006 06:47 AM
help -- shrinking distance between x,y coordinates wuuf ActionScript 2.0 5 11-30-2004 03:07 AM
need help with unique numbers rkdresden ActionScript 1.0 (and below) 2 06-02-2004 10:10 AM
localToGlobal = unexpected numbers Jessica lucidiastudios ActionScript 1.0 (and below) 17 08-29-2003 09:49 AM


All times are GMT. The time now is 08:40 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.