Coding question

i have a series of maps all of which have rooms on them and i’m making a locator for those rooms. i have an input box where the user can put the number of the room and the movie will go find it when they click the go button. there are 500 or so rooms. the first idea i had was to have an if statement for every room


on (press) {
	if (_root.room.text == "2140C") {
		_root.map.gotoAndStop("f2");
		_root.endX = -80;
		_root.endY = -50;
	}
}

that tells an MC ‘ball’ the _x and _y that it needs to go to, to be over the room on the map

or i thought i could have a blank MC on the map over the location of each room and tell ‘ball’ to go to the _x, and _y of the blank MC that corresponds to the room number that has been typed in the input field.

i really hope there’s a more simple way but i can’t think of any

Hi,
Not sure I have this right, so tell me, does each room have its own frame ?
OR
are you displaying 500 rooms on one image ?

If I have the first part right, all you need to do is name the frames after the room numbers ( I assume 2140C is a room number ), then your code would like like this:
[AS]on(press){
_root.map.gotoAndStop(room.text)//I will have to check the syntax here//
}[/AS]

The second way, you could try writing an array, and calling the array item from room.text, thats a bit more complicated, but probably more efficient. Either way looks like you are in for a lot of typing.

Cheers

SteveD

right …i expected a lot of typing and the frame thing is another one i thought of but opted against b/c at the moment … ‘ball’ moves from it’s previous location to the location of the new room … if it were just frames then it would just jump

i thought about an array but i don’t know how that would work. with 500+ rooms i am very interested in effeciency for the flash player.

and yes 2140C is a room number

any ideas on how the array would work?

Hi,
Haven’t had the time to test this yet, you may need to play around with it a bit, but the simplest form I think of is:

[AS]myArray = new Array(2140C, 2141C, 2142C and so on for all the room numbers);
for (i=0; i<myArray.length; i++){
if(myArray*==room.text){
trace(“success”);
}
}
[/AS]
Type a room number into your texwt box, if you get a trace success, then just change the trace code to want you want to happen.
Let me know how it goes

Cheers

SteveD

well it sorta works but not really. it traces success but it’s because the value in the text box is equal to one of the values in the array. but none of the others

so if you also check for inequality and then trace you get one success and two unsuccessfuls with each press of the button

i need to be able to specify 3 values per room, like the if statement in my previous post

if room = 2140C
then varX = 50
and varY = 80
and varZ = 3

the vars will be different numbers for each room … like x and y coords of the room on the map and then the value of the floor on which the room is located

so i’m not sure how this code setup would work for that :frowning:

sniffle i wish i could figure this stupid thing out

Hi Shuga,
First an apology, I posted that late last night, tired and didn’t look at what I had done, you need to set up a 2 frame loop so that the array is constantly checked. To assign more than one value, you need to write a sub array, not absolutely sure how that works myself.
If you have a test file you can post I will play around with it myself ( as it really is about time I knew these things for myself)
If the file is to big for Kirupa email me here and I will see what I can do

Cheers

SteveD

i posted the question again with a sample file so hopefully some more people would look at it … since not many people tend to help on a post once one person has responded

here’s the post http://www.kirupaforum.com/forums/showthread.php?s=&threadid=20794