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...
FlashKit > Flash Help > Flash ActionScript
Posted on: 08-04-2005, 07:19 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
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...
Dynamic Text Field Listeners
Can I have a listener that looks for a change in a 'dynamic' text field.
I got this working for a input text field:
function listen(){
trace("lee");
}
switchText = new Object();
switchText.onChanged = listen;
slideLoaded_txt.addListener(switchText);
but it doesnt work for a dynamic text field.
can anybody help me?
lee
Create Dynamic Event Listeners
Alright so I have a loop that creates a dynamic amount of MovieClips depending on how many items are in an XML feed and I need these MovieClips to be buttons but I can't figure out how to do this. Here is my code...
Code:
while (blockCount <= spotCount) {
var spotBlock:MovieClip = new MovieClip();
spotBlock.graphics.beginFill(0x0069A3);
spotBlock.graphics.drawRect(0, 0, 11, 11);
spotBlock.graphics.endFill();
spotBlock.x = blockAdjust;
spotBlock.y = 155;
blockAdjust -= 22;
blockCount++;
addChild(spotBlock);
}
Do Dynamic Text Boxes Require Listeners?
I have hard coded clip info that I am trying to put into an info pane. It works when it is just my scroll pane and the clips, but when I put it in my full flash file, I no longer have dynamic text updating onRollOver. Here a sample piece of script. the thumbnail reeves, which is a button, is inside a clip with instance cPC, then inside panel. Panel has the action script that is below. The text boxes are in info, title_mc (etc.), title(etc.) with instance name of title and box set to dynamic. Do I need a listener, or any suggestion on the hangup? I did a trace, and it fires off the content box text when I rollover, just no in the text box itself.. .
Attach Code
reeves.onRollOver = function(){
var xscaleT:Tween = new Tween(reeves, "_xscale", Elastic.easeOut, 100, 120, 1, true);
var yscaleT:Tween = new Tween(reeves, "_yscale", Elastic.easeOut, 100, 120, 1, true);
_root.info.title_mc.title.text = "Mr. Reeves";
_root.info.from_mc.artist.text = ""
_root.info.cat1_mc.cat1.text = "Short Film"
_root.info.cat2_mc.cat2.text = ""
_root.info.content_mc.content.text =""
}
OnChange, Listeners And Dynamic Text Fields
How come a subscribed-to textfield won't broadcast to the listener when its value is changed? I have a dynamic text field, and when the variable it displays changes, I want it to broadcast to the listener.
The following code works when I change the textfield to input text, and enter something, however when I change it back to dynamic nothing happens:
this.onChanged = function() {
trace('changed');
};
_root.answerIdent.addListener(this);
Any light on what, exactly, flash considers an onChange event? Is it purely limited to input textfield value changes?
Thanks,
Noah Pedrini
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.
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?
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
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.
MovieClipLoader And Listeners In Different Swf Go Where?
Here we go again...
I've playedaround with this for like six hours now without getting it to work so obviously I´m missing something - I guess I have some kind of conflict...
I have a master.fla with a MovieClipLoader (MCL from now on) that I'd like to use from different swfs. I use it to load a swf called "brain". In "brain" I use the MCL on level 0 (master) to load a "head.swf" into a movieclip (in brain.swf). This works fine.
In "head" I load different photo.jpg using this code
Code:
this.attachMovie("mask","mask",10,{_x:314,_y:62.5});
this.createEmptyMovieClip("mc_headPicture", 5);
var hjHeadListener:Object = new Object();
hjHeadListener.onLoadInit = function(target_mc:MovieClip):Void {
target_mc.setMask(mask);
}
var hjHeadmcl:MovieClipLoader = new MovieClipLoader();
hjHeadmcl.addListener(hjHeadListener);
hjHeadmcl.loadClip("scen.jpg", mc_headPicture);
Firstly - if I would like to use the MCL on level 0 - how would I change the code? I've tried severel different ways but end up seeing nothing or the mask only.
Also - if I use a mask_mc loaded from a shared library (triggered in the master.fla) setMask doesn't work.Why?
Finally - you can see the mask "blink" as the swf loads, very ugly, I tried set taget_mc._visible to false before the mask is set and turn it on after but it looks the same. Is there another work around?
Haeps of thanks in advance from Snowgirl working late again
[F8] Help Regarding Event Listeners
Hello All,
I would like some help with an effect I am trying achieve.
I am controlling the text displayed in a dynamic text field with the position of the mouse.
For Example:
[code]if(_root._ymouse <100) {
_root.variable=TextOne;
} else if (_root._ymouse >100) {
_root.variable=TextTwo;
}
I would like, every time the text changes a sound to be played. I know about Sound Objects and etc, I am just wondering the best way to call a function when the text in the text field changes. Would it be with an EventListener or something completely different?
If so, can yu give me an idea how I would code it, I dont have much experience with Event Listeners.
Thankyou v.much in advance.
Using Listeners In The ImageLoadingClass
http://www.martijndevisser.com/blog/...ss-for-flash-8
This awesome image loader class has made me really happy. Though trying to fit this into my existing program has stopped me from being able to track the image's loading status.
Now he documents that you can use listeners with the movie, but I havent been able to successfully use them.
I was using the information found here:
http://flash-creations.com/notes/dynamic_loadjpg.php
To try to use the correct functions but I like a different perspective on how to track the Image using the ImageLoaderClass
Key Listeners And HitTest
Ok I have mc coming from the right of the screen moving to the left with a constant a speed. Then i have another mc that is stationary, its a bar, and goes across the height of the stage. what i want is so if the user hits a key at the right time(when the moving mc touches the stationary one) that the moving mc changes frames and continues to move. im having problems with perfecting this. im using the onKeyUp function. If I use this the user can simply hold down the key and let go right when the moving clip touches the bar. when i use the onKeyDown function you can just hold down the key the whole time.
heres the code on the moving mc(rightsym2)
PHP Code:
onClipEvent (enterFrame) {
this._x += 11
keyListener = new Object();
keyListener.onKeyUp = function() {
if (Key.getCode(Key.RIGHT)) {
if (_root.scorebar.hitTest(_root.rightsym2)) {
gotoAndPlay(2);
}
}
};
Key.addListener(keyListener);
}
if you don't understand what im saying then i'll put up the .fla
|