actionscript-3


Array targeting trouble in AS3


Brand new to programming so I apologize in advance.
I'm trying to set up a game where after each time a button is pressed, a new instance of a MC is added to stage, then I need a collision detection for an existing object with any of the new instances of the MC. I need to add one instance to the stage at a time and once it reaches 8 instances, I need it to stop adding children but still be able to detect collisions with any of the instances. As it stands now it just replaces the MC or MCs into the new random position. Heres what my code looks like so far:
var pinkBox:pinkClass = new pinkClass();
var pinkArray:Array = new Array();
myButton.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownleftBtn);{
function mouseDownleftBtn(e: Event): void {
for(var i=0; i<8; i++)
{
addChild(pinkBox);
pinkArray.push(pinkBox);
pinkBox.x = Math.random()*stage.width;
}
myButton.startDrag();
}
}
addEventListener(Event.ENTER_FRAME, checkCollision);
function checkCollision(event:Event){
if (myButton.hitTestObject(pinkBox)) {
trace("hit")
}}

Related Links

Adding object to another sprite layer causes issues
Differentiate variables
Problems Scripting Multiple Buttons(nearly identical) in a single Action Script
AS3 “Error: Return value must be undefined”
How to make TextField gutter less?
why is only one actionscript working at a time?
On mouseover how to highlight an object's point so that I can draw connector from highlighted point
Access a integer variable through a separate Class
AS3 Remove Child to non public variable
Try to mask a textfield in actionscript
AS3 Pageflip effect: Page reversed when flipped
Bitmap graph drawing, how do you add thickness to a line?
AS3 not recognising MovieClips - 1046: Type was not found or was not a compile-time constant: MP_00
Unable read data from Socket
how to change background color of PopUp window in flex
Why is this method causing Flash to crash without even being called?

Categories

HOME
asp.net
autohotkey
skype-for-business
twitter-bootstrap
sip
ssh
weblogic
casting
apache-storm
cryengine
crm
sdk
collision-detection
virtualhost
osx-yosemite
bookmarklet
versioning
geography
spring-webflow
datasource
minimagick
lotusscript
waterfall
ckeditor4.x
orgchart
dynamic-memory-allocation
bytebuffer
r-factor
andengine
foxpro
ports
jsonapi-resources
perf
sdl-2
kepserverex
scalamock
contenteditable
uitextview
colorbox
easyquery
pyopenssl
jcs
playframework-1.x
boost-regex
grib
nsalert
stringbuilder
alfred
netlink
containstable
oryx
cascading
kramdown
windows-kernel
gulp-cdnizer
database-project
jsoncpp
p4python
firewire
esb-toolkit-2.1
cl.exe
nsnotificationcenter
selenium-grid2
telerik-appbuilder
reactjs-native
smartxls
opencobol
vbaccelerator
xtify
lastinsertid
android-library
database-restore
netzke
blackberry-eclipse-plugin
bindinglist
optimistic-concurrency
scsf
apache-commons-email
automapper-2
quazip
carbon-emacs
rpxnow
scala-designer
zend-acl
wtsapi32
cross-cutting-concerns
weak-typing

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App