AS3 :: Flash - Custom Broadcast Events ?
Mar 15, 2010
In Actionscript 3, most events use the capture/target/bubble model, which is pretty popular nowadays:
When an event occurs, it moves through the three phases of the event flow: the capture phase, which flows from the top of the display list hierarchy to the node just before the target node; the target phase, which comprises the target node; and the bubbling phase, which flows from the node subsequent to the target node back up the display list hierarchy.
However, some events, such as the Sprite class's enterFrame event, do not capture OR bubble - you must subscribe directly to the target to detect the event. The documentation refers to these as "broadcast events." I assume this is for performance reasons, since these events will be triggered constantly for each sprite on stage and you don't want to have to deal with all that superfluous event propagation.
I want to dispatch my own broadcast events. I know you can prevent an event from bubbling (Event.bubbles = false), but can you get rid of capture as well?
View 2 Replies
Similar Posts:
Jun 24, 2011
I'm taking my first stab at writing a custom flex 4 component by extending the UIComponent class. Unfortunately, I cannot get the component to respond to any sort of mouse events.I've tried setting mouseEnabled to true is the component, as well as setting mouseChildren to true in the parent (the stage object). It seems whatever I do, my click events can be detected from the stage, but not with the component.Here is my component class:
package components {
import mx.core.UIComponent;
public class DrawCanvas extends UIComponent {
[code]......
View 1 Replies
Nov 24, 2011
I am looking for alt for broadcast live from my webcam.i have option to use Flash Media Server but flash is not supported in ipad so what other option i can go with which support ipad/iphones and other mobile devices as well as web.
View 2 Replies
Jan 14, 2009
How do i make custom event in as2 similar to as3?
View 5 Replies
Jul 25, 2010
Is it possible to broadcast a live video stream from my PC to my website and have it appear in a flash player?
View 4 Replies
Mar 1, 2009
I've been running into a billion problems while creating custom events, so I clearly don't understand some of the basics. All the examples I've found online are unnecessarily complicated, so I've gone ahead and created a super simplified version of how I think it should work. The results are in bold...
[Code]...
View 4 Replies
Apr 29, 2010
So heres the issue I'm haveing, my event listener is not being triggered from the parent, and not retrieving my string for each button being clicked on.
Here is the event listener which listens for the subclass to dispatch an event called MenuEvent.LOAD_PAGE and then passes a string to a variable thats called whatPage thats defined within my custom event.
[Code]...
View 1 Replies
May 12, 2011
How do I correctly implement custom events? I thought the following should work, but I never receive CustomEvent.READY in the main Model
[Code]...
View 2 Replies
Mar 14, 2011
I have this Document class:
ActionScript Code:
package {
import flash.display.MovieClip;[code]....
I just want to dispatch that custom event named "myEvent" but it doesn't work. How can I do? I don't want to use flash events. I want to use mine.
View 8 Replies
Oct 3, 2009
I'm making a game where you build supports under a bridge to keep it up. I'm trying to add some custom events to my game but I cant seem to get them to dispatch. What I'm trying to do is get the repair shop support to fire an event and tell the bridge and the surrounding supports its been built so they can generate a movie clip and start repairing them selves.If I trace the event it gives me all the correct data after the support is built but the listener on in the repair shop support and on the bridge does not receive it.
Code:
package com.CustomEvents {
import flash.events.Event;
[code]....
View 4 Replies
Nov 24, 2009
i have been trying to figure our the dispatchEvent system in as3. But am just not able to wrap my head around it. So can someone please explain and give me an example on how to dispatch custom events?
for eg: Here i just want to disptach event every 100ms and the event should give me the value of "a" .
Code:
package com
{
import flash.utils.Timer;
[Code].....
View 4 Replies
Dec 24, 2009
I'm trying to create a custom multi-touch application that consists of a package containing about 6 classes at the moment. I'm trying to find a way to communicate between the various classes when certain custom events happen but am having a hard time making custom events.
I've tried about 5 different tutorials online for creating custom events and none of them have worked. The code is a bit extensive so I won't attach it but the specific situation I'm dealing with goes like this:
There is a drop down menu system that contains file names from an XML file. When the file name is clicked in the menu I want a custom event to be dispatched that I can pick up in another class file that loads the name of that file into a "status bar" textfield element elsewhere in the app, and later a class that will open the file and add it to the stage.
View 2 Replies
Aug 12, 2010
Can anyone help with this, I've been working on it for hours straight and I'm still having major issues.
Sometimes it works great, sliding each new status update down as it should. Most of the time it seems to have completely random positions set. I am completely at a loss. [URL]..
I think it's an event issue, specifically with line 127 trying to loop through the children and dispatch a custom event to all children. I'm not sure how to best do that.
View 8 Replies
Jul 27, 2011
I want broadcast the television channel in the flash video component. It should be just like seeing TV channel in the internet. I have some knowledge in flash media server. I don't have knowledge to do this. First I want to know that, is it possible to broadcast television channel in the flash video components. If it is what are the software need to use or any other tutorial links.
View 1 Replies
Feb 6, 2009
I'm using one of flash's standard FLV skins but want to modify the code and graphics. Not a problem however, I want an animation running around the outside of my player that can also be controlled by the play button of the movie player..... so..animation on outer skin is running or perhaps starts to run when user mouses over that area... video inside is still.... press play button, video starts, animation stops.... press pause, video stops, animation starts...
View 2 Replies
May 14, 2009
I'm using the following code to create events my question is how do i create multiple events? I need each event to contain a diffrent data parameter.
PHP Code:
package NetConnections.Call{
// Import class
import flash.events.Event; [code].........
View 1 Replies
Jul 29, 2009
The fact is that the "dispatchEvent" method must be placed into the code or timeline where the "event" happens, then it can be trigged and the function associated with the event will be invoked. Ok, it is understood. Nevertheless, my question is: what's the point to create an event to trigger the a function call, if I can simply call the function instead directly???
Code:
package{
import flash.events.Event;
public class CustomEvent extends Event{
public static const ONSOMETHING:String = "onSomething";
public function CustomEvent(type:String){
super(type);
[Code] .....
If I can do simply:
Code:
DoIt();
function DoIt(){
trace ("Done!");
}
What I mean is that custom events doesn't look like as REAL events for me, but more like a delegate way to call a function. Differently from Flash native events that are controlled by an internal engine that keep checking if the event happened, in the custom events they must triggered 'manually', and it seems to lose the event main characteristic.
View 6 Replies
Apr 15, 2012
I'm trapping keyboard events on the stage and dispatching custom events through a framework (Mate, though I don't know that this is an important issue), but I'm pretty confused by the scope. The structure is:application (traps keyboard events and dispatches custom event mainPanel (receives dispatched events but mainCalendar (a child element) is null on debugging. Obviously if I try to call a public method on mainCalendar it errors out, even though it's a child of mainPanel. However, mainCalendar is NOT null IF I use FlexGlobals.topLevelApplication.mainPanel.mainCalendar. Outerdocument and parentDocument do not expose mainCalendar either, BTW mainCalendar (a custom component inside mainPanel with public methods. Creation policy is 'all' and it's visible and exists long before I trap any keystrokes at the top level)Could someone take a minute and explain why the mainCalendar is out of scope when mainPanel receives a custom event, even though mainCalendar is a child of mainPanel. Is there a better way to manage the events so I don't have to always address the component via the topLevelApplication?
View 1 Replies
Jan 4, 2010
I have written a custom component for drawing a circle in Flex. But When I try to write a click event or mouseDown event for that component, it doesn't work.[code]...
The "Hello" Alert is displayed only at a particular point and guess is, at the point, (175,150) the x, y co-ordinates of the circle. But shouldn't it be displayed wherever I click on the MyCircle component?? how to enable it in that way?
Also the mouseDown function doesn't work for MyCircle,but if have the event for the VBox, the Alerts are displayed.
View 2 Replies
Nov 30, 2010
We are building an interface for a game. The interface has a tabbed menu at the bottom of the screen, with each tab displaying different aspects of an object (called a node). When you click on one of these parts, it becomes the focus, and we download it's details in XML, including all it's sub-nodes and parent nodes and then update the tab display accordingly, or at least that's what we'd like to happen.
What we have:
MainInterface.mxml
<s:Application...
<fx:Script>
<![CDATA[
public var currentNode:Node = new Node();
[Code] .....
We tried adding an event listener for "selectNode" to the dashBoard:SkinnableContainer you see see above, but it didn't seem to want to take. We suspect this is because dashBoard is from a spark component and the dispatcher for "selectNode" is on of our own custom components, but we weren't sure... in any case that's what the code assist seemed to indicate as we had to write it in by hand. We're not sure how to pick up the Events in FlashBuilder 4's debugger, so we're having trouble working out where it's going wrong.
Basically, when someone clicks on the label of a child or parent node (that is displayed by the itemRenderer), we want a URLRequest sent to our website, with the url specific to the node clicked on. We then want a URLLoader listening for the return which will update public variable 'currentNode' when xmlDownloaded is called by the loader. If you could clarify how the click event should be dispatched, what should be listening for it then sending the URLRequest and where the URLLoader that is listening for the xml data to return should be that would solve our problems.
View 1 Replies
Aug 2, 2011
Basically I am trying to create a string Validator which requests a new language from its controller by dispatching an event upon its creation.
The example below is a straight copy from the Flex3 component explorer - the only diffrence being that I have created the validator as a custom component which dispatches an event upon its creation.
The problem is that my main Application cannot hear the event being dispatched and I don't know why.
Here is the example
MyValidator.as
package components
{
import flash.events.Event;
[Code]...
View 1 Replies
Jan 23, 2012
I'm using ActionScript 3 in Flash Professional and I'd like my class to raise an event, not a custom event but an existing one. I've set up my class so that it extends EventDispatcher. In the documentation [URL] the example declares a custom event by adding a static String variable:
class CustomDispatcher extends EventDispatcher {
public static var ACTION:String = "action";
I assume that enables:
dispatcher.addEventListener(CustomDispatcher.ACTION, actionHandler);
Or at least auto-complete when you've typed 'dispatcher.addEventListener(' into the Flash Professional IDE.
But lots of classes that raise events raise a mixture of existing noncustom events. For example if you have an instance of a flash.netFileReference and type
fileRef.addEventListener(
A long list of potential events to listen for is given including DataEvent.UPLOAD_COMPLETE_DATA, Event.SELECT, HTTPStatusEvent.HTTP_STATUS, SecurityErrorEvent.SECURITY_ERROR, etc.
If I want my class to be registered to raise those existing events, what code do I need? Preferably so that the IDE knows instances of my class may raise the event and suggests them in the addEventListener auto-complete/intellisense list.
View 1 Replies
Feb 3, 2009
I'm working on a project in flex and I have a few questions pertaining to performance. First off I know that I cannot write multi threaded programs but I understand the internals of the flash player are multithreaded1. when i call ActionScript Code:loaderObj.load(new URLRequest("ljdsfglsdhflsd")); will flash player make a new thread for that?2. I am also interested in making a custom Event class will the listener (which i assume is a loop that runs once per frame or more) run in a different thread. I want to minimize CPU usage as much as possible in areas I can.
View 0 Replies
Dec 30, 2009
I have made a site in AS3.0 code and it's working fairly well but theres alot of things i'm trying to update to make the code a little more reusable. For startersI have a function that creates a little pop-up text when I roll over a button. The text is a class that I created in the Flash IDE instead of dynamically drawing it with actionscript.Here is the code for the pop up text instance called "enter_text" as it rolls over the movie clip "preloader_mc"
Code:
//add listeners to the preloader_mc movie clip on stage
preloader_mc.buttonMode=true;
[code].....
View 1 Replies
Jan 2, 2010
I have an <mx:Application> which contains a <mx:Module>. This module has several child modules. It also has some an instance of a class I have created. I am trying to have a method of this class dispatch an event that can be "heard" by the module and handled. This isn't happening.To be more clear, I am using 'dispatchEvent' to from inside a class method.There is an instance of this class in: mx.core.Application.myapplication.mymodule.myclassIt is the 'myclass.somefunction' that dispatches the event. I have a listener registered in 'mymodule'. Nothing happens when the function/method runs, however.
View 1 Replies
Apr 14, 2010
I am working on actionscript to generate a SWF dynamically using JSON data coming from an HTTP request. I receive the data on creationComplete and try to generate a tree like structure. I don't create the whole tree at the same time. I create 2 levels, level 1 and level 2. My goal is to attach custom events on the panels which represent tree nodes. When users click the panels, it dispatches custom events and try to generate the next level.
So, it goes like this :
On creation complete -> get JSON-> create top tow levels -> click on level 2-> create the level 2 and level 3 -> click on level 3-> create level 3 and 4. and so on and so on. I am attaching my code with this email. How to do this if you need to paint a tree having
total level number = "n" where n = 0 to 100
Should I carry the data around in CustomPageClickEvent class.
[Code]
import com.iwobanas.effects.*;
import flash.events.MouseEvent;
import flash.filters.BitmapFilterQuality;
import flash.filters.BitmapFilterType;
import flash.filters.GradientGlowFilter;
[Code] .....
View 1 Replies
Jul 24, 2011
bubble events up a class tree for none-ui components.I have a structure like this:Controller Unit of Work Child Unit 1 (Raise Event)I would like to handle the event raised in Child Unit 1 in the Controller. I've tried to set the bubble property to true but I've read that this only works for UI components.Is there a way to enable this for custom classes that are not UI components?
View 1 Replies
Sep 5, 2011
I came to some misunderstanding how to use events. LOL. I thought I understand it but as I see I dont.
I've got a Engine document class where Hero is added, and Cannon object too. In body of Hero I need to dispatch event when Hero reaches some point or particularly a pitfall, so I've got static const string to handle it:
[Code]...
but this way I would end up with dozens of handlers in the Engine body class, and I am trying to minimize this class as it is big enough without those handlers. I am stunned and suprised, and I am noob again. Maybe someone will clear out how to get custom events working/... and why only instance of object that dispatches an Event can hear it (my case).
View 2 Replies
Feb 16, 2012
I'm curious about event performance. I have a custom class that downloads files from a server and writes to your local system with AIR. This class has a few custom events that fire during a download process: File starts downloading, files finishes downloading, error occurred, progress, and a few others. This class was built for a specific project, but made coupled so it can be used for anything else wanting to download a file from a server. I'm starting to implement it into a new project, and a few events I'm not listening for, such as when the file starts downloading, or the progress of it, just the complete.
Does it strain overall performance having all the other events still dispatching, when I know they aren't being listened to? Would be be better to comment out the dispatchEvent() for the specifics I know aren't used, or does it even matter? There's obviously events dispatched throughout the SDK that aren't always listened for: Right click, drag, resize, etc. This makes me think it doesn't matter that these events fire but aren't handled, but since code is running and things are happening, that means there is performance going on.
View 2 Replies
Oct 14, 2010
Once a button is clicked in a submenu called SelectChar(a menu class extending my menu base class), it dispatches a custom event carrying an array of variables. This event is then listened for in the main Document Class called Engine, where the value of the passed variable can be used. For testing purposes im only passing 1 arguement in the array.
my Error when trying to trace the passed variable in isolation "trace(e.arg[0]);": 1119: Access of possibly undefined property arg through a reference with static type flash.events:Event.
Okay, i hope that made sense... heres the relevent code:
custom event class: passCharEvent.as
Code: Select allpackage com.asgamer.snipergame
{
import flash.events.Event;
public class passCharEvent extends Event
[Code].....
View 2 Replies