Flex :: Dispatching Events From External Class?

Dec 21, 2011

I have a main application Planner.mxml. This view has a couple of custom components, one of which is LoginView.mxml. In LoginView.mxml I do the following:

protected function btnLoginClick(event:MouseEvent):void
{
try
{

[code]....

As you can see, when the user is successfully logged in, I want to dispatch a custom event; if not, I show an alert box. However, this event doesn't dispatch (or at least, I don't know how to listen for it).

I would like to listen for it in my main application where I can then change my viewstate to the logged-in state. However, the event never seems to get there. I listen for it by having loggedIn="loggedInHandler(event)" on my loginComponent.

View 2 Replies


Similar Posts:


Flex :: Dispatching Events From A Class?

Dec 15, 2009

package com.services
{
import com.asfusion.mate.events.ResponseEvent;
import com.events.navigation.DesgManagementEvent
import flash.events.EventDispatcher;
import mx.controls.Alert;

[Code]...

I am able to get the result, but not able to dispatch the event from the custom actionScript class. I googled and got the riposte that you need to add it to display list.

View 2 Replies

Actionscript 3 :: Dispatching Events From Parent Class To Child Class

Apr 30, 2010

I think this is a pretty simply problem but I do not seem to be able to pull it off. Basically I have a parent class A, and a child class B.Class A instantiates class B with addChild.There is a shared object which is being updated from a java server (red5) that has an event listener attached to it in class A.I have a function in class A which will pass certain, specific updates from this shared object to class B.The problem occurs is that when class B is instantiated, the event listener from class A doesn't work anymore. I have not removed the event listener from A.?

View 1 Replies

ActionScript 3.0 :: Dispatching Events From Static Class?

Aug 3, 2010

However, it seems to me as I've started building this (or trying, rather) that there's no way this can be done, but I'm sure I'm wrong. Since the static class is never added as an instance to the display list, the stage (or any object for that matter) will never hear any events it dispatches.I've searched and found this, but that doesn't seem to be the right solution since I'm listening for my custom LinkEvent event from the stage, and *not* in the class calling the dispatch function in the static dispatcher class.And to reiterate, the goal is to have a single class I can use throughout my application that dispatches my custom LinkEvent event with two properties: linkURL, and linkTarget.The whole reason for wanting to do this is so I can have some control over what happens (to track, or do some other behavior) when someone clicks on a link created within an htmlText TextField with an <a>

View 1 Replies

ActionScript 3.0 :: Dispatching Events In External Swf File?

Jan 22, 2009

I have problems dispatching events from an external swf file.

The class that loads the file only receives the original events of actionscript (for example MouseEvent.CLICK, etc) and ignores others that are dispatched with a own event class or dispatched with a direct string in the type parameter. For example:

dispatchEvent(new PLYPubliEvent(PLYPubliEvent._OVERLAY_OPEN))
dispatchEvent(new Event("testtt"))

These events are dispatched from the loaded swf file in the main timeline.

View 3 Replies

ActionScript 3.0 :: Custom Class - Dispatching Events Performance

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

ActionScript 3.0 :: Dispatching Non-custom Events From Inside A Class??

Apr 3, 2009

Would it be possible for me to also dispatch non-custom events (like Event.CHANGE) from inside a class? I already did this with custom events which worked fine, but when I try to dispatch a the Event.CHANGE it will tell me that I am trying to convert a String into an Event (??). What I do is:[code]

View 2 Replies

ActionScript 3.0 :: Dispatching Events - External SWF & Main Stage?

May 15, 2011

I am dispatching two different events showbutton and removebutton from the code inside the LOADED SWF.on main file, (the one that is loading the swf file) i m listening for events and either showing or removing the buttons based on proper scenario. Here is he error i m getting.
  
ERROR   1180  Call to a possibly undefined Method Event   - - - > dispatchEvent(new Event("showbutton"));

[Code]...

View 6 Replies

ActionScript 3 :: Dispatching Events - Extend Class With No Display Objects?

Nov 15, 2011

When dispatching events in as3 I always have to extend class from sprite, or movieclip, but when I don't have display objects I don't wont to extend to sprite or movieclip. What is the most light class that I can extend, I mean no display object, and still do use event dispatching?

View 1 Replies

Flex :: Dispatching Events Between Classes?

Jun 25, 2010

I have a custom event class public class FFTDrawEvent extends Event {

public static const DRAW_EVENT:String = "drawEvent";
private var _param:Array = new Array();
public function FFTDrawEvent(type:String, __param:Array, bubbles:Boolean=true, cancelable:Boolean=false) {
_param = __param;
super(type, bubbles, cancelable);

[Code]...

Both class (Dispatcher & Listener) are Child class of a MXML application. Also listen to the event in the parent MXML application doens't work. Listen to the event in the dispatching class itself somehow works.

I have to feeling that the EventDispatcher class is not the right one to dispatch events to a mxml application or respectivly AS classes, which extend/inherent from a MXML component class.

View 2 Replies

Flex :: Dispatching Custom Events From A Validator?

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

Flex :: URLLoader Fails Randomly Without Throwing An Error Or Dispatching Any Events

May 29, 2009

In Adobe AIR 1.5, I'm using URLLoader to upload a video in 1 MB chunks. It uploads 1 MB, waits for the Event.COMPLETE event, and then uploads the next chunk. The server-side code knows how to construct the video from these chunks.

Usually, it works fine. However, sometimes it just stops without throwing any errors or dispatching any events. This is an example of what is shown in a log that I create:

Uploading chunk of size: 1000000
HTTP_RESPONSE_STATUS dispatched: 200
HTTP_STATUS dispatched: 200
Completed chunk 1 of 108

[Code]....

View 3 Replies

ActionScript 3.0 :: Dispatching Events Between Different Classes

Jul 19, 2009

Im trying to dispatch and event from an XML class.dispatchEvent(new Event (XMLClass.INDEX_CHANGED));and catch it in the display class [code]I know that im missing something because the application works and the function runs but its not dispatching the event the event or maybe it's not catching the event in the display class, even though everything else is working and im not gettin' any errors.

View 7 Replies

ActionScript 3.0 :: Get A Grasp On Dispatching Events?

Nov 22, 2010

I have been trying to get a grasp on dispatching events and have a few questions I am hoping you will all be nice enough to clearify for me.
 
Do I have to have a custom Event class to dispatch a custom event?
 
If so do I have to create a new intance of the event each time I want to dispatch an event. Example:

dispatchEvent(new MyEvent(MyEvent.TASK_COMPLETE));
or can I just dispatch an event once an instance has already previously been created.... example:  dispatchEvent(MyEvent.TASK_COMPLET);?

View 3 Replies

Flash :: Events Dispatching And Listening?

Sep 2, 2010

I want to have a main logic class that listens for dispatched events from an assortment of other classes.

for instance: i have a parent Map class that contains X instances of a State class. When the user clicks on a State class, i want to dispatch an event CLICKED along with the name of the state.

now this Logic class will see this new event and process the name of the state and perform some other logic stuff. no matter what i try i can only get it to work where the State class listens for its own Dispatched event. Which to me seems a waste, i could have just manually called the function.

I have read so many tutorials online about custom events/ dispatching and they are being used in a basic one class example.

View 3 Replies

Actionscript 2.0 :: Dispatching The Keyboard Events?

Jul 16, 2009

I have a key.addlistener setup to listen to key events.What I want to be able to do is to dispatch key events by for example a mouse click or just on load. I've tried a lot of possible solutions such as dispatchEvent with type as "onKeyDown" and "keyDown" etc.... but key listener simply do not treat it as a keyboard event.

Code: Select allvar eventObj = new Object();
eventObj.type = "keyDown";
eventObj.code = 13;
eventObj.ascii = 'e';
dispatchEvent(eventObj);

View 1 Replies

Actionscript 3 :: Flash Starling Dispatching Events?

Nov 7, 2011

is it possible to send data to starling object after var mStarling:Starling = new Starling(StarlingClass, stage); or maybe dispatching event from main class and then listening event in starling class.

View 2 Replies

ActionScript 3.0 :: Dispatching Events To Flash From Html?

Mar 27, 2011

If i have a html menu, how can i call events within a swf on the same page.?IS this done with java or php?exact example is being used hereclick the nav and see the flash banner change

View 1 Replies

ActionScript 3.0 :: Dispatching And Receiving Events - Button Array

Jun 23, 2010

I am attempting to dispatch an event on the click of any of the buttons in a button array in the document class of my application. The intent is to have an external object receive this dispatch so as to remove a listener for the EnterFrame event in this class.

Here is the Main.as code (document class):
Code:
package {
import flash.display.*;
import flash.events.*;
public class Main extends Sprite {
private var one:MovieClip;
[Code] .....

View 3 Replies

ActionScript 3.0 :: Listening Events Dispatching From Their Child Classes

May 5, 2011

`i'have a problem with listening events dispatching from their child classes. for example i have contentManager object which is controlling content at the top level of stage. it has a imageGallery object and in the imageGallery objectthere ise a collectionLoader object which is loading images.

now i want to add one preloader to contentManager which always listen for ProgressEvent. when the progressEvent dispatched i want to preloader going to active. becouse there is another objects that are loading images or other kind of files. i think it is a good apporach to solve preloader issue. so my problem is, when collectionLoader object loading images with using queLoader. my QueueProgress event dispatches ProgressEvent evey time, but my preloader object stand at the 2 classes up level, doesn't percive this event.

View 3 Replies

ActionScript 2.0 :: Dispatching Keyboard Events - Mouse Click

Jul 16, 2009

I have a key.addlistener setup to listen to key events. What I want to be able to do is to dispatch key events by for example a mouse click or just on load. I've tried a lot of possible solutions such as dispatchEvent with type as "onKeyDown" and "keyDown" etc.... but key listener simply do not treat it as a keyboard event.

Code:
var eventObj = new Object();
eventObj.type = "keyDown";
eventObj.code = 13;
eventObj.ascii = 'e';
dispatchEvent(eventObj);

View 2 Replies

Flash :: Dispatching Events: Does Listener Inherit The Caller's Properties

Jan 5, 2010

I notice in actionscript 3 that when a handler gets called, its able to access the senders properties. If I dispatch an event from my custom class. can all the listeners inherit all my public properties and methods?

View 2 Replies

ActionScript 3.0 :: Dispatching Custom Event From One Class Over To Another Class?

Feb 18, 2009

In a nutshell I have a custom event that I am dispatching from one class that is not getting picked up by the other class even though i have added the appropriate addEventListener calls on its constructor.Here's how the classes are laid out:

application(class/parent)
- network(class/child)
- loginscreen(class/child)

The constructor of the Application class creates and stores references to the network and loginscreen classes:

ActionScript Code:
import com.fg.managers.NetworkManager;
import com.fg.screens.LoginScreen;[code].....

The NetworkManager class extends the MovieClip class as does the LoginScreen and Application classes as well.Now within the oLoginScreen class I dispatch the ValidateCredentialsEvent by calling it this way:

ActionScript Code:
dispatchEvent (new ValidateCredentialsEvent(ValidateCredentialsEvent.VALIDATE_CREDENTIALS, oLoginData, true, false));

Then when I debug the code, I can step through and see that the ValidateCredentialsEvent is being generated but it is never picked up by the oNetworkManager class whatsoever.Is this occuring because the NetworkManager and LoginScreen classes are children of the Application class and because of this can't capture events raised by one another without using the Application class as the intermediary to redispatch these events? My whole idea here was to create a generic network managing object that could be called from anywhere within the application, by any object, using custom events.

View 9 Replies

Flex :: Listen For Events On The Pop Up Manager Class?

Jan 27, 2012

I'm trying to detect when pop ups are visible (including tool tips if possible). The reason is that I need to hide or freeze (capture a snapshot) the Stage* components (StageWebView, StageVideo, StageText etc) when pop ups appear.

View 1 Replies

ActionScript 3.0 :: Dispatching An Event From One Class To The Other

Sep 24, 2008

I have two document classes. The main document class creates a empty movieClip and adds it to the stage in which the second document classes published swf is loaded into. The second document class has a button component on the stage in which once clicked just traces 'hello' to the output window.

What I want to do is upon clicking this button a Event is dispatched from the second document class, to the main document class. Now, I've Googled everything in this known world and have tried to implement examples to no avail. I'm really at a loss right now yet I stubbornly intend to keep banging my head against the problem. Below I have pasted both document classes minus the examples I've tried to implement thus far.

View 5 Replies

ActionScript 3.0 :: Event Dispatching From External SWF?

Jun 9, 2010

I'm working on a project and had a question related to another thread I recently posted earlier this week regarding an area I was a little stuck on..While I did manage to resolve most of my issue, there's still a piece of the puzzle that's missing. I basically have one main container swf that loads several external swfs into a MC and cycles through an array of external files. I have navigation buttons so the user can click next to proceed through all of the external content files. My goal here, is to not have the "next button" become active until after the external files are done playing, so they can't skip ahead.

I currently have this working by having the external swf dispatch an event (from its final keyframe) to the main swf telling the main swf it's done playing, and then activates the next button on completion. This works great; however, I can't seem to get it to dispatch this event on any of the sequential swfs -- it only does this for the first swf initially loaded. Is there a way to "reset" the event to detect the end of the other swfs and continue in this fashion? Or another possible solution so I can apply this to each external swf?Here is the code I have in the main container swf:

Code:
//Array of external swfs
var contentArray:Array = new Array("content1.swf", "content2.swf", "content3.swf");

[code]......

View 2 Replies

Flex :: Dispatch Custom Events From A Created Class?

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

Flex :: Actionscript :: Create A Class To Handle Events

Apr 7, 2010

in Adobe tutorials, they suggest to create a class to handle the events (see below the copy/pasted code, and link to page).I was wondering if I have to handle all events with the function handleAllEvents, using if statements to check if the target is the one I want, and the event is the one I want.i.e. if (event.type=="click") && (event.currentTarget == "myId")Should I have a list of ifs (for each target and each event type ?)[code]

View 1 Replies

Flex :: Events - Updating External Components From An Action?

Apr 6, 2010

I'm new to Flex and am having trouble understanding Events. I think Events are what I want to use for my situation. I have 2 components, addUser.mxml and listUsers.mxml. I access these from a ViewStack in my main application. When I load listUsers.mxml it shows a list of current users in a datagrid via a HTTPService call. When I add a user using the form on addUser.mxml I would like the datagrid in listUsers.mxml to refresh when I return to that view to show the new user. I've tried several different things with addEventListener and dispatchEvent but can't seem to get it working. Can someone help me with this logic?

[Code]...

View 2 Replies

Flex :: Listening To Events In Javascript Without Using External Interface?

Jul 6, 2011

I need to register events in flex and listen to them in java script. Is there any way other than using external interface.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved