Actionscript 3.0 :: 2 Addeventlisteners 1 Function
Sep 1, 2009
Don't care about that squares that is inside the functions, I'm just using it as a example.I'd like that both eventlisteners when removed use the same onclick3 function, in the following code they recognize the onclick3 because it is outside of the eventlisteners. So, how can I remove the eventlisteners and both of them use the same onclick3 function?
[code]...
I need both of them to use the same onclick function, and not 2.
The following creates movieclips from XML. Everything worksgreat.One problem however. I need each MC to have it's own mouse event listener anddon't know how to achieve this because I don't have specificinstance names to refer with. I want to update textfields etc, with specific data when a
i have to make a drag and drop thingy in actionscript 3.0. Now we had another actionscript project before and then i had some extra classes but most things i put in the main class and it was all working fine. Someone told me that i put too much in my main class and that i should make more classes like a class for every object you interact with. Dont know if hes right but he acted like he was.
Now back to the problem. I made a main class connected directly to my fla in its properties. Then i made another class for the game itself, cause maybe it needs an intro and other things so i want to separate them in their own classes and start them with the main class. now in the class for the game itself i want to be able to click an object with the mouse. I was just testing with a trace. When i click the object it only traces like 1/20 clicks i make, tryed alot of things, when i put the same code in the main class with stage.addEvent blabla it will respond every time but as soon as i try to put in the class for my game it only responds like 1/20 times i click. Wth?
Now i can put all my code in the main class again and make another 1000 line code with a couple of other small classes but this time i want to do it right so what am i doing wrong? Heres some code too
This is the main class dressUp is the game class, it doesnt do much just define the game class and change the mouse pointer.
EDIT: We work in a project group so another reason i want to make alot classes is so we can work on different classes separately. But i promised to have this done this weekend and there not so good in actionscript either.
I have created a simple game which is started by a start button in a Movieclip that opens at the beginning using the code : var splashscreen:MovieClip = new Splash(); splashscreen.x = 0;splashscreen.y = 0; addChild(splashscreen);
The splashscreen movieClip has its own code : Play_btn.addEventListener(MouseEvent.CLICK,playgame); function playgame(e:Event):void{parent.removeChild(this); Play_btn.removeEventListener(MouseEvent.CLICK,playgame) }
When I run the game the splashscreen does load and then disappears when the Play button is pressed but none of the eventlisteners seem to work. The background moves, the enemy ships fire but I can't move the ship or fire using the keyboard. The game works perfectly well when I don't use the splashscreen at the start.
This is probably something very simple that I just can't seem to get to work. Basically I'm trying to use a variable to be called inside of an array instead of the actual array so a simple example would be
Code: var people:Array = [john,tom,ann]; var selected = john; trace(people[selected]);
I get an error everytime I try to use a variable in place of and actual element
I'm creating a drop down menu and when I addEventListeners to check the clicks on the invisible buttons on frame 19 of the "menu" movieclip, it gives me an error. T really hate doing rollover with actionscripts. The download link for the fla can be found in below. Sorry for posting an external download link as the file is 7mb+! [URL]
I'm trying to get this one function to be able to call many functions (not at once, but call many possible ones)In other words, I'm trying to get this variable to be named as a function. That way, this one variable can create multiple functions.example:
actionscript Code: class Thing extends MovieClip{ var funcvar; var othervar; function onLoad() funcvar = "YYY"; othervar = "ZZZ"; function onEnterFrame()
I have a set of Cue Points in an FLV I'm playing. It's an interactive quiz, so the idea is that flash will change a variable, theAnswer, to a different letter depending on which question it is. The answer to question 1 is B, question 2 is D, etc. Either the cue point event listener isn't working, or else it is working and Flash isn't declaring the variables. 1120: Access of undefined property theAnswer. I literally can't find a single problem with my code. I have an almost identical Event Listener further down which works.
I need to return to my original function after capturing an event (downloading something) with another function. The original function needs to return a value, which depends on the downloaded data. So, I'd like to pause original function for the time needed for the download and the eventhandler function to complete it's work, and resume it afterwards.
The obvious way is to set a flag value (both the original function and the eventhandler are within the same class) and make the original function check it until the eventhandler function changes the flag. But that would be wasteful, and my AS is slow enough already:) [other parts of the application utilise some heavy graphics]. Is there another way? Like an event that gets captured "in the middle" of the function? Or some other form of flow control?
Let's say I have a Custom Event Class, and it has several Event types stored in static Constant:
[Code]...
Is there an easy way to validate that the type passed to the Constructor is one of the Static Constants of the Class, without having to check it against each value?
Use Flash CS5 (and AIR, though this does not seem like it would be AIR related) in Win XP 64 I have a MovieClip symbol in my library with the identifier 'Puzzle10Piece10' with the following actionscript attached to frame 1 of the only layer with the following actionscript:
[Code]...
This runs contrary to my understanding of the pre-compiler and code execution order. In my way of thinking, any reference creation and related memory allocation is made when the object is instantiated, and indeed that allocation, unlike C depends not on code order (declaration before use), though this is an order that would satisfy even the C pre-compiler. If I understand the Flash compiler at all, it's not even a question of 'code order'... the symbol is pre-compiled such that for it to exist... for it to be instantiated, the variable would exist before the function would even be 'available' to be called internally or externally. Is my thinking way off, or is this a bug?
I have an AS3 program that calls a function multiple times. The function must return multiple variables, so I created a class for the function to declare an object containing all of these variables. For example, here's my class:
package { public class PER { [Code].....
Let's say the calling program calls the function, which returns the variables into data_set1 (where data_set1 depends on input variables arg1, arg2, arg3) using:
var data_set1:PER = function_name(arg1, arg2, arg3);
The calling program does some stuff, then calls the function again, but returns the variables into a new variable name, data_set2:
var data_set2:PER = function_name(arg4, arg5, arg6);
My intention is that data_set1 and data_set2 are different (e.g. not linked together).
My question is, given that arrays are passed by reference, will data_set1 be modified to agree with data_set2 upon the 2nd function call? Why or why not?
I'm doing a basic site with frame labels on the main timeline whose name corresponds to the btn names. A simple otoAndPlay(evt.target.name); I have a basic navigation setup of 7 mcs with mouse eventlisteners for CLICK, ROLL_OVER and ROLL_OUT.
Does anyone know a better way to do this so when my mcs are clicked they display the rollover content/art? In essence I'm trying to achieve that when the user clicks a btn it goes to that "page" and the corresponding btn stays highlighted. Pretty standard web navigation technique but I just don't know what the best way to do this in flash is and with how my site is setup.
I am working with AS3 to build a very simple mp3 player on my site. So far the play and pause button work fine, but when I try to move the slider then click the pause button, it doesn't pause, and then clicking the play button again causes it to play a new file.I'm assuming that for some reason when I call the playMp3 function from my MouseEvent, it's within an object or something and not at the root, so it's like loading a new sound file, but I don't know how to fix that.URL...
this is the function i want to turn in to a static function. just dont know how to make it a static function and call it from other classes. i think this would have its own file.
I'm trying to find a function that will repeat my Rotational tween function. I found the yoyo() function to be what i want to do but i don't want the tween to change the rotation to CCW while originally moving CW. Basically i want the animation to move CW at a steady rate continuously.
I'm using the following code at the moment, i'm not too sure if this is the most suitable code for this situation, maybe im off track.
From my thoughts, i assumed that i would need to put the stars function in a onEnterFrame to repeat the animation and change yoyo() to continueTo() function. or maybe some sort of if statement in the stars function?
ActionScript Code: import mx.transitions.Tween; import mx.transitions.easing.*; var stars:Tween = new Tween(ring, "_rotation", Regular.easeInOut, 0, 360, 4, true);