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

Flex 3: ColorPicker Customization
FB 4.6 Data Services from local XML file - how to advance to next record?
Width of a group in mx:ViewStack
New Tween not working correctly
Drag-and-Drop - Limiting duplicate MCs for single use in targets?
AS3: can't addchild indexed movieclips into a sprite
How can I track all of my Box2D collisions in a clean, manageable manner?
ActionScript 3: waiting for user input in the middle of a complicated chain of actions
Adding Value of Variable To a Label
how to make an MovieClip transparent?
Drawing the exact region of the Bitmap in as3
Problems loading XML file (url cannot load) on local machine
Removing event listeners in for loop
Getting blank screen from packaged air desktop application
flash: drawing and erasing
Where should these AS3 variables go?

Categories

HOME
typo3
gsm
azure-eventhub
dynamic
reference
azure-database-mysql
boxplot
ebay
confluence-rest-api
sugarcrm
kohana
zabbix
handlebars.js
wavefront
android-webview
rtc
phpexcel
dcos
ethereum
angular-universal
websharper
element
lambda-calculus
greensock
android-actionbar
md2
url-parameters
custom-component
restructuredtext
functional-dependencies
tftp
boosting
folder
ios9
foxpro
multilanguage
ibm-bpm
qt-designer
imageprocessor
odp.net
android-geofence
origami
gem-fury
fisheye
mixed-models
file-descriptor
quartz
autodesk-data-management
wufoo
reqif
line-endings
jcs
senti-wordnet
apache-commons-cli
catalyst
google-scholar
sharing
turbolinks
change-password
avaudiorecorder
radar-chart
trendline
alchemy
containstable
taverna
hexagonal-tiles
dcg
valdr-bean-validation
crtdbg.h
dojox.grid
dotcmis
msdropdown
behance-api
winrun4j
infor-eam
pthreads-win32
autofilter
logo-lang
nop
ie-developer-tools
ironworker
forward-declaration
codeigniter-form-helper
ntdll
linear-interpolation
php-gettext
systrace
sqlbuddy
joomla1.7
scsf
automapper-2
overlays
lightopenid
quazip
carbon-emacs
hp-trim
vista64

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile