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(); }
FlashKit > Flash Help > Flash MX
Posted on: 10-07-2004, 12:48 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
[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
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
Setup Listener?
Hy,
Simple one, I need to setup listeners...
descr. path / instance
-------------------------------------------------
1. I have a MC on stage : _root.my_mc
2. Inside that one another mc : _root.my_mc.color
-------------------------------------------------
Now I need a listener for _root.my_mc.color (2), when the value of this listener is changed it needs to activate the code below. That code will color a MC (some background) with the value from the listener
my color code :
-----------------------------------------------------------
temp_color = color.split("#")[1]; // color value loaded from .txt file
mycolor = new Color(_root.my_mc.color);
mycolor.setRGB("0x"+temp_color);
-------------------------------------------------
So basically, how to setup a listener and how to "broadcast" to one and make it do stuff ?
Thankz....
Lars
MovieClipLoader And It's Listener
What can be the disavantage of setting a MovieClipLoader as it's own listener? That saves you an object doesn't it?
for example:
jazz = MovieClipLoader();
jazz.onLoadComplete = function(){
trace("loaded!")
};
jazz.addListener(jazz);
jazz.loadClip("mexico.swf", instance1);
Listbox Listener Help
Hello,
I'm learning some actionsript via a tutorial and I just finished a tutorial that is an MP3 player that loads a playlist from an XML file. I have completed the scripting and everything works great. However I'm curious how I would add to more features not covered in the tutorial.
1) To imediatly begin playing the first MP3 on the playlist.
2) After finished playing the current MP3 start playing the next MP3 on the playlist, but Stop at the end of the play list without recycling to the first song.(I'm assuming this would be along the lines of a listener but I haven't been able to come up with something that works.)
Thanks
Here is the script so far:
var playlistXML:XML = new XML();
playlistXML.ignoreWhite = true;
var music:Sound = new Sound();
var currentSong:String;
playlistXML.onLoad = function(){
var tempArray = new Array();
for(var i = 0; i < this.firstChild.childNodes.length; ++i){
tempArray[i] = new Object();
tempArray[i].label = this.firstChild.childNodes[i].firstChild.nodeValue;
tempArray[i].data = this.firstChild.childNodes[i].attributes.URL;
}
playlist_lb.dataProvider = tempArray;
}
playlistXML.load("playlist.xml");
var playlist_lbListener:Object = new Object();
playlist_lbListener.change = function(){
currentSong = playlist_lb.selectedItem.data;
}
playlist_lb.addEventListener("change", playlist_lbListener);
play_btn.onRelease = function(){
music.stop();
music = new Sound();
music.onID3 = function(){
song_txt.text = this.id3.TIT2;
}
music.loadSound(currentSong, true);
}
stop_btn.onRelease = function(){
music.stop();
}
Variable Listener
hi, i have flash movie with a variable "key". This variable is changed dynamically from external to the flash movie from a custom player. I want to be able to watch this variable and do something when it changes, is this possible???
Thanks for the help. Tony
Mouse.listener + OSX
I built an application that uses a mouse listener to start everything. It works flawlessly on a PC running XP as an executable. When tested on OSX the listener doesn't work at all and the app will not start. Are there any issues with Macs in general running listeners? The Mac user unpacked the .hqx file and ran that and nothing happened. I'm at a loss.
-Rob
Add Listener And BroadcastMessage
Im back to learning flash after a year off doing css xhtml sites, forgot how frustrating and satisfying it can be.
im creating a drop down menu, Ive used robert penners easing equation for the motion. Then I noticed that he had used
Code:
this.broadcastMessage("clipIsGone", this._parent);
//Which I traced to make sure of target
trace("broadcast "+ this._parent._name)
So makes sense to add a listener to the mcs which move, however im having no joy, or ive just not understood listeners correctly, ive tried
Code:
_root.myClip["menuItem"+s].addListener(_root.blank)
_root.blank.clipIsGone = function(){
trace("gone");
}
//also tried
function clipIsGone(){
trace("gone");
}
any ideas?
Keypress/listener Help
Hello all,
Here is what I want to do, I have a test in which the user clicks a button to identify their response to a question, however what I want to do is use a key press instead, I have the correct response done, that is easy, but what I am wondering is if it is possible to somehow make a button which will be activated with ANY key press, other than the correct one, so it will log the proper negative feedback to my array.
Example would be the correct response would be key L but the other three buttons would be activated by any key other than L.
I am using Flash MX and any advice or help would be greatly appreciated.
Cheers!
Listener Problem
I am applying the following code to a button component and it isn't working:
scrollLis = new Object();
scrollLis.press = function() {
this.startDrag(this, false, 0, 0, 0, 200);
};
scrollLis.release = function() {
this.stopDrag();
};
Knob.addEventListener("press", scrollLis);
Knob.addEventListener("release", scrollLis);
I'm pretty sure there isn't anything wrong with the code.. any ideas?
|