ActionScript 3.0 :: Input During A Holding Loop?

Apr 9, 2009

I have separated the background info on the "WHY", from the "WHAT" so that people can give me feedback on my question directly, but if they require more information, they can read my background info to understand the purpose of what I am doing.
  
======================================================
Background Info (the WHY):
======================================================

I am working with an actionscript structure as follows:On a specific frame exists a controlling function or "node".  It contains a user defined array of "branches" or sub functions.  These sub functions(branches) are of a user-defined class which can hold other code.  Other programmers will be using this structure.  When they work with it, they will be dynamiclly  adding new  "Branches" which the node will then run in whatever way they specify.  I am coding the node, and creating the different execution options that the other programmers will be able to use.
 
One of these types of executions is for the node to LOOP through the branches (however many there may be) waiting for either a key press or a mouse click.  On either input it should exit the node and continue on to the rest of the frame, and then the rest of the program.

My original structure is based on user defined Event Listeners and Dispatchers. Upon Entering the node I begin by defining:
 
addEventListener("BranchComplete",nextBranch);  addEventListener("RepeatDone",runComplete);
 
runComplete executes when the node has finished, nextBranch is fired after each branch has successfully finished.
 
I originally fired off:

dispatchEvent(new Event("BranchComplete"));  

as the last line of the Branch executing function.  The problem with this was, the function "nextBranch" does not return until all that it has called/triggered has finished.  "nextBranch" ends up being called recursively by the EventListener.  This causes a stack overflow.
 
I then changed the code, by moving the 'dispatchEvent' command into the same function that added the EventListeners.  This ensures the function "nextBranch" has finished and returned before the EventListener triggers it again.  This prevents the recursion and the stack overflow, but creates a new problem:  The 'DispatchEvent' only occurs once, as after the second time through the branch, it returns and continues on the line after the dispatch.
 
In order to get around this, i placed the dispatchEvent inside a do...While loop, that tracks a variable that is only set to false when the user gives Mouse or Keyboard input.  Voila, problem solved, code loops forever while calling "nextBranch" and triggering "BranchComplete" events as they complete.  The only problem is, user input doesnt seem to be caught, due to the infinitely repeating while loop.
 
To test that it does in fact work correctly, i set the While Condition to automatically turn false after 1000 iterations.  This works perfectly, and exits after 1000 branches have executed, all triggered by the Dispatched events.  So, I want it to loop through my Branches until Key press or Mouse click. It appears that during a while loop, Keyboard and Mouse Listeners will not trigger.  Is this true, and what is the best solution for holding in a loop while waiting for an event listener to trigger?

View 5 Replies


Similar Posts:


ActionScript 3.0 :: Adding Data To Array From Text Input Through Loop?

Jun 9, 2010

I am trying to add data to an array from the textinput which I have created through for loop, but not working.
import fl.controls.TextInput;
import fl.controls.Button;
var myBt:Button = new Button();
addChild(myBt);myBt.label="Submit";
myBt.x=50;myBt.y=200;
[Code] .....

View 4 Replies

ActionScript 2.0 :: Dynamic Name Of Input Text - Change MaxChars In Loop?

Aug 24, 2009

I have 10 text input. (txtin1, txtin2, txtin3,.....) I going to change the maxChars for every text input but I going to do that dynamic in a loop. I have tried
ActionScript Code:
txtin[nr].maxChars=maxnr;
But nothing happened. I know that the variable "nr" and "maxnr" have a number.

View 0 Replies

ActionScript 3.0 :: Loop Objects On Stage Input Text Check Box?

Oct 9, 2010

i have several check boxes and input texts on stage and would like to null out their values with a reset button but seem to be having issues, can anyone take a look

[Code]....

TypeError: Error #1010: A term is undefined and has no properties.
at Main/resetHandler()

View 9 Replies

ActionScript 1/2 :: Holding Down A Key: Execute ONCE?

Mar 28, 2011

scripting for holding a button down and having the action take place once.So thing is, I have code for pressing a button (which is the up arrow button)This was suppose to show the animation for someone shooting constantly until released:
 
if (Key.isDown(Key.UP)){        fox.gotoAndPlay(16);        deploy.gotoAndPlay(2);        trace("Pressed.");    }
 
Unfortunetly the results are:Holding down the up key places out "Pressed." constantly instead of once.fox.gotoAndPlay(16) stays on 16 rather progressing the animation (to which should come back to 16 at a repeated process)deploy.gotoAndPlay(2) plays a sound but before: the sound played constanlty rather once) recently: sound never playsI also need code that prevents the player from moving when holding down the up arrow key.So in total, I want the player to be able to hold the up key, and everything executed is played once until pressed agan after release.I heard about adding listeners:
 
var myListener:Object = new Object(); myListener.onKeyDown = function() {     KEY = Key.getCode();     if (!this[KEY]) {         trace("You pressed "+KEY);     }     this[KEY] = true; }; myListener.onKeyUp = function() {     KEY = Key.getCode();     trace("You released a key."+KEY);     this[KEY] = false; }; Key.addListener(myListener);
 
but I can't understand this technobabble and everytime I try to work it, it only puts error outputs.

View 7 Replies

Php :: Holding The Session In Flex?

Jun 23, 2009

I am getting the session generated in Flex Application in a hidden text field, but when i refresh the page it gets back me to login page...

How can i hold the session of the page until the browser is not closed...

I am getting the session value from PHP.

View 2 Replies

ActionScript 3.0 :: Pressing A Key Vs. Holding A Key Down?

Jan 15, 2010

How can I differentiate between these two actions in AS3? I'm working on a side-scroller,and I want to require the "attack" button to be pressed for each successive attackCurrently you can continuously attack by holding down the attack key. I'm using a standard event listener, i.e.

ActionScript Code:
private function keyDownFunc(event:KeyboardEvent)
{

[code]....

View 1 Replies

ActionScript 3.0 :: 2D Array For Holding MC's?

May 22, 2010

I have a mc which is a square. I want to make a grid with it. Everybody knows how a grid looks like. Heres the main issue: I want to have a full control over each single element of the grid. I want to put them all in a 2d array, so I can access them by giving a row and a column number, e.g, so as to remove a specific mc, Id write: container.removeChild[_myArray[i][j], where i and j stand for the row and the column.This is how my current method for creating the grid look like:

ActionScript Code:
private function drawGrid():void
{
var startX:uint = 0;

[code]...

It does draw a grid, but I dont have a power over it. And even if I do, I cant see any way of accessing a specific box.

View 3 Replies

ActionScript 3.0 :: Textfield Holding PlayheadTime?

Feb 1, 2010

I've created a textfield which I want to hold the time that is left of a flv being played. I also created a timer which will see to it that it gets updated.

Here is the code:
"import flash.utils.Timer;
import flash.events.TimerEvent;
var myTimer:Timer = new Timer(1000);
myTimer.addEventListener(TimerEvent.TIMER,updateCo untdown);

[Code]...

However, when i try to compile i get this error message: "1067: Implicit coercion of a value of type Number to an unrelated type String.

View 1 Replies

Php :: What Design Should Be Used For Holding File Information

Jul 31, 2011

I want to create flex/actionscript directory view for my files with php/mysql. I have some ideas that I want to share:

1)I am thinking of creating table (in mysql) "files" and another table "folders", when user loges in i will require all data from "files" and "folders" where Username = 'something'. But the problem is, I will create a lot of entries inside of tables. For example if I will have 100 users, and each user could create 100 entries (files or folders) it means that i will get 10000 entries inside table.

2)My second idea, and I think more safe way of doing it is creating table "users" where will be set id, username, password, ... , files, folders. In files (text format entry) will be listed information about files, and they will be dividend by "*" symbol like this:

id*file name*size(in kbytes)*path*status
example:
15*test.exe*150*/root/*private
16*test2.exe*200*/root/folder1/*public

[Code]....

Now here is only 3 file info but there can be more than 1000.

View 2 Replies

ActionScript 3.0 :: MC's Holding Custom Variables?

Nov 3, 2009

Having a bunch of dynamically-created MC's, what is the best way to store custom variables for each MC?Do I just make a hidden textfield inside each MC to hold the data?For example I have MC's called:-Apple1-Apple2-Apple3-etc...And inside each MC I have a variable appleEaten = X.And eventually I could use the data in an IF statement like:

View 4 Replies

ActionScript 2.0 :: Holding Instances In An Array?

Jan 24, 2006

I'm working on a project where I have Multiple instances with the same actions.

Instead of typing out

btn1._visible = false;
btn2._visible = false;
btn3._visible = false;
btn4._visible = false;

Could I store these instances in an array so that I could minimize my code to something like:

btnArray._visible = false;

I've tried to do this but it seems to read the instances as strings instead.

View 11 Replies

ActionScript 2.0 :: On(release) Firing When Holding A Key?

Apr 26, 2006

I'm working on a ACAD flash system, and one of the functions is to draw lines. Now I'd like to be able to draw vertical/horizontal lines by holding a key down (i.e. Shift). But I'm finding that the system is detecting me releasing the mouse (I'm not) while I hold another key.

Attached is a .fla file where you can click and drag a box.

Don't worry about posting "oh you should use startDrag()" and whatnot. The architecture of the actual application makes such things not feasible. This is just a test .fla.

The code is here:

ActionScript Code:
on (press) {
this.onMouseMove = function() {
trace('Mouse is moving');

[Code]....

So yeah, as you run it and drag the object around, you see a lot of "Mouse is moving", but if you press and hold any key, you'll also notice the "Mouse released" as well.

View 3 Replies

ActionScript 3.0 :: MC's Holding Custom Variables

Jun 22, 2010

Having a bunch of dynamically-created MC's, what is the best way to store custom variables for each MC? Do I just make a hidden textfield inside each MC to hold the data? For example I have MC's called:

[Code]...

And inside each MC I have a variable appleEaten = X. And eventually I could use the data in an IF statement like: if appleY.appleEaten == X then do something. What is the best method, or generally common way of doing this? Maybe I'm already doing it,

View 2 Replies

ActionScript 3.0 :: Holding A Button On The Down State?

Oct 19, 2010

I need to have the user click on a button, and until another button is clicked, keep that button on the "Down" state.

View 2 Replies

ActionScript 3.0 :: FullScreen On Container Holding Image?

Oct 5, 2008

Working on an important piece at present; I need to make theimage wihtin a holder_mc go fullScreen, not the whole interface.Heres my code thus far:

masker.addEventListener(MouseEvent.CLICK, fullScreen);
function fullScreen(MouseEvent):void
{

[code].....

View 8 Replies

ActionScript 2.0 :: Holding Down A Button - Looping Code?

Aug 13, 2009

ActionScript Code:
_root.UpnDown_mc.up_btn.onPress = function () {
_root.Website_mc._y += 30;
[code]....

very simple code, you press the down button on the screen and the page moves down, and similarly for the up button, by 30 pixels...but it only happens once? I need it to continue for as long as the button is being held down.I have tried placing it within the onEnterFrame event, but it still only occurs once.

View 1 Replies

ActionScript 2.0 :: Holding Space, Increase Variable?

Nov 20, 2005

right now, my code looks like this:

Code:
onClipEvent(load){
speedy = 1.1;
gravity = 9.82;

[Code].....

What I want is that the flash should wait until I've finished pressing space, and the longer I hold in space, the bigger the variable speedx is. I can hold it in right now, but the ball will fall before I've released space. I'm really new to this so please be nice

EDIT: the flash is a ball that "throws", and the code is on the ball, which is a movie clip.

View 2 Replies

ActionScript 3.0 :: Flash Arrays Holding Functions?

Sep 8, 2011

Is it possible to put a function into an array and execute it from calling it via the array?I did this before in as2 [code]

View 2 Replies

ActionScript 3.0 :: Mouseovers Only Work When Holding Down Mouse Button?

Dec 10, 2009

My flash piece is not responding when I mouse over it, unless I hold down the mouse button while I do it. It's as if the flash object is actively surrendering focus unless I hold down the mouse button or something.

View 1 Replies

ActionScript 2.0 :: Move MovieClip On Holding Down Left Arrow Key

Mar 12, 2007

Basically I wanna remove my mc "ball" when you press the left arrow key. I've tried stuff like
Code:
if (Key.isDown(Key.LEFT)){
ball._x -= 1;
}
Some reason gives me like, "needs clip events"

View 6 Replies

ActionScript 3.0 :: Make A Slideshow Holding 3 Images With 3 Different Categories?

Aug 13, 2009

I'm trying to make a slideshow holding 3 images with 3 different categories. The images is loaded through an XML-file.

My xml looks like this: (the number after IMAGE[] indicates the category)

Code:
<?xml version="1.0" encoding="utf-8"?>
<SLIDESHOW SPEED="2">
<IMAGE1 URL="images/1.jpg"/>
<IMAGE1 URL="images/2.jpg"/>

[Code]....

View 8 Replies

ActionScript 2.0 :: Putting A Loop "on Hold" Until User Input?

Aug 3, 2007

i have a loop that moves a game piece every time a dice is tossed using tweens (i loop the movement the amount that comes out on the dice). it all works fine.

the problem is that when mid movement i need to ask a user a quesition with a popup movie with buttons that would determine the movement - i cant pause the loop.

basically i need to know how to put a loop on hold until further user input

if i have a loop that increments a number by one until it hits a predefined amount- i want to pop up a menu that would ask the user if he wants to continue incrementing the number by 1 or by 2. I still want the loop to run a total set amount of times (lets say 100)

View 1 Replies

ActionScript 3.0 :: Dynamic Text Field Holding XML Does Not Scroll Through Http?

Aug 1, 2007

I have created a flash file using XML to populate a dynamic text field. I have a UIScrollBar componant added to my text box to scroll through the XML. The movie works fine both when testing the movie in flash and when I access the file that is stored locally through IE. As soon as I upload the file to my server, however, the scrolling functionailty no longer works. The XML is visible on the site and it is possible to scroll using the mouse wheel; the bar itself, however, appears to be disabled for some reason.

View 9 Replies

ActionScript 2.0 :: CS3 Sliding - When Running And Not Holding Keys Down Then The Friction Should Slow Me Down

Nov 12, 2009

when I'm running and not holding my keys down then the friction should slow me down. That works but the speed never stops at zero. I can't see him moving but I've put a text that draws his speed, because if the speed isn't zero and I'm not pressing any button then he will slide and that doesn't work look here: [URL]
The code in the player I use is:

[Code]....

View 1 Replies

ActionScript 3.0 :: Making Game - Zoom In And Out By Holding And Letting Go Of The Space Bar?

Dec 28, 2010

I am making my first game and it's my first time using actionscript. I am making a sniper game themed with the L96A1 sniper rifle from COD: Black Ops and the map nuketown. I'm in cs5 with ac3 and on my stage I have two movie clips that I'm working with. I'm not really sure if they're supposed to be movie clips though. Anyways, one is the gun, and the other is the zoomed in scope overlay thingy.

For now, I'm trying get the zooming in to work. I haven't done anything else though except collect graphics for enemies, the landscape, the gun, and the scope. I want to make it so that you zoom in and out by holding and letting go of the space bar. Also,I want to make it so that when you are not zoomed in, the gun moves horizontally at the bottom of the screen (aligned vertically with the cursor). And when you are zoomed in, the scope crosshair is the cursor.So my idea was to set the gun as the cursor and make it only move horizontally at the bottom of the stage and then make an event listener that listens to when the spacebar is pressed and when it is, disables the gun as the cursor (and makes it transparent to get it off the screen) and makes the scope the cursor [was transparent, now opaque and unrestricted(vertical movement also)].

I got as far as making the gun move horizontally at the bottom with the cursor. I cant get the event listener working because I don't really know how to go about changing the opacity of each movie clip and how to switch cursors. So I am asking how do I change the opacity and switch the cursors when the spacebar is held and then reverse those changes when the spacebar is released? Here's my code on an "actions" layer [I haven't done any animations yet, so everything is on frame 1. Also, I used a couple preset code snippets since I have no previous experience with actionscript (I can understand most of it though)]:

Code:
import flash.events.KeyboardEvent;
// make gun cursor
stage.addChild(gun);[code]..........

Here's a link to a zip archive with all the files used so far (I hope this google docs link works): link

View 2 Replies

Professional :: Incrementing A Number In A Text Field By Holding A Button?

Feb 2, 2010

is there any way to increment a display number up or down my clicking / holding a button?
 
im making a project to select a fuel tank capacity and want the default to be 0.0 gallons and have the user increase the number or decrease the number by clicking and up or down arrow button... If they hold the same button that function would ideally increment faster, perhaps by multiples of ten until it reached a max / min number.

View 16 Replies

ActionScript 2.0 :: [FMX] Make A Couple Of Movieclips Hide On The Holding Down Of A Key - Command

Jan 20, 2003

I am trying to make a couple of Movieclips hide on the holding down of a key such as Page down ive used this:

[Code]...

it hides the MC but doesnt return visible on release of PGDN. Ive had a go at trying to fix this but i cant find the right command in the actionscript dictionary. Also is it possible for the MC to hide only on the holding down of multiple keys.

View 2 Replies

ActionScript 3.0 :: Making References To All The Subclips In The Enemy Animation And Holding?

Jun 7, 2009

Recently I've been developing in a certain way that i'm not sure is wise, so I thought I would ask the guru's here for guidance. Let's say I'm developing a game with an "Enemy" class. Recently I've been making references to all the subclips in the Enemy animation and holding them in my class as variables, so for an Enemy called "Troll" i might have variables in the class saved as:

private var _walkAnimation:MovieClip;
private var _runAnimation:MovieClip;
private var _attackAnimation:MovieClip;

and then reference these whenever I need to flip between the animation states for that Enemy instead of using getChildAt() or getChildByName() to find the relevant subclip every time I wanted to reference it. I was once told saving CPU was more important than conserving memory in cases such as this, but I wanted to make sure this was true. Your thoughts?

(I call a dispose() or destroy() function when I remove enemies so the references can be Garbage Collected)

View 2 Replies

ActionScript 3.0 :: Replace Div Holding Flashplayer With Blank And Swf Movie / Buttons Disappear

Mar 19, 2011

I replace div holding flashplayer with blank and my swf movie/buttons disappear. All good. However, when I right click the mouse over the area, the flashplayer is indicated as still being there. How is this possible if the contents of the div is replaced with " "? The flashplayer, not recognizing Z-index interferew with drop down menues.

View 5 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved