actionscript 3 - Can't make MovieClip in function dissapear -
i'm trying make simple shooting game fiat multipla falling bottom of screen. have created function generate falling multipla , within function have problem.
the main issue after change of multideath status 1 "death" function nothing if kept enter_frame. child becomes invisible implemented in multipla movieclip, after response there death = 1, nothing happens.
i'm new this, i've met , solved few issues during programming, here's brickwall now. code's either failing or don't know that's obvious. said, i'm newbie.
thanks lot help!
here's function:
import flash.events.event; import flash.desktop.nativeapplication; multitouch.inputmode = multitouchinputmode.touch_point; mouse.hide(); var velocity = 0; var ammo = 6; lgui.lguiammo.gotoandstop(6); var counter = 0; function multiplarain() { var x1 = math.ceil(math.random() * 280); var y1 = -200; var random:multipla = new multipla(); var life = 265; var multideath = 0; random.x = 100 + x1; random.y = y1 addchild(random); random.gotoandstop(1); setchildindex(random, +1); addeventlistener(event.enter_frame, death); function death(event:event):void { if(multideath >= 1) { removeeventlistener(event.enter_frame, death); removechild(random); } } addeventlistener(event.enter_frame, fl_enterframehandler); function fl_enterframehandler(event:event):void { if(random.y >= 680) { removeeventlistener(event.enter_frame, fl_enterframehandler) removechild(random); trace("rofl"); } } random.addeventlistener(event.enter_frame, fl_animatevertically); function fl_animatevertically(event:event) { velocity = velocity + 0.000035; random.y += 1.5 + velocity; } random.addeventlistener(touchevent.touch_tap, fl_taphandler); function fl_taphandler(event:touchevent):void { counter = counter + 1; ammo -= 1; } if(ammo == 6) { lgui.lguiammo.gotoandstop(6); } if(ammo == 5) { lgui.lguiammo.gotoandstop(5); } if(ammo == 4) { lgui.lguiammo.gotoandstop(4); } if(ammo == 3) { lgui.lguiammo.gotoandstop(3); } if(ammo == 2) { lgui.lguiammo.gotoandstop(2); } if(ammo == 1) { lgui.lguiammo.gotoandstop(1); } if(ammo <= 0) { lgui.lguiammo.gotoandstop(7); } hgui.saved.text = counter; this.addeventlistener( event.enter_frame, handlecollision) var kucyk = lgui.lguilife.lifeitself; function handlecollision(e:event):void { if (random.hittestobject(lgui)) { kucyk = lgui.lguilife.lifeitself; kucyk.width -= 0.1; } /*if (kucyk.width == 0.75) { trace("cycki"); nativeapplication.nativeapplication.exit(); }*/ } }
and here's multipla's movieclip in library code:
multitouch.inputmode = multitouchinputmode.touch_point; this.addeventlistener(touchevent.touch_tap, fl_taphandler2); function fl_taphandler2(event:touchevent):void { this.gotoandplay(2); } addeventlistener(event.enter_frame, fl_enterframehandler); function fl_enterframehandler(event:event):void { if(this.currentframe == 60) { this.visible = false; movieclip(root).multideath = 1; trace(movieclip(root).multideath); removeeventlistener(event.enter_frame, fl_enterframehandler); removeeventlistener(event.enter_frame, fl_taphandler2); } }
it's been 10 years since last time worked as2 i'd guess multipla sets multideath property in wrong place. if remember corrctly, root top-most level (your application). if first code not on main timeline in movieclip on main timeline won't work. try put trace death function see if multideath changing there:
trace(multideath);
try in multipla code:
parent.multideath = 1;
instead of
movieclip(root).multideath = 1;
and i'm asking myself why need many enter frame listeners? can have 1 , combine animations in 1 function.
also don't need check multideath on every frame, remove movieclip in separate function:
function removemultipla():void { removechild(random); }
just call function multipla instead of setting multideath property:
parent.removemultipla();
Comments
Post a Comment