Turning Listeners On And Off
Hi all,Wondering if someone can point me in the right direction. I'm doing a simulation with some screens learners have to step through. On the software, they input code(s) in a field(s) and press "Enter" and the screens populate. I've got everything setup but what I am trying to do is: after the code is entered correctly the "Enter" key enables, advances to the next frame (when they press enter) and then disables for the next screen. I've managed to setup the "Enter" key to advance the frame with this listener. The problem is that it activates when the frame is entered and they could just skip through the sim without inputting anything. So I need to have it come on after the condition is met. Listener: ActionScript Code: //This movie clip detects if the enter key has been pressed and then advances the screen to the next onClipEvent (load) {Key.addListener(myListener); EnterKeyListener = new Object(); EnterKeyListener.onKeyDown = function() { if (Key.getCode() == "13") { _root.nextFrame(); } }; Key.addListener(EnterKeyListener);} I already have something setup to recognize when the code is entered correctly. Right now I have some popups come on and a sound play. Is there a line I can add to this that will enable the listener ActionScript Code: onClipEvent (load) { this.onEnterFrame = function() { //The correct answer RVSI20 if (_root.InStratCode == "RVSI20") { _root.audioCorrect_mc.play(); //I have some information screens set to popup as well setProperty(_root.confirm01,_visible,true); setProperty(_root.enter1,_visible,true);} } } I'm pretty new to Flash so it might be something obvious I'm missing. I've looked at dozens of sites but still can't figure out this and it's driving me nuts. Thanks in advance if you can help Bob
KirupaForum > Flash > Flash 8 (and earlier) > Flash MX 2004
Posted on: 11-27-2006, 04:00 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Adding Listeners And Removing Listeners
Hi all,
I've come across a problem during the creation of a flash movie..
Basically the movie consists of two scenes. Key.LEFT moves from "help" scene to "interface" scene and numpad 9 goes to "help" from "interface".
It works fine from "help" to "interface" the Key.removelistener(helpListener) disables the Key.LEFT. But on going back to the "help" scene the Key.removeListener(interListener) doesn't disable numpad 9 enabling the user to jump to and from each scene with each press (code at bottom).
Is this usual behaviour? Does it have anything to do with help being the first scene and trying to remove something that hasn't been created yet?
Any work arounds or solutions to this problem would be greatly appreciated!!
Thanks in advance,
Ben Gazzard
Each scene;
----------------------------------------------------------------------
Help:
Key.removeListener(interListener);
helpListener = new Object();
helpListener.onKeyDown = function() {
if (key.LEFT) {
gotoAndPlay("Scene 1", 1);
}
};
Key.addListener(helpListener);
stop();
----------------------------------------------------------------------
Interface:
Key.removeListener(helpListener);
interListener = new Object();
interListener.onKeyDown = function() {
if (key.isdown(105)) {
gotoAndPlay("help", 1);
}
};
Key.addListener(interListener);
stop();
Listeners Unable To Listen To Other Listeners?
hi
i have a listener problem here. Previously, i have 2 listeners that listens to 2 listboxes for its variable, to display other stuff. It works nicely, but when i add in a third listbox,the whole flash jumbled up and it cannot receive the variable from its intended recipient previously, and always stick to 0
Code:
//////////////////////////////////////setup items in top most layer listbox
function setupTopList() {
f_Top.reverse();
for(var item in f_Top){
topList.addItem(f_Top[item]);
}
topList.sortItemsBy("label", "ASC")
}
//////////////////////////////////////////////// input items in 2nd layer listbox
function setupSecList(q) {
fSecList.removeAll();
all = counting.length
SecList._visible = false;
for(p=0; p<all; p++) {
if(f_TopR[q] === fTop[p]) {
featureList._visible = true;
featureList.addItem(fTitle[p]);
trace("p in setupSecList= " + p) // still ok here
}
}}
/////////////////////////////////////////////////////////////input items in thirdList
function setupThirdList(p) {
trace("p in thirdlist = " + p) // p is not working anymore!
thirdList._visible = false;
thirdList.removeAll();
for (j=0; j<total; j++) {
if (fTitle[p+1]=== thirdTitle[j]) {
thirdList._visible = true;
thirdList.addItem(thirdWorks[j]);
}
}}}
///////////////////////////////////////////////////////////////////////top listener
myTopBoxListener = new Object();
myTopBoxListener.change = function ( eventObj ){
var eventSource = eventObj.target;
var selectedObj = eventSource.selectedItem;
var q = eventSource.selectedIndex;
var selectedObjLabel = selectedObj.label;
setupSecList(q);
}
topList.addEventListener ("change", myTopBoxListener);
////////////////////////////////listens to secList for command
myListBoxListener = new Object();
myListBoxListener.change = function ( eventObj ){
var eventSource = eventObj.target;
var selectedObj = eventSource.selectedItem;
var p = eventSource.selectedIndex;
var selectedObjLabel = selectedObj.label;
clickChange(p);
setupThirdList(p);
trace("p in listbox listener= " + p)
}
secList.addEventListener ("change", myListBoxListener);
function clickChange(p){
trace("p in clickchange = "+ p)
if (loaded == filesize) {
picture.loadMovie(image[p-1]);
desc_txt.text = description[p-1];
}
}
//featureList.setChangeHandler(samplist(p+1)); should i put this line in??
i hope my question is understood. appreciate any help ..
Listeners? I Can't Figure Out Listeners/broadcasters
Hello AS gurus... I need your help.
I have a movieclip - which when it stops it assigns a value to a global variable. (ie. _global.variable = 3)
Now, how do I have a listener on my main timeline that is listening for changes in the global variable & will do a certain number of commands based on the value of this variable.
ie. If _global.variable ever equals 3, I want it to do something & if _global.variable ever equals 4, I want it to do something else. please help
Listeners ?
I've created a generic object, 'txListener', and I want it to listen for any textfield that receives focus. I'm still learning the capabilities of flash broadcast methodology and have got as far as the code below. It traces the key pressed in the textBoxTx field.
txListen = new Object();
txListen.onChanged = function() { //Would like this to be "onReceiveFocus" somehow.
trace("key pressed code: "+Key.getCode());
}; // I belive this additional semicolon is the correct syntax.
textBoxTx.addListener(txListen);//Would like all textfields registered dynamically.
1. How can I listen for when the textBoxTx field receives focus.
2. Is it possible and how can I listen for any textfield that receives focus - is there a way to dynamically register, 'addListener', to the txListen object?
Thanks to anyone that understands this
MX Help On Key Listeners
Does anyone have a tutorial or an example on how to use the Key Listener for Flash MX? I can use Key.isDown just fine, but I have no idea how the Key Listener works. Anyone have a link or a tutorial or anything?
I'm trying to make something move diagonally when I press a combination of two keys, either the up and the right arrow, or the down and left, etc. I can't do it using Key.isDown, so I'm assuming that it requires the key listener. Any help out there?
Riki
Key Listeners
How do you add a listener to a specific key on the keyboard, and not just to the generic Key object like this:
code:
myListener = new Object();
myListener.onKeyDown = function () {
trace ("You pressed a key.");
}
myListener.onKeyUp = function () {
trace ("You released a key.");
}
Key.addListener(myListener);
What Can Listeners Do?
i recently started using listeners for checking key strokes and i was wondering, can listeners be used for anything else? can i somehow use them for hitTests? is there ANY way of doing a constant hit test w/o onEnterFrame ?
Those D*mn Listeners Again...
Hello,
In my movie there are several objects (draggable windows and such) which need to respond to a listener command. All my instances are on different target levels.
How do I add a listener "inside" a symbol so code is executed when a listening command is received? A window symbol in this case.
The plan is that the symbol will update its color as soon as a message is broadcasted. The color value is in a variable.
--------------------------------------
this needs to be executed when a listening command is received:
temp_color2 = _root.GUIcolormain.split("#")[1];
myColor2 = new Color(datarget);
myColor2.setRGB("0x"+temp_color2);
--------------------------------------
So I need something like :
if a listener command is received do something.
Thankz....
Listeners
I don't understand what listeners really do...i was wondering if somebody could show or tell me...
thanks
P.S. I know this sounds stupid probably but i just don't know.
Listeners Uh?
Hi,
can someone tell me what the point of listeners are in MX2004? why are they needed, whats special about them??
Key Listeners?
Hi All,
Is there a simple way to capture keystrokes? I've been making separate buttons for each key with, for example, an on(press"1")
to get the number one to appear in a textbox. Is there an easier way to do this?
Thanks!
[F8] Listeners /
Hi there,
basically - I want to fade out a MC when a certain variable is 1.
I think I need to use a listener, but not sure (have searched forum, and livedocs)
What is the best way of doing this?
e.g: when allLoaded = 1 then fadeOutMC(faded_mc);
Key Listeners
Anyone know if it's possible to access all listeners currently assigned to the Key class?
[F8] Listeners Help
I want to lock the key board out so they can no longer press keys to interface with my flash object once they have pressed a key. How is this possible?
Im using the code below to Check what key they have pressed. once they press one of those keys i dont want them to be able to "BUZZ in" using the keys no more.
Game consists of 3 players each have a key to press to buzz in and have control of the interface to answer the question.
Can this be done?
Code:
var keyListener:Object = new Object();
keyListener.onKeyDown = function() {
// compare return value of getCode() to constant
if (Key.getCode() == 65) {
trace("Virtual key code: "+Key.getCode()+" (ENTER key)");
} else if (Key.getCode() == 66) {
trace("Virtual key code: "+Key.getCode()+" (ENTER key)");
} else if (Key.getCode() == 76) {
trace("Virtual key code: "+Key.getCode()+" (ENTER key)");
}
};
Key.addListener(keyListener);
Xml Listeners
I was wondering if there is anyway to grab the information from an XML file without using a listener? I have searched google and have only been able to find it using listeners. All I want to do is load an XML, parse the info, an process it to do what I need to do.
How Many Listeners?
I have a button that when clicked, loads
1. an external swf (via MovieClipLoader Class)
2. some variables from an external txt (via LoadVars class)
3. an external picture (via MovieClipLoader Class)
How can I be notified that all of them have been loaded? Should I use 3 listeners? Can this be done by simple 1 listener?
Listeners And Such
Hello, I am new here!
I have a question regarding listeners.
Here is my code:
var myInterval:Number;
musicPlayer._alpha = 0;
Mouse.addListener(myListener);
myListener.onMouseMove = function() {
if (aHitArea.hitTest(_root._xmouse, _root._ymouse, true)) {
myInterval = setInterval(mChange, 5);
}
};
function mChange() {
musicPlayer._alpha++;
updateAfterEvent();
if (musicPlayer._alpha == 100)
clearInterval(myInterval);
}
now, how would you suggest me fading the alpha on musicPlayer when the mouse is off the aHitTest area?
I added an else statement:
myListener.onMouseMove = function() {
if (aHitArea.hitTest(_root._xmouse, _root._ymouse, true)) {
myInterval = setInterval(mChange, 5);
} else if (bHitArea.hitTest(_root._xmouse, _root._ymouse, true)) {
musicPlayer._alpha = 0;
}
};
but that only changes the alpha to 0 for a second then sets it back to 100.
i know this is a long one, but any help is always appreciated.
also, on listners and mousemove - does this affect the cpu cycles? at some point should i removeListener?
thanks again
Help With Listeners...
I am creating a class (Blog) that loads data from a database and then handles that data. The first method - blog.getData(); - in the class uses LoadVars to get the data from the db. The second method - blog.makeTitles(); - I have uses the number of records returned from the database for determining the loop length through which to process data.
So if I get 5 records returned I want to process the title of each of the 5 records.
var newBlog:Blog = new Blog();
// So I make the first call:
newBlog.getData();
// Then the second call:
newBlog.makeTitles();
The problem is that I need to wait until the data is returned from the db before making the second call. I believe the solution is to use a listener on the first call but I am unsure on how to set one up.
Listeners In AS3
Hi Masters
I move a character by mouse only in x axis. In order to move I use Event.ENTER_FRAME listener.
When the character moves to right I want to play a movieclip inside the characer movieclip, and the same for left side to simulate a walk. In order to do it, I used:
private function onEnterFRAME(e:Event):void{
...
if(mouseX > character.x){
character.gotoAndPlay(2); //I've got a mc to right_walk inside character mc
}else{
character.gotoAndPlay(13); //the same for left_walk
}
}
But it just play the frame 2 and doesn't play all the mc, and the same for frame 13 (left walk).
I'm trying the same code inside of MouseMove.MOVE listener and while you are moving the mouse it doesn't work and just play the mc when the mouse is stop.
What kind of listener or another way should I use?
Thank you for your time reading this
Help With Listeners?
Hey I have just discovered listeners and I want to know exactly what they are and what you can do with them. I understand that they monitor when an event has happened, but then what? Can someone help me out and show me some example code maybe, or give me an alternate way to make something happens when the mouse stops moving??? thanks
Listeners In AS3
I have a quick question about adding a listeners to the objects/movie clips in actionscript 3.0.
Is it possible to use an event listener other than mouseEvent?
i.e. if I'd like to trigger myFunction() only when someMovieClip.width property changed, is it possible to set listener which listens for property of object/movie clip - like height, width, x, y, alpha, etc.
Xml And Listeners
so here's the skinny,
i am trying to a create a mobile store-front for a product line. there are three products. each product has n-number of items that will be displayed in an empty movie clip. also, each product gets a different frame that a button on the stage points to. product images are loaded into the flash player via xml. a customer scolls through the product images with lieft and right [next or previous] buttons. i've got that much figured out. /// however, here comes the tricky part. i want customers to be able to take a closer look at the products. basically, i want them to be able to rollover the product [or click on a button] and get a pop-up that will show a zoomed in image of product designs. I would like to manage these close-up images with xml as well. i was thinking that maybe i could load two images into the flash player, where one would be loaded into an invisible empty movie clip that becomes visible when activated... either by a rollover or a button...(?) i was also thinking that i could create a listener that would map the product image loaded to a corresponding design image in an xml file... which would be loaded into a pop upon activation [the button would make the pop up visible and load into an image from an xml file)...(?) but, i'm not sure which is the most viable strategy. also, i want to map a button to each design that will take the customers to a check out with that product allready in the bin, and manage these variable links with xml as well.
i'm not as well aquanted with xml as i would like to be, and yes i could do this without xml, but since i want these storefronts to be mobile xml seems like the most efficent way to manage the storefronts and give each the storefront a unique line. if i can get this much figured out, i think i'll be fine figuring out how to let users create their own xml files.
thanks.
Edited: 09/06/2007 at 11:19:34 PM by Extra Taylor
Different Listeners
I'm having a field day with questions today!
I've got several classes and one of them happens to be a generic (read: reusable/ui independent) music player class. I wanted to have a different class (the ui) display the currently playing song name in a text field. It's not an issue with individual tracks but when playing playlists I need to be able to tell when the song has changed from within the ui class (Sound.onSoundComplete can't be used).
I'm guessing that listeners hold the answer but I've come across 3 different kinds of listeners (unless I'm confused); AsBroadcaster, EventDispatcher and Object.watch. Here's were I got lost, I can't seem to find a lot of info on any of them apart from AsBroadcaster!
Any help?
Listeners
Does anyone know how much memory/resources listeners take? That is if I create a bunch of listeners within my movie do I need to remove them after they aren't needed anymore? Thanksssss for the help.
Help With Listeners
Could anyone explain me how "addEventListener" and other stuff that is connected with listeners works, because i have no practic with that and i dont know a bit of it. Thanks, links to tutorials with that stuff should also be great!
Key Listeners
hey,
I'm looking for an alternative to
Code:
on(keypress){} ..
I went tot this site.. http://flash-creations.com/notes/asclass_key.php
But this code will come into effect if the key is pressed.. and also when it's down..
How do i make it so that it only registers the key when it is pressed.. but not when it is held down?
( so it's like a one time thing only .. also.. this is for keyboard events.. not the mouse events)
Thanks
Help With Listeners.
For the life of me... I can't get listeners to work, what is going wrong here? I get this error...
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at player$iinit()
at game$iinit()
Code:
package {
import flash.display.Sprite;
import flash.events.TimerEvent;
import flash.utils.Timer;
import flash.events.Event;
import flash.events.KeyboardEvent;
public class player extends Sprite {
private var speed = Math.random() *2+2;
private var timer:Timer = new Timer(30);
public function player() {
timer.addEventListener(TimerEvent.TIMER, onTimer);
timer.start();
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
}
private function reportKeyDown(event:KeyboardEvent):void {
trace("Key Pressed: " + String.fromCharCode(event.charCode) +
" (character code: " + event.charCode + ")");
}
private function onTimer(event:TimerEvent):void {
}
}
}
Help With Listeners
I'm in trouble, again. Thanks for your time.
I need an externally loaded mc (a listener) to execute a tween when another movie clip (a broadcaster) is pressed. So, when you press on mc1, mc2 executes a function. Sounds so simple. And I feel I almost cracked it. Now, I know the theory behind broadcasters and listeners, but my code simply doesn't work. I must be dumb since I couldn't figure it out from the senocular's tut on broadcasters and listeners.
To try to illustrate the problem more: listeners are a couple of arrows, left and right. They are movie clip buttons that work on the rewind principle. There's an externally loaded mc at the stage that executes its intro tween (nothing special), and when it stops I want it to start listening to the arrows. So, when on(release) on the arrow occurs, externally loaded mc executes it's outro tween, and at the end calls for the next externally loaded mc on the stage.
Now, to add another question; I have 6 externally loaded clips, called by the arrows. When the first and the last one are on the stage, I'd like to disable the previous, and the next buttons, respectively. I thought I'll just do arrow.enable = false in the first and the last clip. Any better way of doing it?
Again, thanks for your time.
Listeners Listeners And Listeners
Hello,
I have a question about listeners. Theres a motion text on my fla and i want to trigger a sound event when the motion starts and after that motion finishes the sound ends.
Could anyone give me an example or a document link about listeners. (AS2)
Listeners?
How would I remove listeners? I know I have to use removeListeners, but how? I am trying to load different movies at differnet frames in a main movie and I need to remove the object from the listener once it's loaded so I can use the same key again.
Thanks,
John
Key Listeners
Hi All,
Is there a simple way to capture keystrokes? I've been making separate buttons for each key with, for example, an on(press"1")
to get the number one to appear in a textbox. Is there an easier way to do this?
Thanks!
Why Do I Get The Last Value On My Listeners?
Hi all!
For some reason the following code doesn't work! It generates n number of menu elements but no matter what element I click on the event functions traces the data for the last element created by the loop. why is that? please help!!
Code:
private function generateMenu():void {
for(i = 0; i < productMCs.length; i++) {
var mc:Class = getDefinitionByName("btn_prod"+i) as Class;
var currentBtn:Object = new mc();
currentBtn.addEventListener(MouseEvent.MOUSE_OVER, mouseOverMenu);
currentBtn.addEventListener(MouseEvent.MOUSE_OUT, mouseOutMenu);
currentBtn.addEventListener(MouseEvent.MOUSE_DOWN, mousePressMenu);
currentBtn.x = 50+(i * 100);
currentBtn.y = totalHeight - (this.height + 10)
menuCon.addChild(DisplayObject(currentBtn));
trace("Added "+currentBtn+" to the Menu");
}
}
Listeners
I'm struggling to understand listeners and events
I'm looking to change the postion of a movieclip on the stage when the mouse pointer gets below a certain "y"position.
can anyone offer any information.
Turning Around
im trying to get my one attached mc "zombie", to flip over or turn around when the oter MC "guy", is on the other side of it.i had this code on the zombie when i didn't attach it.
Code:
onClipEvent (enterFrame) {
if (_root.guy._x < _x) {
_xscale = Math.abs(_xscale);
} else {
_xscale = -Math.abs(_xscale);
}
}
but when i use this code after i attached it,
Code:
_root.zombie.onEnterFrame = function() {
if (_root.guy._x < _x) {
_xscale = Math.abs(_xscale);
} else {
_xscale = -Math.abs(_xscale);
}
};
it doesn't work....can anyone help?
Turning SWF's Into FLA's
Anyone one know where I can get the programme that does this? I know it's about as I used to have one, before I reformated my harddrive and lost it!
Turning Off An .mp3
I have a secondary .swf loading into a master .swf. I am loading an .mp3 into the secondary .swf dynamically by creating a new sound and a new sound channel (here's my vars):
ActionScript Code:
var musicPiece:Sound = new Sound(new URLRequest("mp3s/intro.mp3"));
var mySoundChannel:SoundChannel;
var isPlaying:Boolean = false;
var pos:Number = 0;
I just have a pause button in the secondary .swf and everything works fine, the problem is that I have 3 more secondary .swfs that will load when called from buttons on the master .swf. I'm unloading the new loaders that carry the .swf childern on the main timeline of the master .swf, but the sound, of course, doesn't stop. I tried just addressing the sound channel var I made:
ActionScript Code:
this.swfIntroLoader.mySoundChannel.stop();
swfIntroLoader is the loader that I created in the master .swf that loads the child .swf (secondary .swf) with the mp3 player in it.
I've also tried to cast "swfIntroLoader" as a MovieClip and that didn't work either.
Any suggestions?
Turning
How can i turn an object around with motion tween?
Turning
How can i turn an object around with motion tween?
Turning .swf Int .fla
Hi,
I have a very Big problem....I created a website for a friend of mine...It is the first one I made...I have lost all data on my computer including all the .fla's that made up the website...it is a tattoo website and every jpeg and thumbnail on the website were made up of .swf's...I can get all of my .swf's back if I download them from the server onto my comp. but is there a way to somehow turn the .swf back into an .fla??? Please say yes!!! I have sothink .swf decompiler but I do not think that will work...If you would like to check out the site the address is www.MikeRubendallTattoo.com (i dont know if the url is allowed in the forum, if it isnt please let me know) as you can see it is not the greatest website so I really need these files to make it better...the time it will take to build again for me will set me back alot...also if I have to make any updated pics on the site I will surely have to make all of that all over again...I will if i have to, but figured id take a shot with this...any help is GREATLY appreciated....
Thanks,
Mike C.
Turning Something ...
Howdy flash people.
I can't work out how to do this, I have a MC called "dial" and I have centered it in the MC.
Now when I press on it I want it to turn with the cursor like a real dial so if I press it and turn it left it will turn left and it will turn to whereever my cursor it on the stage.
Any help would be great :D
Key.? Listeners Flash MX
Hi all,
I've come across a problem during the creation of a flash movie..
Basically the movie consists of two scenes. Key.LEFT moves from "help" scene to "interface" scene and numpad 9 goes to "help" from "interface".
It works fine from "help" to "interface" the Key.removelistener(helpListener) disables the Key.LEFT. But on going back to the "help" scene the Key.removeListener(interListener) doesn't disable numpad 9 enabling the user to jump to and from each scene with each press (code at bottom).
Is this usual behaviour? Does it have anything to do with help being the first scene and trying to remove something that hasn't been created yet?
Any work arounds or solutions to this problem would be greatly appreciated!!
Thanks in advance,
Ben Gazzard
Each scene;
----------------------------------------------------------------------
Help:
Key.removeListener(interListener);
helpListener = new Object();
helpListener.onKeyDown = function() {
if (key.LEFT) {
gotoAndPlay("Scene 1", 1);
}
};
Key.addListener(helpListener);
stop();
----------------------------------------------------------------------
Interface:
Key.removeListener(helpListener);
interListener = new Object();
interListener.onKeyDown = function() {
if (key.isdown(105)) {
gotoAndPlay("help", 1);
}
};
Key.addListener(interListener);
stop();
Key Presses And Listeners
HI! i am using key presses for certain things to happen within my movie but for one scene I want a key press to make one thing happen and then on another scene i want the same key press to make another thing happen.
The trouble is the key press is acting as a global for the whole file. i can't seem to remove them for each scene..i've tried removing listeners but this doesn't seem to work!!
Help! Any ideas?
Listeners, MX, Web, And What The Heck Is Going On
I've been trying to create a listener for text input. I've looked at, downloaded, and studied this for a while from several sources. I even tried and easy one like:
myObj = new Object();
myObj.onKeyDown = function() {
x = Key.getAscii();
trace("You hit: " + x);
};
Key.addListener(myObj);
I would publish it to the intranet and still it wouldn't work. After about four and a half billion attempts, I tried just testing the movie from the Flash MX app. Lo and behold it works. Now, why doesn't it work after I publish to the intranet?
MX 2004 Listeners
Does anyone know why this does not work.
myListener = new Object();
myListener.click = function(evt){
trace(evt.type + " triggered");
}
Location_cb.addEventListener("click", myListener);
Location_cb is a combo box.
Or is their a simpler way to know when a combo box has changed? This is right out of the flash dictionary and it wont work. Also I am running Flash MX 2004 Pro with AS 2.0 and when I go
var myCombo:ComboBox = new ComboBox(); I do not get code hints.
Events And Listeners
I'm having a lot of trouble getting Events and Listeners to work properly.
Some of the flash built-in objects (such as MovieClipLoader) have several listener method outlines for events they broadcast (such as onLoadStart or onLoadProgress). I know how to generate an event using dispatchEvent and I can get a listener function to be called appropriatly for the required event. What I can't do is pass the parameters from my event in a way that matches the listener implementation of the flash objects. The best I can do is get an event object with parameters, which I have to then extract data from within the function.
code: // listener method for MovieClipLoader.onLoadProgress event
listener.onLoadProgress = function(target_mc:Object, bytesLoaded:Number, bytesTotal:Number)
{
...
}
// listener method for my own onLoadProgress event
listener.onLoadProgress = function(eventObject:Object)
{
// extract parameters from event object
var target_mc:Object = eventObject.target_mc;
var bytesLoaded:Number = eventObject.bytesLoaded;
var bytesTotal:Number = eventObject.bytesTotal;
...
}
What I ultimately want to do is have an object create the exact same events as MovieClipLoader, so I can create dummy events to test preloaders with locally. I already have the code to create those events, but I can't seem to get the parameters passed to fool already existing listener implementations.
Can anybody help?
Listeners And Dynamic MCs
i'm so full of questions these days...one of the urgent ones is:
can anybody point me to a decent tutorial on how to use listeners, especially how to attach them to dynamically created mcs and for various events?
i have been messing around with listeners lately, but i cannot get them to work...
Onresize Listeners
Hey...i have movie clips loaded using Listeners. i.e.
Stage.scaleMode = "noScale";
Stage.align = "TL";
Stage.addListener(this);
this.onResize = function() {
menu1._x = Stage.width*(0/100);
menu1._y = Stage.height*(50/100);
};
this.onResize();
What i would like to introduce is another movie clip that will scale according to the browser (however without distortion...maybe 90% of browser width for example...)
...how can i do this is the initial script contains 'noscale'.....
many thanks in advance
Dynamic Mc's And Listeners
Hi all,
I'm creating a business directory where the entries are read from an XML file. I store each entry in objects and associative arrays so I can loop through eachentry and place it on the stage. Depending on different attributes for each entry, different buttons will be created. I now need these dynamically created buttons (which are mc's, subclassed from MovieClip) to have listeners that responds to when the button is being clicked, get the information from within the button of what action to take (go to a certain webpage, load another movieclip etc). What I'm looking for is something like (pseudocode):
code:
for (each entry in xml file) {
entry_mc = dir_mc.attachMovie('mcEntry', 'dir'+i, 21+i);
entry_mc.button1.setPath(path);
entry_mc.button1.addListener(listener);
}
function mouseclicked(button) {
if (button class of DirButton) {
path = button.getPath();
this.attachMovie(path etc)
}
}
Now my question is: how do I create a listener that listens to the dynamically created buttons, and when clicked gets the information from my subclassed mc? Something like in Java's actionPerformed...
Listeners And FLV Cue Points
Hi,
I'm pretty sure this is simple, it's just that I've never used a listener before.
I want to play an flv and use cue points in the flv to have text in a dynamic text field change, just to describe what is playing.
Any help would be greatly appreciated.
|