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.
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
I just added columnWidthRatio: 1; to my mx|ColumnChart to fatten up my columns a little. But now, there's no space between the X axis and columns, and between the columns themselves, so how do I increase this space?
I have a var defined and that is colour var colour = 0; and I want to increase var everytime you press space so I have an invisible button with this code in it
on (keyPress "<Space>") { colour+1; }
This is so that I can advance in a movieclip. I have the code for that here:
onEnterFrame; { if (colour == 1) { head.gotoAndStop(1); }
I have a line of 12 horizontal placed buttons. I want whatever button is rolled over to get larger (no problem), but I need the other buttons to slide over to allow for the new size that the larger one would bring. I have no idea what type of code I should be looking for here.
I have an overlay that I pull up in response to a button click. This overlay is dynamically populated by a TextField, a MovieClip, and a Bitmap. I used to add them to the overlay with addChild() and induce a index out of bounds error to make them go away (I was in a hurry and I don't think I'm using removeChild() right). Well, I decided to do it better and dynamically change the object inside the holding variable. However... the Bitmap is gone. It won't appear. The overlay puller function takes a data-holding class I made and the picture is a BitmapData object.
I can't use the line new Bitmap(picture) because it doesn't work; that makes nothing appear. So, I guess my question is can I store a line of text in a variable and then use that variable as code? Like... Could I have something like this and get an image as an output? I imagine it could be done with XML, but is there another way? I tried storing the constructor in a variable and calling it with object.constructor, but I don't know if I was using it right and it didn't work.
I have this code, which should work fine, but it doesn't.
Unit1_Mobs_Destroyed += 1;
Text="Unit 1 destroyed "+Unit1_Mobs_Destroyed+" Mobs!" It should set Unit1_Mobs_Destroyed to current value + 1 If Unit1_Mobs_Destroyed is 5 at the start, it should be this: Unit 1 destroyed 6 Mobs But that doesn't happen instead I get this: Unit 1 destroyed 5 1 Mobs
i have a variable that i want to increase when you click somthing. the code im using is this but its not working
on (press){ w/e++; this.startDrag; }
i may have written the start drag wwrong but thats not the problem the variable wont increase. How can i do that? if what im doing isnt possible with as2, the reason im doing this is because i want my "game" to start after you get ready, so people arent caught off guard from starting right away and having a falling object not be caught.
I want to use two buttons, one for increase and the other for decrease, to change the numeric value of a variable. I will use this variable to call a line width in some lineStyle code that I have. Basically, the user will be able to use the buttons to change the width of the line they are drawing in real time. I have attached the fla with the beginnings of this section.
I am using the attachMovie script in as2 and I want to use a counter variable to increase the depth each time so it doesn't replace the last one. Every tutorial i've seen for attachMovie mentions this but I can't find any information on how.
Also is it possible to use a different counter variable to change to y position of the attached movieclip, so that it adds another beneath the last every time.
I am wondering if anyone has experience this problem before:
[Code]...
I was experiencing some other "strange" behavior so I'm wondering if my code is getting too long. Maybe I'm running into some kind of limit. Has this happened to anyone else? Anyone know of some fixes? The loop is in a _global function, could that be causing a problem? other than that, the code is on line 4420 of the actionscript coding interface.
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.
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) {
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.
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.
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:
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?
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:
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:
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.
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,
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.
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.
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"