FORUMS: list search recent posts

simple as3 codes

COW Forums : Adobe Flash

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Seth Jillson
simple as3 codes
on Aug 2, 2012 at 12:39:42 am

Can someone please download this file and help?

First off, don't hate. I'm new to as3 and i cant figure this simple code out. You need to click on the grenade in time before it blows up. Up to that point it works fine.

Where it goes wrong is you're supposed to hold down on the grenade and the meter goes up. If you release the grenade when the meter's in the middle color. When you hold down on the grenade, the meter doesn't go up. If someone could help me with these codes I would appreciate it.

Return to posts index

demetri tashie
Re: simple as3 codes
on Aug 2, 2012 at 4:45:38 pm

without looking at your file, i would say that this could be done a few ways. some ways are using either a TIMER Event or an ENTER_FRAME Event triggered by a MOUSE_DOWN to update a text field.

consider this scenario: a dynamic textfield ( your 'meter') with the instance name 'myText' has its value increased by a MOUSE_DOWN over a movieclip with instance name 'grenade'.

here is some full code which would make it work, using a TimerEvent:
import flash.utils.Timer;

grenade.addEventListener(MouseEvent.MOUSE_DOWN, meterUP);
stage.addEventListener(MouseEvent.MOUSE_UP, meterSTOP);
grenade.addEventListener(MouseEvent.MOUSE_OUT, meterSTOP);

var tim:Timer = new Timer(500);

var grenNum:uint = 0;

function meterUP(e:MouseEvent):void {
tim.addEventListener(TimerEvent.TIMER, startTimer);

function meterSTOP(e:MouseEvent):void {
tim.removeEventListener(TimerEvent.TIMER, startTimer);

function startTimer(e:TimerEvent):void {

myText.text = String(grenNum + 1);

there is a working example, as well as some further explanation, here: example

I hope that helps you work it out. if you have any further specific questions, please ask

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved