Home Tutorials Forums Articles Blogs Movies Library Employment Press

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

Reply
 
Thread Tools Rate Thread Display Modes
Old 08-21-2012, 02:27 AM   #1
jeteran
Registered User
 
Join Date: Aug 2012
Posts: 23
Red face Detecting an object inside another object, but in different frames?

Hello once again.

Ok this is another thing that is driving me crazy.

I'll do my best (as always) to explain everything I do.

I have an scene (called mision1) that inside has 3 frames, room1, room2, and room3. Inside each room it has 2 static MCs. Besides this, I have a character that moves in .x

Ok now, what I want to do is that, in each room, when that character hitTestObject the objects AND the mouse is clicked over that object, action something.

So far, this is done correctly, like this:

Code:
if (roomPosition == "room1")
	{
        	if (mouseObj.hitTestObject(mision1.object1_1_1) && (person.hitTestObject(mision1.object1_1_1)))
		{
			trace("object1");
		}
(The code for the object is: object[number]_[mision: in this case 1]_[room: in this case 1])

This is great, even though I tried the following but I had problems, using nameObject as event.target.name (that throws me the name of the object):

var nameObject = event.target.name

but when I tried to compare it with the mouseObj, says something about they are not the same class or something (sorry I'm tired right now, can't remember).

OK but thats another subject, the thing is that when I try this:

Code:
else if (roomPosition == "room2")
	{
	if (mouseObj.hitTestObject(mision1.object4_1_1) && (person.hitTestObject(mision1.object4_1_2)))
		{
		trace("object4");
		}
Tells me that the object is null; I think (I truly think) is because the room2 is in another frame of the mision1 MC.

So I though in 2 alternatives:

1) That I find a way to access all the objects no matter what frames they are.

2) Separate each room of the first mission in different MCs so I have mission1room1 MC, mission1room2 MC and so on; and of course, each of them will have only 1 frame.

Right now, the structure to the code is made to function having that 3 frames inside mission1. I think that, in that way, my code will be cleaner if I just can make "alternative 1)" to function (based too that I will have a total of around 60 rooms in the game)

What can I do?? If "alternative 2)" is the way, I will change everything and stick to it (haven't try it, but I think will correctly function)

Thanks so much guys for your time !!
jeteran is offline   Reply With Quote
Old 08-22-2012, 01:03 PM   #2
jeteran
Registered User
 
Join Date: Aug 2012
Posts: 23
Default

Ok I'm going to try to separate each room to see what happends !!
jeteran is offline   Reply With Quote
Old 08-23-2012, 01:16 AM   #3
jeteran
Registered User
 
Join Date: Aug 2012
Posts: 23
Default

Hello once again.

I did a little experiment.

I create an 2D array that has, in the fist column, the current room and in the second column the objects inside it.

So far so good. The thing is:
1) I created them one by one because I couldn't use the nested FORs for it. Any suggestion?
2) Inside the room, there are the objects. Even though, I create the instances inside the code. Now, I'm trying to add a listener to the first object of the first room (array[0][1]) but it doesn't trigger, what can be? I tried to add the listener to array[0][0] and works great! :S


Thanks guys for all your help, I'm very enthusiastic by the results so far !!
jeteran 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 On
HTML code is Off

Forum Jump


All times are GMT. The time now is 09:29 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.