I have one event handler for several object's events. I would like to pass a value through to the function from the event listener:
function chkEmpty(event:Event){ if(event.currentTarget.text==){ thisIsBitIWantToBeAbleChange.text = You haven't entered anything in the box, please try again hisIsBitIWantToBeAbleChange.setTextFormat(validate_frmt); } }
Could I give the event.currentTarget a value that I could test for? So if the value is 1, I effect output1_txt, if 2, output2_txt, etc etc. If so, are there customisable values that I could use that wouldn't do anything to the display object,?
I have one event handler for several object's events. I would like to pass a value through to the function from the event listener:
PHP Code:
function chkEmpty(event:Event){ if(event.currentTarget.text==""){ thisIsBitIWantToBeAbleChange.text = "You haven't entered anything in the box, please try again"
[Code].....
Could I give the event.currentTarget a value that I could test for? So if the value is 1, I effect output1_txt, if 2, output2_txt, etc etc. If so, are there customisable values that I could use that wouldn't do anything to the display object,?
Let's say I have 10 different buttons, a click on each button will open a different website. Currently, I have 10 different functions for 10 buttons. Is there a way to simplify the code and only have one function for all the buttons and only pass the URL to the onclick function?
button121.addEventListener(MouseEvent.CLICK, clickButton121("http://www.myurl.com")); function clickButton121(event:MouseEvent, urlString:String):void{ myURL = new URLRequest(urlString); navigateToURL(myURL); }
I can say it will be very inefficient if i have 100 buttons and having to write 100 functions.
I'm new to ActionScript and have a fairly basic question. I want an eventlistener to call a function and pass it a parameter that will send the movie to a specific frame. My code generates and invalid parameter type error. It's as follows:
TL_AboutUs_btn.addEventListener(MouseEvent.MOUSE_OVER, DropSubMenu(10)); // calls a function to drop a sub menu function DropSubMenu(sm:number) { gotoAndPlay(sm);}
Error is "1046: Type was not found or was not a compile-time constant: number."
I would like to know if it is possible to pass a clip event on to both the function that has a listener, and to the button that is being pressed. I am finding the listener takes it and thus the button doesn't see it.I found a walk around, however, I'd like to know if it is possible say for one clip event to be seen by both objects?For example, with the mouse over a button the listener function detects the event and carries itself out, however, the button misses the event now.
I am trying to essentially pass a string as a function name into an event listener, but I am not sure how to approach this. Is there a way to convert a string into a function?
Here is some code I have for me to show you what I am doing.
package{ //some import statements public class changes extends MovieClip{
I'm using the following addlistener to listen for a custom event the event works if i put e.Event in the functions parameter but i don't get the passed variables however if i go into the .as folder where the dispatch originates and put EventType in the parmeters field of the function then i get all the variables.........but if i put EventType instead of e.Event in the first example then I get undefined for EventType.....how do give access to EventType?
I have a .swf file through which i am passing arguments to .exe file which is basically a C++console application, how is it possible, should i tweak the sourcecode in th application file for it to accept the arguments passed?
I had been trying finding a way to passing more than one arguments using FlashVars. Below is the snippet of HTML code, using this parameter:
HTML Code: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,
I have a global function that does some stuff with a LoadVars in it.I 90% of the cases, the onLoad reference of the LoadVars is the same, but I sometimes need to do something else when the LoadVars is loaded.Is there a way to pass a function reference to a function so that I could do something like that :
[AS] _global.function myFunction(maybeFunction) { myLoadVars = new LoadVars();
The transition from AS2.0 to 3.0 has been a long and broken trail for me.
Is there a way to pass arguments to a function via addEventListener, like (but unlike) this: timerTurn.addEventListener(TimerEvent.TIMER, moveUnit, "unitname", "unitdirection")
where moveUnit is the function I want triggered, and "unitname"/"unitdirection" are the arguments?
My question is slightly complicated : I have a global function that does some stuff with a LoadVars in it. I 90% of the cases, the onLoad reference of the LoadVars is the same, but I sometimes need to do something else when the LoadVars is loaded. Is there a way to pass a function reference to a function so that I could do something like that :
So far, I have a class that creates a Vector object, and pushes data into it:
ActionScript Code: public var mList:Vector.<cusClass> = new Vector.<cusClass>();
The data is read by a second class like so:
ActionScript Code: trace(firstClass.mList);
The problem Im having is take that same Vector and passing it into a third class (from the second class) as an argument in a method: ActionScript Code: views.mUpListing(firstClass.mList);
I am using a carousel with items in it...when the user clicks an item in the carousel, I want a new swf to load to _level0 and replace the carousel on the stage...the new swf reads an xml...however the xml should be different for every item on the carousel...is there any way to pass the xml file name to the loadMovie command so the new swf can use it?
I had a class that I was passing a simple argument to like so:
var quiz_1_2:CaseStudyQuiz = new CaseStudyQuiz(2); addChild(quiz_1_2);
I now would like to use this class for multiple MCs in my library. I thought I could let Flash create a class for each of them and specifying the CaseStudyQuiz class as the Base class. When I do that, I get the following error:
I'm trying to figure out how to set a MovieClip return value by passing a string argument and using that string to define the child of a given movieclip. I'm doing something wrong because I keep getting null traced instead of home_mc.[code]
TypeError: Error #2007: Parameter listener must be non-null.at flash.events::EventDispatcher/removeEventListener() at project1_fla::MainTimeline/btnName()
I saw a post that touched on this, but I thought it deserved a thread of its own for explicit verification. It seemed that some of the resident geniuses here had given the thumbs-up to passing your whole doc or app class to a function. Please correct me if I'm wrong, as this sounds convenient but I assumed it would cause heart attacks and CPU meltdowns.
EXAMPLE: Say I have an app class that controls my entire game (or slideshow), and it has an ENTER_FRAME scrolling function that's 50 lines long with tons of conditionals so I want to take it out and make it an external file. I pop it into a new .as file but now all my variables are out of scope. I could pass them each individually, but there are so many it's impractical. So my question is: good or bad practice to pass the entire class?
I am trying to learn JavaScript and I am wondering whether JavaScript has a event listener just like ActionScript's ENTER_FRAME. Basically, I want this event listener to listen "all the time" not just wait for any particular instance (mouse click, keyboard event) of event.
What I want to do is to remove an item from the array targetArray when the tween hitFade has finished. I added a MOTION_FINISH event to the hitFade tween which calls the spliceTarget function. I wanted to send an argument to the function indicating the targetArray index to splice, but apparently I'm not allowed to send any argument.
how do I send the targetArray index (i) along to the spliceTarget function?
I'm guessing that I could put i into a global variable and use that in the spliceTarget function, but that seems kind of roundabout.
Code: var hitFade:Tween = new Tween(targetArray[i], "alpha", Strong.easeOut, targetArray[i].alpha, 0, 1, true); hitFade.addEventListener(TweenEvent.MOTION_FINISH, spliceTarget);
function myFunction(argument1:int, argument2:int):void { trace(argument 1 + argument2); }
i can use myFunction(1,2); to get a trace of "3" but if it's a mouse event, or timer event, or anything myMC.addEventListener(MouseEvent.MOUSE_DOWN, myFunction); we can't put arguments in this because it would have been
if I have an event listerner (mouse, keyboard, enterframe,....event) that is being triggered, and when it finishes its event, something that is able to detect the finished event listener and fire out another sets of event.
It works more like MOTION_FINISH in TweenEvent, but it is only available for TweenEvent only, what if I want to detect a mousclick, keyboard, enterframe or even touch event?
My stage has about 25 buttons on it. Each button when pressed to tweens the background to some random x/y coordinates and then loads an external swf file.This is all working, but the timing is off. How can I wait for the initial background tween to end before I make the loader call to the .swf file.Currently each button's behavior is called on the MouseEvent.CLICK event which calls a function that knows its unique filename.swf. I know you can add the MOTION_FINISH even to the tween event but then I would have to call a new function and lose track of the button that initially called it.
I'm moving on to my next massive programming project and I'm trying to decide whether I should code it in as 2.0 or 3.0. I came across the new click event model in 3.0. Right now it's looking like a pain in the butt to me. So now I have to make a function and add it as an event listener? what the hell? What's the benefit? I understand stuff like this makes AS a more complete language but it's kinda annoying.