ActionScript 3.0 :: Passing An Event Up A Hierarchy?
May 1, 2009
I've created some classes for a nav menu and I'm having some trouble dealing with the click. The bottom class of the chain gets the click, but I need to pass that event up a hierarchy of classes to the very top so it can get handled.My hierarchy looks something like this:
I have searched on the Internet and didn't find any clue on how to do so, any idea ? I don't want flex only flash (my objects are not visual components).
In Actionscript 3 is there any way to determine the precise display object hierarchy an event will traverse through when dispatched from a given object? The object is not necessarily a display object.Although I could imagine this actually being useful somehow, in my particular case it is a learning exercise. I'm trying to master the event system in flash and have some locations where I'm very curious what path an event will take when I dispatch it.
I used to actuate the painter function by using a MouseEvent although I'm prefering to do it this way, but I'm having issues with an error "1120: Access of undefined property thisMouse." Error in Bold I've attempted to pass the Mouse Event to the painter function but had no luck. A simple solution (even potentially dangerous and WRONG) would be fine here, as this is part of University Coursework and I haven't been taught Classes etc. Its basically an introduction to scripting but im trying to do things slightly out of my depth
I'm a professional flash game developer and my week planning is to learn AS3 (kinda..I've just started something but there is one minor problem.... I can't find a way to pass args with eventListener
I'm stuck with an issue and I cannot understand why it behaves like that. In a for loop, I'm passing the for index as an event parameter. However, the eventHandler is getting the wrong index, but the right target...
I am fairly new to AS3. vancouverMC.dotsBttn.addEventListener(MouseEvent.M OUSE_OVER, mcIn(vancouverMC)); vancouverMC.dotsBttn.addEventListener(MouseEvent.M OUSE_OUT, mcOut(vancouverMC)); function mcIn(mcName:MovieClip):void{ mcName.gotoAndPlay("in"); mcName.ringMC.gotoAndPlay("on"); } function mcOut(mcName:MovieClip):void{ mcName.gotoAndPlay("out"); mcName.ringMC.gotoAndPlay("off"); } Why this is Not Working?
I like reusing functions repeatedly so I pass the object to the function (blur, drop shadow, etc.) but if an Event or MousEvent function is involved, I have to do things I don't like. In my example, I had to put the TimerEvent.TIMER_COMPLETE function as a sub function of the setTimer function. I would rather keep the functions apart but I don't know how to pass a parameter to the event function to tell it what movieclip(timerObject) to fade in. Is there a better way to do this?
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 followed the tutorial and have SWFAddress setup and it works fine in one way (the browser is showing the right thing) but since all buttons on my site use one and the same function (what happens depends on the button witch was clicked - using the e.target variable) I can't tell flash what has to happen when the browserbuttons are used. As in the tutorial I'm working with a switch statement where I call the MouseEvent function for every possible case, but I can't find out witch variable to pass inside that function.
url (it's a french site about birth, some pictures are kind of explicit) [URL]
Say I have an array with 4 string elements that are 4 different urls. On the stage I have 4 movieclips that I want to have listen for a CLICK event. When the user clicks a button, the navigate to one of the 4 urls.I can loop through the buttons and add and event listener to each:
Code: private function applyPlankLinks():void { for (var i:uint = 0; i<numberOfPlankBtns; i++) {
'm trying to break out stuff that happens on a mouse click into a function so that function can be called at another time. here's what i'm trying to do:
function itemClicked(e:Event):void { passoff(e.target); trace(e.target.name); //menuItem1
[Code]....
the above is obviously not working but i'm wondering how this should be done.
I have isometric tiles that are put together to form a map. Because the graphics are isometric, and the images themselves are rectangles (with transparent corners) I was wondering if there's way to pass a mouse event through image being clicked if it's being clicked at a point that is transparent onto the object that is layered below it. Using the bitmapData class I already know how to check if the position being clicked is transparent or not, just not the second part.
I would like to pass Parameters to a functions from a button click. Currently I need to call a function that in turn passes the Parameters.
example gardengate_btn.addEventListener(MouseEvent.CLICK, onClick_gardengate); function onClick_gardengate(e:MouseEvent):void{ /*Sends the xml and the paintingCount_Numb to the parseXML function. This will display the text and images for each painting */ ParseXML(xmlData,0); }
I would think that i could just do this but it gives me an error. gardengate_btn.addEventListener(MouseEvent.CLICK, ParseXML(xmlData,0)); 1067: Implicit coercion of a value of type void to an unrelated type Function.
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 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 need to pass along a string with my FileReference, or provide that string as an argument when an event fires. To be clear, it really annoys me that AS3 doesn't allow you to pass parameters on events.Right now, I've extended the FileReference class to include an additional variable. I'm trying to get this to compile, but it won't compile; I think I don't know how to import this class correctly. If you can tell me how to import this class correctly so that I no longer get Error: Type was not found or was not a compile-time constant at compile time that would be great.
This is the extended FileReference class: import flash.net.FileReference; public class SxmFR extends FileReference {
I have a 16x16 grid of buttons, and want to add an event listener to each of them so when clicked it will return its unique grid position number (anything between 0-255);
What I have so far: public static const GRID_SIZE:Number = 16; private var i:int; private var j:int; // Constructor public function Grid() [Code] .....
Unfortunately every time the listener function is called by each button, it uses the last two values of i and j, which in this case return 255 for every button.
I have a loaded swf (CustomClass) and I want to listen a dispatch event from the swf, but it doesn't seems to work. The relation of the dynamic class are: Code: tablet(DocClass of the swf) ---> mainmenuC I'm trying to pass a event to a function in tablet, and have the codes listen to the dispatchEvent from the function in tablet.
ActionScript Code: CustomClass.addEventListener("profile_home", currentPage) private function currentPage(event:CustomEvent):void { trace("profile home clicked") } tablet.as [Code] ..... It doesn't return any error, but why does it not pass the data?
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: