Actionscript 3 :: Flex - Listening For Events From A Yet-to-be-bound Property?
May 1, 2010I've got a class like this:
class Foo extends UIComponent {
var someDispatcher:*;
...
[code].....
I've got a class like this:
class Foo extends UIComponent {
var someDispatcher:*;
...
[code].....
I've got a class like this:
class Foo extends UIComponent {
var someDispatcher:*;
...
}
And I want to listen for events fired by someDispatcher... But, of course, someDispatcher may not be bound until "later":
<components:Foo someDispatcher="{someOtherComponent}" />
What's the best way to listen for events from someDispatcher?I know I could bind to someDispatcher, then wire up the event handlers when it's updated... Or I could use getters/setters...
On creation complete my parent component executes an "init" function which simply sets public bindable variables in child components. I'd like the child components to watch these variables and upon being set use them. However, for some reason the ChangeWatcher is not firing with the change of the variable. Below is my code;
Parent Component
private function init():void
{
userInfo.user = new User("Tom");
[Code]....
I am working on a simple project involving flex 4 and Mate framework. When I am including Mate event map in fx:declarations tag in mxml file, and when I fire up an event, Mate event handlers listen to events and act upon it.
The issue is this, in action script based project, when I instantiate the eventmap class(this is in mxml file only) and keep it in top and fireup an event, instantiated eventmap is not listening to event fired up from action script class.
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 RepliesI 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.
what the most efficient method is for listening for events up and down a string of parents and children? Example:
(these are parents from left to right) Main Sprite -> Child A -> Child B -> Child C
Child C fires and Event - what's the best way to have Main Sprite listen for it?
1) Make Child B and C "public" so Main Sprite can attach a listener all the way down on C (_childA._childB._childC.addEventListener)
2) Child C's event triggers a Child B event that triggers a Child A event that Main Sprite listens for
I have the Main class that imports my urlValidator class.My urlValidator class imports com.usual.swfaddress and thanks to the SWFAdressEvent fires the function dealing with the validation of the url.In some other class myMenu (child of the Main but on the other branch) I need to listen for the event of validation being completed.I'm importing myEvent (custom event) class to urlValidator and when the validation is complete I'm triggering the dispatchEvent.At the same time I'm importing the myEvent to myMenu class and trying to listen when the myEvent was dispatched (from urlValidator).
View 2 RepliesBasically I've build a small class that can be imported anywhere in the program and one of it's public methods dispatch a listener, which as I understand can be received anywhere. Is that correct? In my project I've got a menu which slides in and out. It's movement can be triggered mainly bu the buttons on the menu, but I also want to be able to controll it's movement from various places in the program. So i.e. it can slide in or out when something completely unrelated has been clicked. So I've got a class "SlidingPanel" and one of its children is class "SlidingPanelNavigation". SlidingPanelNavigation uses the class that only dispatches the Event, which should be listened in class "SlidingPanel" and the problem is - it doesn't.
My main class that holds the whole menu together:
Code:
package com.zeeto.menu {
import flash.display.MovieClip;
import flash.events.Event;
public class SlidingPanel extends MovieClip {
private var navigation :SlidingPanelNavigation;
[Code] .....
Why the SlidingPanel.slideMenu() isn't fired?
I am making a game that uses MVC pattern. The game.swf is loaded into main.swf. I want to dispatch a gameOver event from the Model Class of the game.swf and have the main.swf(parent) listen for it but I can't get it to work.
I have game.swf dispatching events fine amongst itself just fine but I can't get the parent to hear anything.
I tried this in the main.swf
Code: Select allvar loader:Loader = new Loader();
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler);
function gameOver(e:Event):void
{
[Code].....
I'm creating an AIR application that loads a child SWF. The child needs to read keyboard input (for a game), which I usually do by adding a keyboard event listener to the stage property, like this: stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp)
However, the child SWF is apparently not allowed to access the stage property because the parent SWF owns the stage, so I get a security sandbox violation. So I need to do one of two things:
Bypass the security restriction allowing AIR to load SWFs that have an absolute path (local path), and allow that child to access the stage, orGet keyboard events to be heard by some display object other than the stage, without ever calling "stage" (this includes stage.focus).A few things I have tried already: Security.allowDomain() does not work. AIR thows an error saying that allowDomain doesn't work in the AIR sandbox. Also, adding the keyboard listener to the child's document class (then clicking inside the SWF) doesn't work.
Here's my code: [URL]
I'm using Flash Develop.
The trace command never gets executed. Why?
I have a menu movieclip and an externally loaded swf on my main stage. The menu mc needs to control the externally loaded swf. For example the swf plays and pauses, then when any of the menu buttons are clicked the swf needs to play thru and be removed. currently I am dispatching an event for each button clicked with a switch statement. In the main timeline I need to listen for each of theses events and based on what button is clicked proceed to the correct content frame. How can I listen for different events and run one function that based on which event is registered perform a task with a switch or if statement?
View 4 Replies`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.
I'm creating a swf, that has a parent class and a child class. The parent class has a button, that dispatches a custom event and I want the child class to list for this event, but when I dispatch the event the child class does not hear the event has been dispatched.[code]The register EventListeners() function is in the child class.I know events can bubble up the display list but how can then go down the list?
View 1 RepliesI currently have an over, out and click event for 8 different objects. The over and out events are identical for each (tween expands object and then shrinks it back for the out state).I have previously asked for an easy way to declare those events, and now I was looking for an easier way to handle them.
Here's my code:
//-----------GARAGE
function growGarage(e:MouseEvent):void{
scaleTweenX = new Tween(map_garage, "scaleX", Elastic.easeOut, 0.648, 1, 0.5, true);
[code]....
I've tried using a single function and then using "this" as the object of the tween but that expanded the entire stage.
I am a newbie in Flex development and using Flash Builder 4 with SDK 4. Now I get the error that "the prefix "fx" for element "fx:Style" is not bound" in line number 4.I searched for it, and it has sth. to do with namespaces, but I can not solve it by myelf.I have the file called "UserStory.mxml" in the directory "components" to place it via the main.mxml onto the screen:
<fx:Script>
<![CDATA[
import components.UserStory;
[code]...
I have a window in which I want to add/remove component and resize the window accordingly based on states. but for some reason it's ignoring the first resize.here's a sample code
<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
[code]....
when the state change to 'two', I want to add rect2 to display and increase the minWidth and size of the window. And when the state change to 'one', i want to remove rect2 from display and resize the window. This seems to work except the window doesn't shrink on the very first time the state change from "two" to "one" but works as expected afterwards. I'm not sure why it's ignoring first time I reduce the width. I also tried changing nativeWindow.bounds directly but that didn't work either.
Originally I just tried setting minWidth based on state (minWidth.one="450 minWidth.two="791") but that caused window to grow on left and shrink on right which caused the window to move left whenever the state changed. so then I just moved the window to right whenever state changed but that caused some flicker that I didn't want.
I am working on a product options form whose contents should be cleared by a clearOptions() method each time the user adds an option. The option name TextInput is bound to a value object that is reinstantiated each time the the user adds a product option. The problem I am having is that the StringValidator fires each time the bound value object is reinstantiated.
[Code]...
Take a BIG user submited image: say 2848x2136 pixels (I said it was big) and resize it with a Matrix:
[Code]....
And then add the bitmap to the stage on the next line.... throws the error "can't access a property of a null... blah blah blah" I get it, it's taking a while for flash to resize my gigantamus image, that's fine and understandable. Finally to my question: How do I set up a listener (or something else) to make sure the image is actually resized. I tried firing a method inside my resizer right before the bmp is returned, but that didn't seem to work. Only thing that works is a manual timer to slow things down a bit and that's just messy. I guess I'm wishing for a bm.draw(bmd).addEventListener(GRAPHICSEVENT.comple te, doneResizing); or something crazy like that. But I can find no such event in the package. Other ideas for making sure flash is done with bitmap data before adding it to the display list?
I have an mx:TileList which is bound to an ArrayCollection.I have some code that displays a "Loading..." message before modifying the ArracyCollection and some code after that hides the loading message.For small data sets, it works fine. However, I noticed with an array size of about 50~ and larger, flex will hide my loading message before the TileList is finished rendering the new data and I'm left with a blank screen for an odd second.Is there an event I can listen to that is called after the TileList is finished re-rendering? Code looks something like this:
loading_message.visible = true;
for each (var x:Object in new_data) {
tile_list_data.append(x); // bound to my_tile_list component[code]..........
In this example, loading_message appear, disappear, and then the flex app will lag before finally revealing the updated TileList.
I have an ArrayCollection bound to an editable DataGrid, another component needs to know when the ArrayCollection changes (as a result of changes in the DataGrid) so it can also update itself, so is listening to the COLLECTION_CHANGE event of the ArrayCollection.
The problem is that the DataGrid only updates the ArrayCollection when the row being edited losses focus. This is not good for my app as a user could edit a column on a row and not click elsewhere on the table for a long time (causing the row to lose fucus), therefore the changes won't have propagated to the other parts of the application.
How can I make the data grid inform the ArrayCollection of a change every time there is a keyup event on a text input instead of every time a row looses focus?
How can I cause numbers with no value to show up blank instead of NaN on forms?Let's say I have a User class with an optional weight (kgs) value, of type Number. If I edit a User in Flex I get the user object from the server and bind weightInput.text to user.weight. If weight is null on the server it will be translated to NaN in Flex, and then the value of weight in the edit form showes up as NaN. That is really inconvenient, as I would like it to just be blank if it has no value.
View 1 RepliesI get the webservice(spring WebService) response properly ,but the event.result object is null.I can see the SOAP response body in the event.message.body variable.
## Soap Response ##
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<SOAP-ENV:Header/><SOAP-ENV:Body><getUserUserTasksResponse xmlns="http://ws.burr.com/BurWS/9_0">
<foundTasks>
[code]...
I have a datagrid with an xmlListCollection bound to it:
<mx:DataGrid id="dgCompetente" includeIn="Competente" x="10" y="66" width="547" height="468"
change="dgCompetente_changeHandler(event)" dataProvider="{colCompetente}"
editable="false">
[Code]......
I want the selectedIndex to remain the same. So, if I delete item 2, the next in the list should be selected. The problem is that if I delete item 2, item 3 will be selected and I have no idea why.
I have a piece of software I'm working on that is using a viewstack with 3 canvases. With the change event I need to look for index 2 which is the last canvas when it changes to this canvas I need it to grab data from inputs from the previous two canvases.Within the viewstack events I've assigned the function change() to the event childIndexChange.
Here is the method:
private function change():void
{
[code].....
I'm trying to create a custom component which is being fed with XML data coming from the server.My problem is that the CollectionEvent listener doesn't get fired and thus labels not updated -Games.mxml (my custom component with listener):[code]
View 2 RepliesCan I listen to Alert button click between components using AsyncToken?Basically, I want to have a method that opens an Alert with buttons and have it return an AsyncToken so that other components calling that method can listen for button click.
Example:
var token:AsyncToken=methodThatOpensAlert();
token.addResponder(new mx.rpc.Responder(buttonClick));
For my custom components, when they go from enabled to disabled or disabled to enabled, I want to trigger a custom event. I can't find any related events in the livedocs.
View 2 RepliesI don't know if this is too difficult or too easy. My custom component is trying to listen to the main application's state changes using StateChangeEvent.CURRENT_STATE_CHANGE, but it's reporting its own state changes.
View 2 Replies