Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Remember me

Go Back   Tutorialized Forums2D GraphicsFlash

Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
Unread Tutorialized Forums Sponsor:
Old June 9th, 2011, 04:42 PM
hanslow hanslow is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
Join Date: Jun 2011
Posts: 1 hanslow User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 m 8 sec
Reputation Power: 0
Iterate over multiple objects AS2

Hey guys,
I'm making a flash game in AS2 and I would like to do a hitTest on multiple objects on the _root timeline. The following code works:

if (this.hitTest(_root.bg.box1)
|| this.hitTest(_root.bg.box2)|| this.hitTest(_root.bg.box3)
|| this.hitTest(_root.bg.box4)|| this.hitTest(_root.bg.box5)
|| this.hitTest(_root.bg.box6)|| this.hitTest(_root.bg.box7)
|| this.hitTest(_root.bg.box8)|| this.hitTest(_root.bg.box9)
|| this.hitTest(_root.bg.box10))
//code goes here
where "bg" is my background and the different "box" objects are within the background.
I was wondering if anyone could help me to use a "for" loop to iterate over all of the "box" objects so that I don't need to write out "box1,box2,box3, etc......"

I have tried something like the following:

for (var i:Number = 1; i<11 ;i++)
{//code goes here
}//end for loop

I think the trouble lies in the line "this.hitTest(_root.bg."box"+i)".

Your help is appreciated!

Reply With Quote

Viewing: Tutorialized Forums2D GraphicsFlash > Iterate over multiple objects AS2

Developer Shed Advertisers and Affiliates

Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.

© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap