Actionscript 2 - Deaf Listener?
Hi,
I am having problems with getting a listener to work. I have an input textbox called tbx_quantity - the var name is also tbx_quantity. I have the following code on frame 1 of my movie:
code: var tbxListener:Object = new Object(); tbxListener.change = function(evt){ trace("I heard that"); };
tbx_quantity.addEventListener("change",tbxListener );
However, when I change the value in the textbox nothing happens.
Any ideas welcome.
Thanks
FlashKit > Flash Help > Flash ActionScript
Posted on: 05-27-2004, 07:12 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Listener Gone Deaf
Can anyone shed any light on why my Listener isn't listening any more? It worked fine until one day it just stopped. I can't find anything else in the script that would conflict in any way. There are two buttons in a radio group named "gallery". They are named "water" and "oil" The data for "oil" is "oil" and the data for "water" is "water". Click on the "oil" button and it will hilight though the trace msg does not appear. Hear is the script:
----------------------
//LISTEN FOR RADIO BUTTON CLICKS FOR THE GALLERY TYPE, THEN LOAD GALLERY DIRECTORY OF IMAGE NAMES
var galleryListener:Object = new Object();
gallery.addEventListener("click", galleryListener);
galleryListener.click = function(evt) {
theData = (evt.target.selection.data);
switch (theData) {
case "oil" :
trace("you clicked on the oil button");
break;
case "water" :
break;
default :
trace("no cases selected");
}
};
----------------------
Note that I have another movie with the same script in it which DOES work!
My Listener Is... Deaf.
I'm trying to trigger the completeHandler function when the loader is done loading IMG1.jpg. I know the rest of the code is sound, because if I move the code from the function to the main it works.
So, what am I doing wrong?
Code:
import flash.display.Sprite;
import flash.events.Event;
var logo:Sprite = new Sprite();
var loader = new Loader();
loader.load(new URLRequest("IMG1.jpg"));
loader.addEventListener(Event.COMPLETE, completeHandler);
function completeHandler(event:Event):void {
logo.addChild(loader);
addChild(logo);
}
Thank you in advance guys!
Add Caption For Deaf
I want to add caption for deaf people. I will add flash video for business. Do you know how to add caption??? I will get flash professional 8 soon!! Hope it iwll be easy job!
Can't Access Listener Object From ActionScript File?
Hi Guys,
Trying to access a listener that I have created in a .as file from within a .fla file.
My chapters.as class is as follows:
Code:
class Actions.chapters {
// Constructor function that is called from external swf file
public function chapters() {
var broadcaster:Object = new Object();
AsBroadcaster.initialize(broadcaster);
var listener:Object = new Object();
listener.chapterChange = function() {
trace("Chapter Changed");
}
broadcaster.addListener(listener);
}
}
In my FLA, I have this:
Code:
// Import chapters
import Actions.chapters;
// create an instance of the Chapters
var chapterInstance:chapters = new chapters();
// broadcast
broadcaster.broadcastMessage("chapterChange");
Now I was expecting my broadcastMessage to appear via trace, but it doesn't do a thing. Any ideas on how I can access this properly or do I have to define the listener object within the .FLA file?
Cheers,
Chris
Can't Access Listener Object From ActionScript File?
Hi Guys,
Trying to access a listener that I have created in a .as file from within a .fla file. My chapters.as class is as follows:
Code:
// Define Chapters
class Actions.chapters {
// Constructor function that is called from external swf file
public function chapters() {
var broadcaster:Object = new Object();
AsBroadcaster.initialize(broadcaster);
var listener:Object = new Object();
listener.chapterChange = function() {
trace("Chapter Changed");
}
broadcaster.addListener(listener);
}
}
In my FLA, I have this:
Code:
// Import chapters
import Actions.chapters;
// create an instance of the Chapters
var chapterInstance:chapters = new chapters();
var _currentlabel = "startup";
_level0.broadcaster.broadcastMessage("chapterChange");
Now I was expecting my broadcastMessage to appear via trace, but it doesn't do a thing.
Any ideas on how I can access this properly or do I have to define the listener object within the .FLA file? Cheers, Chris
Can't Access Listener Object From ActionScript File?
Hi Guys,
Trying to access a listener that I have created in a .as file from within a .fla file.
My chapters.as class is as follows:
Code:
class Actions.chapters {
// Constructor function
function chapters() {
var broadcaster:Object = new Object();
AsBroadcaster.initialize(broadcaster);
var listener:Object = new Object();
listener.chapterChange = function() {
trace("Chapter Changed");
}
broadcaster.addListener(listener);
}
}
In my FLA, I have this:
Code:
// Import chapters
import Actions.chapters;
// create an instance of the Chapters var chapterInstance:chapters = new chapters();
// broadcast
broadcaster.broadcastMessage("chapterChange");
Now I was expecting my broadcastMessage to appear via trace, but it doesn't do a thing. Any ideas on how I can access this properly or do I have to define the listener object within the .FLA file?
Cheers,
Chris
Actionscript 3.0 Mouse Click Event Listener Works Only Once
I'm a newbie. I'm using actionscript 3.0 and I have a separate package .as file with all my action script code. I have 2 buttons called myBtn1 and myBtn2 in my .fla file whose base class are both flash.display.SimpleButton.
The event listener for myBtn1 (buttonClickHandler) always fires correctly. But, the eventHandler for myBtn2 (textClickHandler) only fires once and only if myBtn2 is the first button to be clicked. (I realize those event handlers and switch statements look rather silly with only one item each, but I removed code.)
Why does textClickHandler only seem to work once?
Any help would be greatly appreciated!
Attach Code
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.events.Event;
public class myClass extends MovieClip {
public function myClass() {
trace("myClass constructor");
myBtn1.addEventListener(MouseEvent.CLICK,buttonClickHandler);
myBtn2.addEventListener(MouseEvent.CLICK,textClickHandler);
gotoAndStop(1);
}
public function buttonClickHandler(event:MouseEvent):void {
trace("buttonClickHandler");
switch (event.target) {
case myBtn1:
trace("myBtn1 clicked");
gotoAndStop(1);
break;
default :
trace("buttonClickHandler: unknown entry");
break;
}
}
public function textClickHandler(event:MouseEvent):void {
trace("textClickHandler");
switch (event.target) {
case myBtn2:
trace("myBtn2clicked");
gotoAndStop(2);
break;
default :
trace("textClickHandler: unknown entry");
break;
}
}
}
}
[shared Object] [listener] Attach Listener To SO?
Hi everyone,
I'm trying to build a simple sound control panel for voice-overs in an e-learning project.
I want to use one button to control whether or not users want sound played throughout the lesson.
Right now I'm using that button to write an SO that each audio file reads before playing anything. My problem now is if a user wanted to hear the audio after he or she has already entered the page. If a user clicks the audio-on button, it's simply changing the SO, not to be read until the next page and swf loads.
My initial thought was I could attach a listener to the SO, allowing Flash to interpret a change from OFF to ON and then start up the necessary sound files.
Would this work? I've searched and haven't found documentation for attaching listeners to SOs.
THANKS
Mouse Listener And Key Listener Problem..
Hi;
I used key listeners to detect the block in my crossword application but I have a focusing problem going on. I've tried everything but still couldn't find a solution. By the way I used a code that uses mouse listener to highlight the area I want to use but it sometimes craches the flash player. My .fla file is included in the message. Please help before I go mad.
.fla file :http://rapidshare.de/files/26952935/...2006_.zip.html
Thanks...
Listener Or ?
I have an interface that loads all other swf's and php into it.
My delemma is I want to set up one variable that is loaded from the php db after a user is logged in called "reg".
If "reg" has a value inserted in it from the db; Then have all the affected butons, mc's and swf's goto their registered mode.
I don't know how to set up the first part; I don't know the proper name for what I am trying to do. So I'm having trouble finding a tutorial on this subject. Which is making it hard to setup the second part.
Please Help;
Thanks
Listener Help
Had posted this in the MX room, but it's an Action Script ques, so here goes:
Been having trouble w/ a button and some movie clips:
Used to be, default movie wouldn't stop when secondary movie played (onMouseDown & rollOut).
Added a listener, works -- problem is, once listner is activated, anytime anyplace on the stage is clicked, default & secondary movies toggle.
Really annoying, 'cause 1) secondary movie is scroll text and 2) have like 4 of these buttons, so movies play on top of movies.
Any way to deactivate listener once mouse is rolled out of button?
I thought that bec code is in the button timeline, button would be hit area, not entire stage. Is a listener not the way to go??
Here's code:
----------------------
on (rollOver) {
gotoAndPlay("1open");
_root.mainStage.gotoAndPlay("stop");
_root.SuperPlay.gotoAndPlay("SuperGo");
}
on (rollOut) {
gotoAndPlay("1close");
_root.SuperPlay.gotoAndPlay("SuperStop");
_root.mainStage.gotoAndPlay("stop");
supListener = new Object();
supListener.onMouseDown = function() {
gotoAndPlay("1close");
_root.mainStage.gotoAndPlay("stop");
_root.SuperPlay.gotoAndPlay("SuperStop");
_root.SuperText.gotoAndPlay("SuperText");
};
Mouse.addListener(supListener);
}
----------------------
really appreciate it!
Key Listener
Ive read the AS dictionary and searched other posts
And still dont understand
I want a menu to ease in every time I have the M key pressed. And it to ease out ewhen I have the M key released.
I understand the easing, and have that code set up, but no matter what I just cant get the listener code to work, and I'm assuming this IS what I need
Key.Add Listener()
Hi,
does anyone know why Flash does not respond to the decimal and comma buttons on the keyboard.
function onKeyDown () {
var k = Key.getAscii();
trace (k);
}
while running this function, there is no response to these keys. Every other key works. I'm building a UI and really need these 2 keys.
thanks
With Or Without Listener
Hi,
How to return default value of List component to null i.e. List1.index = 0;?
Means if i scroll down scrollbar and with button (on (release) {bla bla})make a list component back to first item ... I ASSUME I WOULD NEED LISTENER BUT I WOULD LIKE TO TRY WITHOUT OR I'M WRONG ?
thanks in advance
Listener
I want to use a listener for to trigger a function.
Lets say the duration of a mc was 50 seconds.
When it reaches the 50 second mark I want the listener to call another function.
How would I use a listener for this?
I don't want to use setInterval or enterframe as there is far to many of them been used already and it is eating away at the cpu.
I don't know if this is true or not but I heard listeners are not hard on the CPU.
The only trigger when there called.
Or maybe I’m wrong. I'm new to listeners.
This is what I’m after but I want to use a listener or maybe someone has a better idea.
Code:
var dur=55
var position=timer.
if (position>=dur){
triggerFunction();
}
Help With Listener?
can anyone break down this code for me, i mean can someone please refrase the code to where i can make sense of it, and how i would use it? "laymans terms"
thank you as always:
Code:
var listenerObject.eventName = function(){
// your code here
};
Code:
broadcasterObject.addListener(listenerObject);
Code:
broadcasterObject.removeListener(listenerObject);
Listener
Can any object like a button or movie clip have a listener event so you can use it in the main timeline frame 1 if you like?
I am confused about what can be a listener event and what can't to use.
I am just talking about converting an object where you convert to a symbol, not a component.
I am confused ablout events and listener events as they appear to do the same thing. Can a button have an event and alisterner event in actionscript main frame (not in the actionscript for the button).
[F8] How Would I Add A Listener To This?
With the code below the function executes before I even call a start() on my fuse object. How can I avoid this? I imagine I need a listener of some sort but I have never used one before.
Here's what my code looks like now: code:
var lar1:Fuse = new Fuse();
lar1.push({target:_root.mc_1, Blur_blurX:25, Blur_blurY:5, seconds:.5, ease:"easeInBack", scope:_root.mc_1});
lar1.push({target:_root.mc_1, Blur_blurX:0, Blur_blurY:0, seconds:.25, ease:"easeOutBack", func:rollovertxt(), scope:_root.mc_1});
_root.mc_1.onRollOver = function(){
lar1.start();
};
function rollovertxt(){
_root.mc_1.txt1.setTextFormat(txtbg);
}
I would like the function to be called once the fuse tween is complete. How should I do that?
Key Listener
Hi guys,
I need to have the user to type (enter) in an input text field and then hit the enter key to go to another page. I'm trying to do it, but I'm stuck for some reason. Any help please?
See the attachment please!
[as2]Key Listener
Im using the following key listener to trigger a login function:
code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
if (Key.isDown(Key.ENTER)) {
login();
}
}
Key.addListener(keyListener);
However this triggers the login function twice, which causes the user to get a error saying they are already logged in. I have a button on the stage which triggers the same function.
code:
login_btn.onRelease = login;
And this works fine. Anyone have any ideas how I can ensure that the keylistener only triggers the login function once?
Thanks for any suggestions,
Harro
Listener Help
Hi,
I've got a function thats placing movie clips on the stage, and I need to make separate movie clips move to the next frame when you click them, but I'm not sure how to make them do that if the Delegate is inside a for loop, is it possible? do I need a listener or something?
here's my code:
public function setCubes ()
{
xArray = new Array ("10", "130", "250", "370", "490");
yArray = new Array ("15", "115", "215", "315");
memory.createEmptyMovieClip ("cubes", memory.getNextHighestDepth ());
while (lineNo <= 3)
{
memory.cubes.createEmptyMovieClip ("line" + lineNo, memory.cubes.getNextHighestDepth ());
memory.cubes.line0._y = yArray[0];
memory.cubes.line1._y = yArray[1];
memory.cubes.line2._y = yArray[2];
memory.cubes.line3._y = yArray[3];
memory.cubes.line4._y = yArray[4];
while (cubeNo == lineNo)
{
for (i = 0; i <= 4; i++)
{
memory.cubes["line" + lineNo].attachMovie("cube", "cube" + i, memory.cubes["line" + lineNo].getNextHighestDepth());
memory.cubes["line" + lineNo]["cube" + i]._x = xArray [i];
memory.cubes["line" + lineNo]["cube" + i].onRelease = Delegate.create(this, rotateCube);
}
cubeNo ++;
}
lineNo ++;
}
}
public function rotateCube()
{
}
Thanks
princess_b
Listener Help
I am having a problem, I have a var that gets set if my listener get fired off to tell me that it has been fired. So I put a while loop because I don't want anything to happen until my listener has been fired. Only problem is that locks up the movie. Is there something that I can do that lets me know that the listener has been fired?
IF Or LISTENER?
Hello all once again I am in a dilemma. First, thanks to Sophostikat for the help with the Tween/Transitions Class. I have definitely gotten what I wanted with that code help!
Now my issue:
I have three clips in my scene that move around the stage based on x and y positions. Now, what I need is a way to continually track when that clip has reached its destination so that I may fade in my album.
Do "if" statements continually run and evaluate? Or do I need to attach a announcer to tell a Listener to start the fade in animation once the clip has reached his destination?
Thanks in advance for the help!
¬badnewsblair
Key Listener
Hello Everyone
I need help!
Can anyone help me understand KeyListner functionality.
What I want to do is very simple.
I key value in the Textfiled and press Enter Button.
I should be able to trace the value enterned in my textfield.
For many in must be simple. So pls help
thanks in advance
Listener
Every object have events that you can simply code in the main frame1 eg object.onPress for a button.
I read the listener events are for object to communciate with each other as the main difference, but some objects i see have listener events but only deal with itself.
I am confused as to what a listener event is basically.
Should I Add A Listener?
I have a toggle button in my scene controlling audio levels. I also have a navigation bar movie clip, with nav buttons. When I hit any nav button, I want the toggle button also to react by executing the fade volume out function, if audio is playing. IOW, I want 2 buttons to react as if they are both being pressed at the same time.
Excuse my ignorance, but is this a potential job for a Listener object?
What Listener Mean ?
hello all,
if anyone understand what Listener mean please explain to me ?
i know how use it and i read many explanation but i can't understand it
any help well be great
Regards
Crimson
Would I Use A Listener Here?
Hey everyone,
I have a somewhat complex button that when I rollover it performs a couple different animations. When all of these animations are completed I want another movie clip to perform an action
Here is my code
Code:
btn.onRollOver = function(){
_root.tab01.dep = _root.tab01.getDepth();
_root.tab01.swapDepths(_root.tab01.getNextHighestDepth());
_global.startMove.call(tabBtm, 12, -18, 142, 85)
_global.startMove.call(tabTop, 12, -193, 142, 211.8)
_global.startMove.call(dropShadow, 0, -19, 142, 26)
_global.startMove.call(image, 12, -18, 142, 85)
_global.startMove.call(tabText, 12, -190, null, null)
_global.startMove.call(description,12,-140,null,null)
}
}
The last item with description as the target is what I want to happen last. I thought if I could somehow track the postion of 'tabText' so that when its _y is = -190 my last animation would execute.
Does anyone have any suggestions?
What Exactly Is A Listener
Im guessing that a listener is a invisible object in a frame? Is that correct. Im also guessing that in order to create a Function to be called You have to first create a listener like below
listener = new Object();
Listener.KeyUp = Function() {
Your Code......
}
?? Am I correct. Or In order for a function to respond to a users reaction. You have to create a listener like above. And a regular Function can be created but only behind the scenes. Someone help me out here
What Is A Listener
Do anyone in here know whats Listener? I would like to know more about it.
Key Listener
I am using a key listener to get the space bar to control a movie within a movie. I can see the (32) is the space bar and (16) is the shift key. Is there a reference for what number controls what keys? I have others that I want to use, but I don't know what controls what key.
Thanks,
Rich
Listener On Ftp
I know this is not the best place to ask, but since it's the best forum I know I'll try.
I have a flash upload function. How can I create a listener on my ftp that sends me a mail or whatever when a new file has been uploaded to the ftp folder..? Can I make one myself, and which language is it done with? Can't find any basic info on the net.
Listener Help
I ahve several button objects on stage and I am looking for a way to have them return their instance names or other properties without having to write a code for each. for example, for the button gaur_btn, I have
gaur_btn.onPress = function ()
{
trace(gaur_btn._x);
};
which return the x position of the button. How do I make it generic so that I do not ahve to write this for each button? Otherwise I will have tor epeat this 100 times for the 100 buttons I have which just doesnt look right. Help appreciated.
Key Listener
I'm a bit new to actionscript and does anyone know how to make a function for a button like the E key or something? cause everything I made before was with the arrow keys or the enter key or something
Can I Do This With Listener?
if have a prototype like this
Code:
MovieClip.prototype.moveToXY = function(xPos, yPos) {
this.onEnterFrame = function() {
difx = xPos-this._x;
dify = yPos-this._y;
if (Math.abs(difx)>1 || Math.abs(dify)>1) {
this._x += difx/5;
this._y += dify/5;
} else {
this._x = xPos;
this._y = yPos;
delete this.onEnterFrame;
// ready
}
};
};
can i track that "ready" state with listener? -> when the object has moved to new place x,y -> other function should start..
because i'll use that prototype with many mc:s i can't call the function in that prototype!
so, can somebody help me?
Key Listener
My key listener is working fine but not as good as i want it. the program responds at every key press but I want about 2 seconds delay before program would respond to another key press.
AS
listen = new Object();
listen.onKeyDown = function() {
if (key.isDown(key.getCode())) {
nextFrame();
}
}
Key.addListener(listen)
Why A Listener?
Hi,
I don't understand the principle: why do you need a listener for, e.g. a moviecliploader object? Can't you just make an instance of the object Moviecliploader, upon which call all the methods and properties? Like many other objects, like TextField, for example?
It's somehow confusing to me :
thank you very much
m.
Var Listener?
is there a way to make a listener for a variable?
i want this function called everytime a specific variable is changed.
i guess i could use a setInterval(function,10) but that would majorly suck.
About Listener
I don't understand what's the main purpose of listeners, like there's already onEnterFrame and onRelease and etc etc all that stuff, why should we set another listener for Mouse? any good example which shows how listeners works perfectly?......thanks.
Key Listener Or Key Down
i have created a script that builds a string from the chars as they are typed into the keyboard, however, i cant seem to make the script stop when ENTER is pressed and return the string into the clip? i have used the do-while however, when ENTER is pressed the system thinks for minutes and returns nothing!
i have a feeling this is a little 'noob' but it is a genuine actionscript question.
Listener Help
I am not a actionscripter, so please be patient with me.
Basically I have 2 functions that handle a transition - CloseWindow(), and OpenWindow(); Each of these contains a tween that opens and close a window. A movieclip will be attached to the Window while it is closed, then it will call the OpenWindow function.
My problem is that the movie is attached and the OpenWindow function is called before the tween contained in CloseWindow() is finished.
I know that I probably need to do something with listeners. I am stuck, and starting to get a bit frustrated. Any help would be greatly appreciated.
Here is a watered-down/pseudo-code version of what I am doing.
function CloseWindows() {
//close tween defined here
}
function OpenWindows() {
//open tween defined here
}
function LoadPortfolio() {
if window is open
CloseWindow();
//remove currently attached movie
//attach movie here
OpenWindow();
}
I know that I can use theTween.onMotionFinished, but how can I tell the code in LoadPortfolio that the window is closed and that mcs can be removed and attached? Since the tween is defined inside of the CloseWindow function, I am unable to access it.
Please help me :P
Listener
I know i'm pretty close...I guess i'm just not calling the listener correctly...I'm trying to get it so that each individual movie has a timer...and you have to press a key before the timer is over with. So, let's say they have to press "D" before two seconds is up...what do I have to add to my code here...(so that x will equal 2 if they press it in time?) Thanks!
ActionScript Code:
onClipEvent (load) {
var myListener:Object = new Object();
myListener.onKeyDown = blastHim;
Key.addListener(myListener);
x = 0;
}
onClipEvent (enterFrame) {
setInterval(function () {
x = 1;
trace(x);
}, 2000);
if (x == 1) {
this._alpha = 20;//means you lose...i've got other script here...
}
function blastHim() {
if (Key.getCode() == 69) {
x = 2;
}
}
}//and if x is 2...then another movie appears...
Listener Help
can anyone send me a url that explains and demonstrates listener objects?
[AS] Add Listener
Hi, I was trying to play around with "addListener" it just won't work, here's the code:
ActionScript Code:
var myPoop:Object = new Object();
myPoop.click = function(){
trace("you just clicked my poop");
}
myBtn.addEventListener("click", myPoop);
it doesn't work, any ideas?
and why do I need addListener? since there are so many build in methouds...what's the point of "addListener"???
Listener?
I am loading some content using Loadvariables.
What i used to do in this situation was make a 2 frame MC with
if (variable != "")
{do stuff that requires variables}
this clip would loop untill the variables were loaded.
Now this seem very ineficient and I have heard about something called .addlistener
Does anyone want to give me a quick rundown on listeners and how I might use it in this situation?
THX!
MC Listener From XML
Hello,
Does anyone know of a good tutorial on how to have an external file from XML converted into a MC and then be used as a button?
I will try and explain better I have a MC that loads a .jpg from an XML file. I would like to have this .jpg converted to a MC. This new converted MC then has the ability to be used as a button to go to an URL and not just any URL but a specified URL that is in the XML File.
The only example I have is at kernkonnection.com within the portfolio page. The different .jpg's loaded are what I want to become my links.
Hope I explained it ok.
Thanks,
tmoflash
Key Listener Problems
Hi,
I have a movie which requires the user to enter a code to identify themselves. I am having trouble with detecting when the enter key is pressed. My code is as follows:
onClipEvent (enterFrame) {
Key.addListener(_root);
_root.onKeyDown = function() {
_global.enteredcode = _global.enteredcode+String.fromCharCode(Key.getAsc ii());
if (Key.isDown(Key.ENTER)) {
trace("enter pressed");
}
}
}
In the finished result the trace line would be replaced by a gotoandplay.
The _global.enteredcode variable is displayed in a dynamic text field and it works fine. But enter never seems to be detected.
Apologies if this a stupid question!
Any help appreciated.
cheers
Kevin
|