ActionScript 3.0 :: Communicating Between Classes - Dispatching Event?

May 30, 2010

I'm just starting to build my first proper OOP piece.I have on stage two manually placed MCs.One is viewer_mc:ViewerClass and one is menu_mc:MenuClass.They each have their own class and there is a document class...

PHP Code:

package
{
import flash.display.*;[code]....

So I can call the public method of either class from the other class.However, I am now trying to understand custom events and dispatching them with parameters.which uses a custom event class.This works fine when the dispatchevent and listener are both in the viewer class, but when the dispatchevent is in the viewer class, and the listener is in the menu class I can't get it to work.I suppose for my purposes I don't really need to use the custom event class, I can just call the respective classes' public functions but I just wanted to try and understand how it works.Here's the pared down version of menu class...

PHP Code:
package classes {
import flash.display.*;
//some other imports[code].........

View 4 Replies


Similar Posts:


ActionScript 3.0 :: Communicating Between Classes?

Jan 26, 2009

I'm trying to call a function from a class that I've instantiated on the main timeline from another class that I've also instantiated on the timeline.The function I'm trying to call adds a line to a string that acts as a game terminal so that even if the game glitches for someone without the source code, it would be possible to read the variable changes and functions called. (it also doubles up as an input for unlocking characters and levels that are otherwise hidden)Main Timeline:

Code:
import britland.Character;
import game.terminal;
var GameTerm=new Terminal();[code]....

I've tried both "flash.display.DisplayObject.stage" and "this.parent.parent" here after discovered that "_root" has been removed and "root" doesn't work in the same way.

View 6 Replies

ActionScript 3.0 :: Communicating Between Linked Classes?

Oct 28, 2009

I have been struggling with what seems to be simple concept in ActionScript 3.0 - how to communicate between classes. I have a very simple experiment with two movieclips on the stage. They are named YellowBox and RedBox in my library. I have linked the following code to the YellowBox movieclip: 
 
package{    import flash.display.MovieClip;    import flash.events.MouseEvent;        public class YellowBox extends MovieClip    {                public function YellowBox()        {            this.addEventListener(MouseEvent.ROLL_OVER, rollOverHandler);        }                public function rollOverHandler(event:MouseEvent):void        {            this.x = x + 3;        }    }}
  
What I would like to do is call the YellowBox() function on my RedBox MovieClip with the following code:
 
package{    import flash.display.MovieClip;    import flash.events.MouseEvent;        public class RedBox extends MovieClip    {                public function RedBox()        {            YellowBox();        }    }}
  
I get the following message when I compile: 1136: Incorrect number of arguments.  Expected 1.

View 2 Replies

ActionScript 3.0 :: Communicating With Other Custom Classes?

Sep 10, 2009

How do I let a custom classes know, what I've done at other classes,so that it would run an action accordingly?a function in the button classes:

ActionScript Code:
public function btnClick(event:MouseEvent):void {
var zoomF:theZoom = new theZoom();

[code].....

View 2 Replies

ActionScript 3.0 :: Flash Communicating Between Two Classes?

Apr 21, 2011

I have a custom keyboard class. The second class is having a textBox as its child and my custom keyboard's object as child. When the key in the custom keyboard is clicked, how can i update the value in the text box?

View 4 Replies

ActionScript 3.0 :: Communicating Between Parent And Child Classes?

Dec 23, 2009

Basically, I have a menu system for a website that is built on a three tier hierarchy. onclick event handlers load movieclips which contain the next submenu in my menu system. Each menu and sub menu is a series of movieclips with roll over, roll out and click eventlisteners applied to them to give them button characteristics.

However, I have hit an unforseen problem. I need to be able to control all the onclick event handlers assigned to all my buttons from one place, not in lots of different movieClips. I want to be able to add and remove different website content pages in one display object or else I fear that pages will start to appear to overlap as they are added within their specific sub menu movieclips.

I guess what I am trying to say is, can I control movieClip instances that are contained within a child object from my main timeline?

View 1 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

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

ActionScript 3.0 :: Communicating Between Classes - Change Alpha For Image Using Button

Feb 25, 2009

I am having problem making classes to communicate. I have main class which loads external swf that contains one image at this time. I want to change alpha for that image using button (created from library) from main swf. Don't know how, various methods I tried gave various error messages.

View 5 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 3.0 :: Communicating Between Classes - TypeError: Error #1009: Cannot Access A Property Or Method Of A Null Object Reference

Oct 12, 2009

I have this error when I run the files.

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com.common::stageConfig()
at cloudsMain()
CloudsMain.as which is attached to the .fla

[code]....

Basically I'm trying to create a class that I can call and centralise any mc on stage by eg.stageConfig.centralisedDO(my_mc), However I encounter the above error.

View 2 Replies

Flex :: Dispatching Custom Event From Repeater Component And Listen Event In Other Repeater Components

May 4, 2011

I have a repeater component with custom event. My repeater components fires custom event holding data. My need is to dispatch event so other repeater components can access data from dispatching component.

Edit: Added whole stuff here.

<!-- AttributeMapping.mxml -->
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:fx="http://ns.adobe.com/mxml/2009"

[Code].....

View 1 Replies

ActionScript 3.0 :: Dispatching Event From Embeded Swf?

Aug 6, 2009

How do I send an even from an embeded swf and receive it from the class that called it?Code the dispatches from account_settings.swf file.

Code:
dispatchEvent(new CustomEvent(CustomEvent.ACCOUNT_INFO, {theData:pipeSize.selectedItem.data}));

[code].....

View 5 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 :: KeyboardEvent Is Not Dispatching Event?

Feb 16, 2011

I´m making a game.This game has 4 frames.It has a preloader.swf and game.swf.The preloader.swf loads the game.swf.The game.swf has 4 frames.In the first frame is given to the user the options to play the game (clicking a button "playGame" on "click" event) and to set the sounds settings (clicking a button "options" on "click" event).So far so good.

When the user clicks "playGame" I send the user to frame 2, where it has the option to select a game level using the arrow keys. So within the playGameListener I registered two keyboard events one for KEY_UP and another for KEY_DOWN. So, to have sure that it´s working, I added a trace for each keyboard event listener. But I´m not getting any message in the output window while pressing
left arrow or right arrow or any arrow.

So I learned that KeyboardEvent only dispatches an event if the flash player has focus.Well I think the flash player has never losed focus in this process.I´ve registered two events for Event.ACTIVATE and Event.DEACTIVATE and inside its listeners I added a trace with a message. Flash outputs me a message if I minimize the flash player window or if I maximize the flash player,but not while the game.swf´s frame transition.The listeners for the KeyboardEvent works only when I press at the flash player, then I receive the messages from the KeyboardEvent listeners.

View 5 Replies

ActionScript 3.0 :: Dispatching One Event For Two Buttons?

Jan 28, 2009

I have two buttons each in its own sprite now I want to listen for mouse overmout and click event on both. In a way that if you roll over button1 its color changes but at the same time button2 color changes as well.

To be more specific lets suppose I have a graphic button like map picutre for a country like UK and then I have text button for UK as well. What I want now is that when user either scrolls over UK map the map button color changes but at the same time the color for UL text button changes as well. same goes for click and out events for the two.

View 1 Replies

ActionScript 3.0 :: Dispatching An Event Which Is Listened By All

May 26, 2010

May be my title doesn't clearly reflect to what I am saying. Let me demonstrate with following example

[Code]....

Instead of doing this type of event listening,is there a way, by which the final class can listen to "firstDispatch" event without going through its object as shown above

View 2 Replies

ActionScript 3.0 :: Event Dispatching And Listening?

Jun 23, 2010

I have a parent swf and eight child swfs. The child swfs are loaded into an array at runtime on the parent swf using a Loader. I have buttons and functions on and in the parent swf to change out the child swfs. This all works just fine but here is my issue. On each of the child swfs I have buttons that need to call the functions in the main swf to change out the child swfs. The program is an interactive virtual tour and I want to be able to click on a door and have the next room's swf displayed in the parent swf. I'm trying to do this by dispatching an event from the child swf

ActionScript Code:
mainPanorama.bedDoor.addEventListener(MouseEvent.CLICK, dispatchBedroom);
function dispatchBedroom(e:Event):void {
dispatchEvent(new Event("loadBedrooms"))
}

that needs to be heard by the parent swf and the appropriate function called.

ActionScript Code:
objectsArray.addEventListener("loadBedrooms", loadBedroom);
function loadBedroom(e:Event):void {
tourNum = 5;
unloadData(tourNum);
}

So far this specific code keeps telling me that addEventListener is not a function. I've tried quite a few variants of stage, this, and parent combinations in place of objectsArray but unfortunately something in the parent swf is not hearing the event dispatch.

View 1 Replies

ActionScript 3.0 :: Dispatching Event On Exit?

Aug 11, 2009

Does flash dispatch any event just before it's closed?e.g. When the user closes the browser? searched the documentation and there's nothing. I thought the stage should dispatch an ventIf there isn't any can I make a custom one?

View 3 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

ActionScript 3.0 :: Still Struggling With Event Dispatching?

Jul 5, 2010

Can anyone please explain me why the dispatched event is not captured in this code?

The idea here was to notify all instances of a class when you click on one of them

[Code]...

View 10 Replies

ActionScript 3.0 :: Event Dispatching In Loaders?

Feb 7, 2011

What I am trying to do is build some kind of Loader-SWF that loads several animations (swf-files) and then plays them back one after the other.

What I am struggling with at the moment is how to find out when the first animation has finished and then switch to the second one. Since the Loader-Object I use to load the swf doesn't seem to dispatch a suitable event I thought I'd just do the following on the last frame of the animations I am loading:

Code:
stage.dispatchEvent(new Event('nextClip'));
and then have this in my "Loader":

Code:
stage.addEventListener('nextClip',loadNextClip);

This works fine when I just have my first animation clip dispatch the Custom Event, but as soon as I add the code to all the other animations it will throw an 1009 error (referring to the last frame of the newly added animation) as there somehow seems to be some confusion regarding what "stage" is referring to now.

View 2 Replies

ActionScript 3.0 :: Hint For Dispatching An Event Which Is Listened By All?

May 26, 2010

Instead of doing this type of event listening,is there a way, by which the final class can listen to "firstDispatch" event without going through its object as shown above

View 6 Replies

ActionScript 3.0 :: Class Is Not Dispatching Event Without Timer Of 1 Second

Apr 28, 2011

I am developing a project where ClassA creates the instances of ClassB , ClassC and ClassD and adds the eventsDispatcher with them. ClassB and ClassC are able to dispatch the events back to ClassA which is fine. But ClassD is not dispatching the event. It only dispatch the event only when I call the dispatchEvent(new Event(Event.Complete)) function after giving 1 Second delay.

View 11 Replies

Flex :: Does Dispatching An Event Interrupt A Function

Aug 12, 2009

Let's say function foo() is executing. Suppose that an external event occurs, for which you have a handler. Will function foo() be interrupted so that the event handler can be executed? What is the order of execution in this situation?

View 2 Replies

Actionscript 3 :: Flex Custom Event Dispatching

Oct 10, 2010

I got a question about event dispatching in flex.my goal is to get a custom event loaded up with some data and than bubble up to the eventlistener. my main application has and AMF service request inside which calls an service class. that class is supposed to dispatch an event when the AMF service request returns a result or fault and the main application is listening for that event.so inside my mainapp i add and listener like this:[code]
However, this event never reaches the main application. Looking closely to it with the debugger, i found out that when the event is dispatched the listeners property of it is set to null.

View 5 Replies

Flex :: Dispatching Custom Event From ItemRenderer?

Feb 15, 2012

I'm trying to dispatch a custom event from a custom ItemRenderer. This is my custom event
package events {
import customClass.Product;
import flash.events.Event;
public class CopyProductEvent extends Event {
public static const COPY_PRODUCT:String = "COPY_PRODUCT";
public var picked:Prodotti;
[Code] .....
The event from the function is dispatched correctly... I can't intercept it..

View 1 Replies

ActionScript 3.0 :: Event Dispatching In Hierarchical Menus?

Jan 23, 2009

I've written lots of hierarchical menus in AS2, am happy with XML, recursion and the Compound design pattern.owever, I'm about to built my first AS3 menu system, and what I want to know is where do people usually add their event listeners? Should I be adding them on each menu item, or just one on the whole menu system, and use event bubbling to capture and respond to clicks, rollouts, etc.

View 6 Replies

ActionScript 3.0 :: Dispatching Event From A Static Class

May 17, 2008

I have a class name ImageLoader that is used to load image and the dispatch a complete event when the image is loaded. This class is implementing singleton design pattern which means that only one instance is created always for this class.

Everything is working fine it is loading the image but in the initListener function i am dispacthing a complete event to let the other class Content (which passes the image name to this class ) that the image is loaded and you can access it now.

BUt the problem is the event is never dispatched or may be it is but I am not catching it properly here is code for my ImageLoader class.

Code:
package
{
import flash.display.*;
import flash.net.*;

[Code]....

View 5 Replies

ActionScript 3.0 :: If An Event Is Dispatching / Function Being Performed

Jun 9, 2011

It's me back with my fighting game questions. Basically, in the frames of the animations, events are dispatched. When one is being dispatched, I dont want the other one's function to be performed...I'm probably making this alot more confusing than it is supposes to be... If you can just picture it, in a fighting game I dont want the enemy to take damage, while both he and the player are colliding and attacking (whichever one was attacking first). geez that was a ramble.[code]

View 1 Replies







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