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
Similar Posts:
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
Aug 20, 2008
How do variables true/false custom variables work in flash?
For example, what I want to do is create a simple true=false variable that I can call on an if statement later.
For example:
Code:
Var1 = true;
if (!Var1)
{
[Code]....
I noticed that neither the "Var1 = true;" part or the if(!Var1) part worked in flash.
View 4 Replies
May 19, 2010
We have to deploy a flex app through a series of development tiers. We are not using Blaze_DS or LCDS. My data/service urls are tier specific and are currently embedded in AS files. We'll be building the project on each tier. I'd like to make them environment variables, but am not sure what the best way to do at compile/build.
Is there a compiler option to read in a custom-config.xml? or -myCustomVariable = value? or should we just setup the build to select a config.as file?ted.
View 1 Replies
Nov 29, 2004
I'm using Flash MX 2004.
PHP Code:
// function to automate the hit tests
function hitClip (aCPlaceNum, loopNum, loopName, aCButtonNum) {
[code]....
View 2 Replies
Apr 30, 2009
trying to learn Custom Events so that I can pass a variable through to a function that's fired when a Fade Out has been completed.
i.e.
Code: Select allvar tm:TransitionManager = new TransitionManager(movieclipname_mc);
tm.addEventListener ( "allTransitionsOutDone", TriggerThis );
tm.startTransition({type:Fade, direction:Transition.OUT, duration:2, easing:Strong.easeOut});
When the Fade Out is completed, the TriggerThis function is fired...
Code: Select allfunction TriggerThis(e:Event):void {
trace('triggered');
}
I want to pass a variable to TriggerThis though and I know that I need to use a Custom Event to do this. I tried creating a .as file containing the following:
Code: Select allpackage
{
import flash.events.Event;
[code]....
But this results in errors. Can anyone shed any light on how to pass the variables after a Transition has completed?
View 2 Replies
Apr 30, 2009
I've spent most of this afternoon trying to learn Custom Events so that I can pass a variable through to a function that's fired when a Fade Out has been completed.
i.e.
[Code]....
So I'm not sure that I'm even close to getting this right.
how I can pass variables to a function called when a Transition has completed?
View 3 Replies
Nov 29, 2004
I'm using Flash MX 2004.
[Code]...
Can you please tell me why this isn't working? It takes me 10 minutes to test the movie every time and it's taking me forever to fix things. Do I have to do something else with the variable names I'm using or something?
View 2 Replies
Jun 12, 2009
This is my first custom class and I'm having a few problems. I just want it to draw a line (for now) using variables from Flash. The .as file is attached. My Flash AS3 script is: var newLine:Myline = new Myline(20,210); I don't know why it won't just draw a line from 20 to 210? Here is the error I get:
[Code]...
View 16 Replies
Sep 28, 2011
does one protect this? I mean, Flash Cs5 ide has this little "protect from import" option but I don't think that's enough.I mean, the only thing I can think of is a scrambler.Something that would rename all variables, functions, and custom classes to some random hash. So something like myVar would be renamed to x41dDefh5kjFCe. It would be like a big "lol have fun" to someone who might manage to go that far.Still, that isn't enough. I mean, anyone else know of any good ideas or programs? Just trying to protect my work
View 9 Replies
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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