Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash








ASBroadcaster?


i need explication whith examples thankyou!!!


excuseme my english!!!




Ultrashock Forums > Flash > ActionScript
Posted on: 2003-01-09


View Complete Forum Thread with Replies

Sponsored Links:

Asbroadcaster
Hi,

I'm trying to broadcast a root variable (true/false)
to all instances of an mc that has a button child.
I want to enable/disable the button(s) whenever
the root var is changed.

I can broadcast the var by making it part of an object.

But I can't seem to attach a listener to the object
from within the mc.
I've tried doing it in on(load) for the mc and
in the first frame.

Any tips?

thanks,
s.

View Replies !    View Related
ASBroadcaster Help...
I have been reading and rereading the post on ASBroadcasters by senocular, and I'm trying to learn exactly how best to use it. I have a few questions...

first, when i run the debugger
in flash, why don't the prototypes i define for the Ball class show up as part of the object b that I instantiate, but they seem to work when I call them in the setInterval function at the bottom?

code:
//initialize the class Ball...
Ball = function(){this.x = 0;this.y = 0;};
Ball.prototype.move = function(){
this.x += random(10)-5;
this.y += random(10)-5;
trace("x = " + this.get_x() + " y = " + this.get_y());
this.broadcastMessage("onBallMove");
//updateAfterEvent();
}
Ball.prototype.get_x = function(){return(this.x);}
Ball.prototype.get_y = function(){return(this.y);}

//instantiate a new object b of class Ball
b = new Ball();
//declare it as a broadcaster
ASBroadcaster.initialize(b);

//initialize a container class for the ball
Container = {};
b.addListener(Container);
//the container now listens for the ball
//to broadcast the onBallMove event
Container.onBallMove = function(){
trace("Ball moved");
}
setInterval(b,"move",1000);

View Replies !    View Related
AsBroadcaster Not In As2?
is there anyone who has found a way to make asBroadcaster work in as2? a lot of my work is depending on the use of asBroadcaster, but in as2 its like it never existed. Cant find anything about asBroadcaster in the help files (oh Im sooo surprised)

View Replies !    View Related
ASBroadCaster
I am using Flash 2004 Pro & ActionScript 2.0

I have created a AS2.0 Class that extends a movieclip.

In the class init I have the following two lines

AsBroadcaster.initialize(this);
this.addListener(billing_mc) --- this is object that I am adding as a listerner

this.onRlease = function(){
this.broadcastMessage("startBilling");
}

The compiler complains that is can't find the AsBroadcaster method or property. How can I get past this?

Thanks

View Replies !    View Related
AsBroadCaster
I am using flash 2004 Pro & AS 2.0

I have created a class that extends a movie clip.

The class init has the following 2 lines
AsBroadCaster.initialize(this)
this.addListener("someObject_mc");

further down I have the following

onRelease = function(){
this.broadCastMessage("sendEvent");
}

the compiler complains that it can't find a method or property called AsBroadCaster or addListerner or broadCastMessage

How to I over come this?

View Replies !    View Related
ASBroadcaster Is Gone? Where Did It Go?
I am not sure if I am going crazy, or just need to completely relearn the events model in MX2004.

I can not initialize an object with the method
ActionScript Code:
ASBroadcaster.initialize(this);

so, what doing, how do I write a custom event broadcast? Even a link to a specific tute would help. But please, not the ones at flashcoders.com or flashguru.co.uk.

thanx for the help all..

doc

View Replies !    View Related
ASBroadcaster?
Hello all.

I've read senocular's Listeners and ASBroadcaster tutorial, as well as the link to ASBroadcaster inside the Best of Senocular thread, but I still can't seem to figure this out.

How does one go about creating an AS 2.0 Class and making it a broadcaster?

I have 3 files, two empty classes, King.as, and Servant.as, and I'm trying to get them to interact using ASBroadcaster and .broadcastMessage() in the third file, test.fla.

I've tried initializing both the King class, and an instance of the King class, (as a broadcaster) and I still don't know what to do.

Any suggestions?

Thanks for any help you can provide.

View Replies !    View Related
ASBroadcaster?
Hello all.

I've read senocular's Listeners and ASBroadcaster tutorial, as well as the link to ASBroadcaster inside the Best of Senocular thread, but I still can't seem to figure this out.

How does one go about creating an AS 2.0 Class and making it a broadcaster?

I have 3 files, two empty classes, King.as, and Servant.as, and I'm trying to get them to interact using ASBroadcaster and .broadcastMessage() in the third file, test.fla.

I've tried initializing both the King class, and an instance of the King class, (as a broadcaster) and I still don't know what to do.

Any suggestions?

Thanks for any help you can provide.

View Replies !    View Related
ASBroadcaster
Hi,

In the tutorial "Events and ASBroadcaster " from (this)//Ultrashock, The code only works when published as flash player 6.

I'm I studying a moot point for FLASH 7, if so where should my attention be focused in relation to listeners and broadcasters in FLASH 7+?

View Replies !    View Related
Something Better The AsBroadcaster?
hey guys,
im having an issue with as broadcasting.

i have 4 unique movie clips.

the first thing my script does is randomly choose one of the four and using the .attachMovieClip method to duplicate it, this happens about 40 times. Each movie clip is given a unique name.

what i want to achieve is when i click on any movieclip, it performs the same function.

i tried initializing each movie clip as it was created and add the same object as a listener to all.

then got the movie clips to broadcast "onClick" when onMouseDown.

then used
ActionScript Code:
obj.onClick = function{ trace("i got clicked"); }


this worked, except that when i click on movie clip, every movie clip sent the broadcast and i got the trace 40 times.

is there a better way? or am i using this the wrong way to achieve what i want?

thx guys

View Replies !    View Related
ASBroadcaster In AS 2.0
Hello all,

In (MX/AS1.0) I used to sometime string together functions through the ASBroadcaster......

var director = new Object();
Stage.addListener(dir);

function someFunc() {
---------------------------
Stage.broadcastmessage("nextFunc");
}
function nextFunc() {
---------------------------
//and so on...............
}

....... I basically used these to string allong packets of animation. In AS2.0 I get errors like ("Stage.broadcastMessage in not a supported methdod") which makes sense because overall AS2.0 is more OOP (strict) with what you do with the classes.
Anyway I guess my questions are:
*Does my problem have to do with extending the ASBroadcaster Class??----
*Does anyone know of the changes with the ASBroadcaster

++++And a side question:
I'm currently working on developing the 3rd tier to an online stock image site, basically our orientations are vertical and horizontal. These are basically the steps...
*Invoke the CF component that calls a SQL stored procedure
*Gather info and save in a Recordset object
*Loop through and load images into their 'slide' objects to display

........Now when you invoke the loadMovie() it gets executed last, (I'm pretty sure this is all handled with the events of the MovieClipLoader, but I'm curious for a better workaround/method) I want to invoke a function that checks for orientation but you have to do it later so the loadMovie() can execute, so my workaround was to call an Interval with a 200 millisecond delay like this.....
with(holderClip){
loadMovie("image.jpg");
--------------
--------------
setInterval(orientate, 200,"clip");
}
function orientate(clip) {
if(clip._width < _height) {
//its vertical procede accordingly
}else{
//its horizontal..etc,
}

Sorry this is a long winded one, but I'm just looking for some insight any of which is appreciated.

Tanks...

View Replies !    View Related
ASBroadcaster Et AS 2.0
Well I was asking me how to make an ASBroadcaster in AS 2.0

in AS 1.0 it looked like that, but I don't know how to convert it in "2.0"


ActionScript Code:
ASBroadcaster.initialize (NewsFeed.prototype);
 
NewsFeed.prototype.sendNews = function (headline, summary, url) {
        this.broadcastMessage ("onNews", this, headline, summary, url);
};


can someone give me guides to continue

thanks a lot

scoob

View Replies !    View Related
ASBroadcaster Catastrophy... Well, You Know
Righto mates... (no im not british) i just read a couple tutorials over at ultrashock.com about building your own event sources and creating your own events using ASBroadcaster. I'm still fairly new to the more complex actionscripting but I like to fool around with stuff that I'm unfamiliar with. I've got 7 objects on the stage. in the first frame of _root, i have this code:

Code:
initialize = function(self){
ASBroadcaster.initialize(self);
_root.a.addListener(self);
_root.b.addListener(self);
_root.c.addListener(self);
_root.d.addListener(self);
_root.e.addListener(self);
_root.f.addListener(self);
_root.g.addListener(self);
}
i call this function in each of the seven objects on the stage (a-g). i realize what im doing here may not be the most effective, but im not really concerned with that. im just trying to get a grip on ASBroadcaster right now. the point is, when i trace the _listeners array on any of the objects, all i come up with is a, g, and f. i have no clue why only a, f, and g show up as listeners, but none of the others do. can anyone help me out here? thanks for your time

View Replies !    View Related
ASBroadcaster And Right Clicking
is there a way to define the right mouse button, or the scroll wheel as a broadcaster for functions to listen to?

View Replies !    View Related
ASBroadcaster In 2004
i'm sorry , am i the only one experiencing this ?

coz the ASBroadcaster doesn't work anymore since i use Flash mx 2004.

this is an example i tried from senocular and even that doesn't work.


Code:
King = {}; // a King is born!
ASBroadcaster.initialize(King); // our King is declared a leader

subject = {}; // a royal subject is born!
King.addListener(subject); // our subject is now hired to listen to the king

// now we tell our subject his job
subject.onKingScream = function(){
trace("brings grapes");
}

// here we just make the King scream twice, for the heck of it ;)
King.broadcastMessage("onKingScream");
King.broadcastMessage("onKingScream");



this only works if i publish the movie with flash player 6 using actionscript 1.0

how do i do this stuff with actionscript 2.0 ?

View Replies !    View Related
AsBroadcaster On A MovieClip Help
hi, how do i use the 'AsBroadcaster' on a movie clip?

ActionScript Code:
MovieClip.prototype.selectItem = function(item) {
    AsBroadcaster.initialize(this);
    this.broadcastMessage("SelectedItem", item);
};
and the other one:

ActionScript Code:
var myListener:Object = new Object();
_root.menu_mc.SelectedItem = function(item) {
    trace(item);
}

View Replies !    View Related
ASBroadcaster Troubles...
I can't seem to get the ASBroadcaster to work.

The following is actionscript in the first frame (root)...

Code:
var eventProcessor:Object = new Object();
_root.mcTS.mcSlideLeft.addListener(eventProcessor);

eventProcessor.slideLeft=function(){
trace("Test");
}
The action script for the movieclip mcSlideLeft is...

Code:
AsBroadcaster.initialize(this);

this.onPress = function(){
this.broadcastMessage(slideLeft);
}
This doesn't work... any suggestions?

Thanks!

View Replies !    View Related
AsBroadcaster, __resolve
It's been a while since I've been here, but I'm hoping to get a little help.

I've come up with a nasty little situation. I have an event broadcaster, and I have event calls all over the place. Some of them pass parameters.

What I want to do is trace every event called for a bit of debugging.

The relevant actionscript to my problem that I have right now is this:

Code:
//My AS Broadcaster
var objBC:Object = new Object();
AsBroadcaster.initialize(objBC);

//My "watcher" Object
var objWatcher:Object = new Object();

//The function that handles any called undefined functions
objWatcher.__resolve = function( sName:String )
{
trace( "Method " + sName + " called" );
}

//Add the watcher to the listener list
objBC.addListener( objWatcher );
This code works fine for it's "normal" use. For example, if you were to type

Code:
objWatcher.foobar();
Then "Method foobar called" would be traced. However, the same does not apply if you type

Code:
objBC.broadcastMessage("foobar");
Which is my problem. I'd write my own AsBroadcaster-esque function, but I'm unsure of how to handle the additional parameters that some functions deliver.

Any help is greatly appreciated!
Many thanks,

--Vector

View Replies !    View Related
AsBroadcaster Equivelant For 3.0?
Quick question. I have always done this with AS 2.0 and it works great:


ActionScript Code:
var EventDispatch:Object = new Object(); // Creates broadcast object
AsBroadcaster.initialize(EventDispatch); // Make EventDispatch an event broadcaster.

/* make the listener events at MC level */
clip.toggleState = function(s:Boolean):Void
{....}

//call the toggleState for clips
EventDispatch.broadcastMessage("toggleState",false);

Does AS 3.0 still have the same class or is it different now? I've looked in the help and through the forums for AsBroadcaster but only come with AS 2.0 references.

Can someone steer me in the right direction?

Thanks.

View Replies !    View Related
Can't Get AsBroadcaster To Work
I'm experimenting with AsBroadcaster -- or rather trying to experiment with it! I've got a custom class that should be broadcasting and a fla that instantiates the class and adds an object as a listener. But it doesn't seem to be happening.

I've also tried periodically tracing out the _listeners array from my class instance, but my object never gets listed.

Any idea what is wrong?







Attach Code

// in a class .as file

import AsBroadcaster;

class myModel
{
public var addListener:Function;
public var removeListener:Function;
private var broadcastMessage:Function;
//
public function myModel()
{
AsBroadcaster.initialize(this);
setInterval(whoIsListening, 500);
}
private function whoIsListening()
{
trace("Checking");
this.broadcastMessage("checking");
}
}

// ************************************
// in my FLA

var model:myModel=new myModel();
var listener:Object=new Object();
listener.checking=function(time){
trace("Checking was received.");
}
model.addListener(listener);

View Replies !    View Related
Please Help Me Understand AsBroadcaster
Hello,

I would highly appreciate it if someone can help me understand the functionality behind asBroadcaster. I have been trying to understand this example at:
http://www.kirupa.com/developer/actionscript/asbroadcaster2.htm

But it hardly serves the practicality for me. Can I use a AsBroadcaster for such purpose as:

Lets say if I had a movie clip "btn" on the stage, and there are four more movie clips on stage as well. Can I make the four movie clips as listeners? And the "btn" as the broadcaster, so when I press the "btn" clip, I can fire a function that would bring "_alpha" down to 50 for all the listener clips?

Thank you.

View Replies !    View Related
AsBroadcaster And AS2 Classes
I'm in need of some help.

Is there any way to make mcs, that are created on the stage and are assigned an as2 class, listeners of a custom event?

Right now, I'm simply looping through the instance names on stage at runtime to make them listen to an event. Kinda junky.

View Replies !    View Related
AsBroadcaster In Class
This url talks about using the AsBroadcaster: http://www.kirupa.com/developer/acti...oadcaster2.htm

But senocular doesn't address using it in .as file.

Here's what I came up for an ImageLoader class I'm in the process of writing:


Code:
class ImageLoader {
private var containerMC:MovieClip;
private var depth:Number;
private var width:Number;
private var height:Number
private var x:Number;
private var y:Number;

// Implemented by AsBroadcaster
public var addListener:Function;
public var removeListener:Function;
public var broadcastMessage:Function;

public function ImageLoader(targetMC:MovieClip, width:Number, height:Number, x:Number, y:Number) {
AsBroadcaster.initialize(this);

this.containerMC = targetMC.createEmptyMovieClip("containerMC", depth);
this.depth = depth;
this.width = width;
this.height = height;
this.x = x;
this.y = y;
}

public function loadImage(pathToImage:String) {
containerMC.loadMovie(pathToImage);
this.broadcastMessage("loading", this);
}

public function getContainer():MovieClip {
return containerMC;
}
}
Just to get it to compile I had to add the:
// Implemented by AsBroadcaster
public var addListener:Function;
public var removeListener:Function;
public var broadcastMessage:Function;

Is there a better way of doing that? AsBroadcaster isn't all that well documented...any insight on how to let Flash know those methods exist another way...or the best OOP way would be great.

Thanks

View Replies !    View Related
Asbroadcaster / Listener
Could somebody point me in the right direction of how to use this without an object or how to do it correctly with an object.

I have a timeline animation and when it gets to the end i'd like it to pretty much say "hey i'm finished" so that other events can trigger. What's the right way of doing this?

Thanks.

View Replies !    View Related
AS 2 AsBroadcaster Difficulty
Hi, I'm having and issue with AsBroadcaster. I'm trying to get different instances of the same MovieClip to respond to an event. The problem is, I can only ever get one to respond.

Here is the class for the mc broadcasting the event;


Code:
class DispatchClass extends MovieClip {

private static var events:Object;

public function DispatchClass () {
events = new Object();
AsBroadcaster.initialize(events);
}

public function onRelease () {
events.broadcastMessage("pressed");
}

public function addListener(listener:Object){
events.addListener(listener);
}
}
and here is the class for the receiving MCs:


Code:
class listenerClass extends MovieClip {

public function listenerClass () {

var obj1:DispatchClass = new DispatchClass();
var thisObj = this;

var listener1:Object = new Object();
listener1.pressed=function(){
trace("
thisObj = " + thisObj + "
");
};
obj1.addListener(listener1);
}
}
I'm sure it's something easy I just can't seem to get around it. Any help would be much appreciated. Thanks, Todd.

View Replies !    View Related
AsBroadcaster And AS2 Classes
I'm in need of some help.

Is there any way to make mcs, that are created on the stage and are assigned an as2 class, listeners of a custom event?

Right now, I'm simply looping through the instance names on stage at runtime to make them listen to an event. Kinda junky.

View Replies !    View Related
[as1] ASBroadcaster And Tweens
Is there an event broadcasted when a Tween class completes the movieclip's assigned movement?

Lets say i have a box that resizes to accomodate various sizes of content. The box is set to change _width and _height using penners easing equations, over lets say, 16 frames. Once the box has completed its resizing, it is available to accept the attachment of the new content movieclip, so I would like it to broadcast an event such as "onTweenComplete" or something similar, to listeners that handle the attachment of the new content.

Is there an event already broadcast, and if not, how would I add this broadcastable event?

Cheers guys

View Replies !    View Related
HuzzaH For ASBroadcaster
this morning, thanks to Mr. Penner's book, more precisly page 181 & 182.
I have created the long sought after "event" engine I have been needing more and more in my projects.

I want to post the code and have you guys look at it, because I am proud,
and I think it's quite usefull.
here's the code, it moves a box to three positions, then kills enterFrame.

transceiver.as

ActionScript Code:
//Initialize Event Broadcaster
xMitter = new Object();
    ASBroadcaster.initialize(xMitter);
    signal = new Object();
    xMitter.addListener(signal);
// --------------------------------------------------------------
//Proto------ autoMoveMe(x,y,que) -------------------------
MovieClip.prototype.autoMoveMe = function(xPos, yPos, que) {
    this.onEnterFrame = function() {
        var xdif = xPos-this._x;
        var ydif = yPos-this._y;
        this._x += xdif/6;
        this._y += ydif/6;
        if (Math.abs(xdif)<=0.25 && Math.abs(ydif)<=0.25) {
            this._x = xPos;
            this._y = yPos;
            xMitter.broadcastMessage("onBeep", que);
        }
    };
};


Code on the first frame:

ActionScript Code:
#include "transceiver.as"
 
//events
box.autoMoveMe(400,200,0);
signal.onBeep = function(que) {
    trace(que);
    switch(que) {
        case 0:
            _root.box.autoMoveMe(500,300,1);
            break;
        case 1:
            _root.box.autoMoveMe(100,20,2);
            break;
        case 2:
            _root.box.onEnterFrame = null;
            break;
    }
}

View Replies !    View Related
ASBroadcaster In Mx 2004?
Is it present? I tried tut about it here and it seems it doesn't work, has it been changed to something different now?

View Replies !    View Related
ASBroadcaster.initialize(s)
HI THERE!!!
i have this code but what is the mistake

excuse my english

Code:
s = {};
Mouse.addListener(s)
ASBroadcaster.initialize(s);
s.onMouseMove = hola
hola = function(letra) {
this.broadcastMessage("hola");
trace(letra+" hola");
};
a.hola("a");
b.hola("b");
c.hola("c");
d.hola("d");
s.addListener(a);
s.addListener(b);
s.addListener(c);
s.addListener(d);

View Replies !    View Related
ASBroadcaster : The Definition
In layman's terms (non dev speak) can someone describe to me what exactly ASBroadcaster is?

I've read a few posts here and visited chattyfig...but it's still a bit sketchy to me. I have an idea of what it is but not a concrete definition.

Can someone help?

View Replies !    View Related
ASBroadcaster To Shadow Another Movie
I have a movieclip (movie A) with an onRelease event handler defined. I need another movie (movie B) to fire a function every time (movie A) fires it's onRelease.

I think ASBroadcaster is the answer? but not sure.

View Replies !    View Related
AsBroadcaster For Movieclip Params
Is there a way to listen to a movieclip to know when it's params have changed? Something like:


Code:
var my_mc:Object = new Object();
var mc_listener:Object = new Object();
mc_listener.someEvent = function(p) {
trace("p changed to: " + p);
};
AsBroadcaster.initialize(my_mc);
my_mc.addListener(mc_listener);
my_mc.broadcastMessage(my_mc._height);
That does not work but is the logic in place?

Thank you!
John

View Replies !    View Related
AsBroadcaster Inside Classes
I am trying to make this works:

AsBroadcaster.initialize(_level0.kingoe);
_level0.kingoe.addListener(this);

inside a class, but it seems its not working, am i doing domething wrong or AsBraodcaster dont work inside a class?

View Replies !    View Related
AsBroadcaster: Can You Give Me A Simple, Useful Example?
Hi there,

After reading this: http://senocular.com/flash/tutorials...caster/?page=2
I understand the concepts but can't think how this would be useful at all.

Can someone show me a simple example of how this would be useful? Or should I forget about it and use event dispatcher?

Thanks.

View Replies !    View Related
AsBroadcaster For Movieclip Params
Is there a way to listen to a movieclip to know when it's params have changed? Something like:



Code:
var my_mc:Object = new Object();
var mc_listener:Object = new Object();
mc_listener.someEvent = function(p) {
trace("p changed to: " + p);
};
AsBroadcaster.initialize(my_mc);
my_mc.addListener(mc_listener);
my_mc.broadcastMessage(my_mc._height);
That does not work but is the logic in place?

Thank you!
John

View Replies !    View Related
AS3: Is There An AsBroadcaster Or Do I Have To Do More Than Convert My Old Stuff Now?
Just wondering if there's an ASBroadcaster in AS3.0 or it's been deprecated. I've done some research, but it references me to EventDispatcher which sort of annoys me a bit, but does that mean ASBroadcaster is out?

View Replies !    View Related
Does AsBroadcaster Break MovieClipLoader?
I wrote a class that extends MovieClipLoader and included AsBroadcaster in it so that I could broadcast custom events when a series of images was loaded.

It stops after loading the first image if I include AsBroadcaster. If I comment it out, all of the images load.

Any suggestions?

Jase

View Replies !    View Related
AsBroadcaster Broadcasting From A Class
I have a class as below. I'd like it to broadcast an event such as invader destoyed but is not happening? I posted all the script in the class but I guess only the AsBroadcaster and listener parts are relevant.


ActionScript Code:
class Invader extends MovieClip {
    private var i:Number;
    var invaderInt:Number;
    var speed:Number = 3;
    private var invaderContainer_mc:MovieClip;
    public function Invader(target:MovieClip, depth:Number, collisionThing:MovieClip) {
        invaderContainer_mc = target.createEmptyMovieClip("invaderContainer"+depth, depth);
        bringInvaderPic();
        invaderInt = setInterval(this, "moveFuncInvader", 10, collisionThing);
    }
    private static var AsBroadcasterDependency = AsBroadcaster.initialize(Invader);
    public static var broadcastMessage:Function;
    public static var addListener:Function;
    public static var removeListener:Function;
    private function bringInvaderPic():Void {
        invaderContainer_mc.attachMovie("invader", "invader", 1);
    }
    private function moveFuncInvader(collisionThing):Void {
        invaderContainer_mc._x += speed;
        if (invaderContainer_mc.hitTest(collisionThing)) {
            broadcastMessage("invaderDestroy");// here is the broadcast part
            destroyInvader();
            trace("explode!");
        }
        updateAfterEvent();
    }
    public function destroyInvader():Void {
        invaderContainer_mc.removeMovieClip();
        clearInterval(invaderInt);
    }
}


the relevant code in the main fla is


ActionScript Code:
invader1 = new Invader(this, 10, ship.bulletcontainer);
counter = {};
invader1.addListener(counter);
counter.invaderDestroy = function() {
    trace("counter responds by saying invader destroyed");
};

View Replies !    View Related
AsBroadcaster/Listener Question
hello People..
So I have a flash movie that is composed of many MCs along a timeline, and its designed to play thru from beginning to end..
Now I need to add play/pause functionality to it, but of course if I use these controls to just stop the main timeline, then the sub-MC's just carry on playing..
So, I want to use MovieClip.prototype to allow each MC to be 'stop'ed and started again, if it can 'listen' to the Play/pause controls..
I dont want to make each MC have an onEnterFrame, so the q is: How do I use broadcasting and 'listeners' to achieve this ?
Googling and LiveDocsing just seems to show me how to put a listener on an instance of eg a button..
I need that button to broadcast a _global variable 'status', that will be 'playing' or 'paused', and have every instance of every MC in my movie respond accordingly..
Anything simple tutorially out there, or anyone got some judiciously neat code for me ?
Thanks all.

View Replies !    View Related
MX Listeners And Hidden ASBroadcaster Explained
I finished my write up on it this morning for anyone interested.

It assumes you have a basic understanding in object oriented techiques within Flash, though it should be pretty striaght forward and easy to understand. I think its definitely one of the better explanations out there on the subject.

http://www.kirupa.com/developer/acti...roadcaster.htm


_____________________________________________

(next posted article on setInterval)

View Replies !    View Related
[F8] Calling AsBroadcaster Events Across Classes
Hi All,

I'm having a little difficulty getting a broadcaster event to call a function inside another class any ideas??

I have 2 classes and the fla, the code in class one is as follows:

Code:
class CMaster {
// properties
var oListener:Object;
var oCNavigation:CNavigation;
// methods
private function SayHello():Void {
trace("hello");
}
// constructor function
public function CMaster() {
oListener = new Object();
oCNavigation = new CNavigation();
oCNavigation.oListener = oListener;
//
oListener.onHello = SayHello;
}
}
Class two:

Code:
class CNavigation {
// properties
var oBroadcaster:Object;
var oListener:Object;
// methods
private function InitBroadcaster():Void {
AsBroadcaster.initialize(oBroadcaster);
oBroadcaster.addListener(oListener);
}
private function SayHello():Void {
oBroadcaster.broadcastMessage("onHello");
}
// constructor function
public function CNavigation() {
oBroadcaster = new Object();
oListener = new Object();
InitBroadcaster();
SayHello();
}
}
And the fla instantiates the CMaster class with :

Code:
var oCMaster:CMaster = new CMaster();
I'm finding that the _listeners array is getting something but it appears empty in the debugger...thus the broadcast is never received by the listener.

RipX

View Replies !    View Related
6 Button Movieclip Problem Using AsBroadcaster
Hi all,

I am wondering if someone will help me with the following:

I am trying to create 6 buttons( all of which act like light switches) Each button
will 'listen' to one another. Each of the six buttons must be aware of what the other buttons switch states are.

This is part of app that I am designing. The app requires that a 6 switch system be set up with the use of Movieclip buttons. Yes, and not a typical button type either. It must be a movieclip button. Each movieclip button has only 2 states, ON and OFF.

Basically, you can only press ONE button at a time. If for instance, button 1 is pressed, it is then considered SELECTED, and the button stays ON, while all others are reset to OFF state. Then if the user decides that button 1 was NOT the proper choice, the user can re-select to another button by pressing any one of the 6 buttons. In this case, the user had previously selected button 1, but then decides that they did not want button one, so therefore they decided that button 2 was the proper choice. By selecting button 2, button2's state is then switched to ON, and any previous selections of the six buttons, are then reset to OFF.


But heres the problem. If the user reselects button 2, then all the other buttons must reset themselves from a 'selected state' and each movieclip button must return to it's previous UNSELECTED STATE.

I am having a great deal of problem with this, as I am playing 'catchup' to OOP 2.0 code standards. I was used to the old Flash MX.

Here is my code thus :

-------------------------- AS 2.0 Code ------------------

// setting up the event listener class for 2004mx

// begin initialization - I have made all the buttons here a
// broadcast object, cause EACH one must be listening to the other
var mymap:Object=new Object();//create broadcast object
var mapbutton1:Object = new Object(); // create listener object
var mapbutton2:Object = new Object(); // create listener object
var mapbutton3:Object = new Object(); // create listener object
var mapbutton4:Object = new Object(); // create listener object
var mapbutton5:Object = new Object(); // create listener object
var mapbutton6:Object = new Object(); // create listener object

mapbutton1.onRollOver = function() {

mapbutton1.gotoAndStop(2);
}

mapbutton1.onRollOut = function() {

mapbutton1.gotoAndStop(1);
}
mapbutton1onPress = function() {

mapbutton1.gotoAndStop(2);
// movie clip then plays to the second frame of mapbutton1 and stops indicating its selection
}
// start of second button
mapbutton2.onRollOver = function() {

mapbutton1.gotoAndStop(2);
}

mapbutton2.onRollOut = function() {

mapbutton1.gotoAndStop(1);
}
mapbutton2.onPress = function() {

mapbutton1.gotoAndStop(2);
}

--------------------------- end of code ---------------------

So, as you can see, I have not gotten too far. One of the problems i have encountered is controlling the movieclip buttons and telling them to reset themselves. To return to the OFF state (which would be frame 1) of each button.



Can anyone who is EXPERT using the ASbroadcaster method please let me know what it is I am doing wrong with the code here?

Or if you have a snippet of code that will work for this, the please post it.

I am also interested in any URL's that you may have on this subject.


Thanx in advance!

View Replies !    View Related
ASBroadcaster.initialize(MovieClip.prototype);
Anyone know how to do this without having every MovieClip use the same _listeners array?

View Replies !    View Related
MX Listeners And Hidden ASBroadcaster Explained
for those of you who might not have seen it on FK:

http://www.umbc.edu/interactive/flas...roadcaster.php

good to know and one of the better explanations of it I think.

View Replies !    View Related
AsBroadcaster To Self Vs. Simply Calling The Function
Hello good people!

I'm writing a class that needs some hooks in it for events. So you can create an instance and then add functionality to it by adding a method like this:

bunny = new Bunny()
bunny.onHop = function(){
this.turnGreen()
}

Then in the Bunny class every time it hops I would provide a hook for the event.

Well my initial approach was to initiate AsBroadcaster and have the event 'onHop' broadcasted every time the bunny hopped. That works fine but I realized that in this situation there didn't seem to be any difference between these two:

private function seeCarrot(){
this.broadcastMessage('onHop')
hop()
}

and:

private function seeCarrot(){
this.onHop()
hop()
}

The thing is I don't really like the idea of calling functions that don't exist in the class and are optional for the user of the class. But it is surely a lot less code to just call the function and if it is defined by the user great, if not it just goes into the ether or whatever happens to function calls to undefined functions in Flash....

So I was wondering if anyone had any input. Is there anything technically wrong with calling undefined functions in flash? I personally feel that broadcasting the message to 'this' makes more sense somehow because the method may or may not be defined and really this is the kind of thing broadcasters are made for I think. But there doesn't seem to be any difference in Flash when I just throw the function call out there and let it be picked up if there is anything to catch it.

View Replies !    View Related
ASBroadcaster Woes - _listeners Shortcut?
In an attempt to create a flash version of minesweeper, it occured to me (after 3 hours of heading in a different direction) that ASBroadcaster might make my life easier. My question concerns the _listeners array. I tried and failed to edit it directly. Instead of using the addListener method, I simply defined the listeners array as in

ActionScript Code:
obj._listeners=[sub1, sub2, etc];

however it didn't work. Is it absolutely necessary to use the addListener method? If so, why? Thanks for your time.

~pkghost

View Replies !    View Related
Difference Btwn EventDispatcher And AsBroadcaster
What is the difference between using EventDispatcher and AsBroadcaster?

View Replies !    View Related
Adding Commands To A Function ( ASBroadcaster? )
My goal is: add a command to an previsious defined function/event.

I don't kwon if it's possible in actionscript, but a workaround should be to call another function/event when my already defined function/event fires.

Any idea?

Thank you in advance, at least for reading...

View Replies !    View Related
Help With AsBroadcaster Making A Button Manager Class
I am trying to create a create a class that stores an array of movie clips. I want the class to register itself to receive onRelease events from each button in the array. I have been trying to us AsBroadcaster but I suspect I'm not understanding it to I'm not implementing it correctly.

Here's what I have so far:

Attach Code

class ButtonGroup {
private var groups_array:Array = new Array();

public function ButtonGroup() {

}

public function new_group( button_array:Array, id:String ):Void {
groups_array[ id ] = new Array();
groups_array[ id ].push( button_array );
for ( var p in groups_array[ id ] ) {
AsBroadcaster.initialize( groups_array[ id ][p] );
groups_array[ id ][p].addListener( this );
groups_array[ id ][p].broadcastMessage( "onRelease" );
}
}

public function onRelease() {
trace( "test" );
}
}

View Replies !    View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved