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




1180 Error With Event Listener



I'm trying make a simple action script that when a countyis clicked I get a trace return telling me the county was clicked.I have a .fla file named Map that has a symbol named "Morrow" in it,and a .as file named Morrow.as in the same folder with the followingcode:package {import flash.display.MovieClip;import flash.events.MouseEvent;public class Morrow extends MovieClip {addEventListener(MouseEvent.CLICK , Morrow ); public function Morrow(event:MouseEvent):void {trace ("Morrow is clicked");}}}I keep getting a 1180: Call to a possibly undefined method addEventListener.



KirupaForum > Flash > ActionScript 3.0
Posted on: 04-21-2008, 01:38 PM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

ERROR: Adding An Event Listener To A Button In The Main Timeline
I am trying to get a simple script to work temporarily to show functionality. This file is a menu.swf file that will load content.swf's below it.

There are 4 buttons on the main timeline and a stop at frame 40. On the same layer that my button exists and on frame 40, I have this code under actions. dineContent is the instance name of the button I'm referencing.

However, I keep getting an 1120 Error Access of Undefined Property.

I know I can add an event listener to an instance name. Do I need to create a movie out of all these buttons and then reference the button instances inside the movie?








Attach Code

function buttonClick(event:MouseEvent):void
{
var newContent:Loader = new Loader();
newContent.load(new URLRequest("dineContent.swf"));
addChildAt(newContent,0);
}
dineContent.addEventListener(MouseEvent.CLICK, buttonClick);

Event Listener Woes: Error 1120: Access Of Undefined Property
I'm having trouble with buttons. I've tried two sets of code and get the same result: an "1120: Access of undefined property enter_btn" error. Here are the two sets of code I am using:


Code:
function onEnterClick(evt:MouseEvent):void {
gotoAndPlay(71);
}
enter_btn.addEventListener(MouseEvent.CLICK, onEnterClick);

and


Code:
enter_btn.addEventListener(MouseEvent.CLICK, navigate);

function navigate(event)
{
gotoAndPlay(72);
}


I've set the instance name for the button but keep getting the error. Do I need to set up a variable first? I'm learning Flash and AS on my own and am pretty confused. Any help is appreciated.

Thanks!

1180 Error
I'm trying make a simple action script that when a county
is clicked I get a trace return telling me the county was clicked.
I have a .fla file named Map that has a symbol named "Morrow" in it,
and a .as file named Morrow.as in the same folder with the following
code:

package {

import flash.display.MovieClip;
import flash.events.MouseEvent;

public class Morrow extends MovieClip {
addEventListener(MouseEvent.CLICK , Morrow );

public function Morrow(event:MouseEvent):void
{
trace ("Morrow is clicked");

}
}
}

I keep getting a 1180: Call to a possibly undefined method addEventListener.

1180 Error On NavigateToURL
I'm trying to understand why I get the error "1180: Call to a possibly undefined method navigateToURL." when I use the following code:







Attach Code

public function nowPrint(evt:MouseEvent) {
var url:String = "javascript:window.print()";
var req:URLRequest = new URLRequest(url);
navigateToURL(req, '_self');
}

Addchild Is Giving Me Error 1180:
I am having a problem adding a symbol to the stage and am hoping someone can help. I found one thread that I thought was going to help but the solution didn't work.

I have a Main class that extends sprite and using addChild() from there puts things on the stage quite happily.

Main creates an instance of another class, (we'll call it cMyClass, for reference) that doesn't extend anything as it doesn't need to. If I use addChild() from inside cMyClass, I get "1180: Call to a possibly undefined method addChild."

So my question is, how can I use addChild() to put things on the stage from an instance of a class that is created in Main?

Any help is appreciated, thanks.

Error #1180: Call To A Possibly Undefined Method..
Hello all (again),

Ok, I get this error message a lot and I normally know how to resolve them. However, not this one! I call a function from within a class function (and the called function is within the class .as file.) My question is: does Actionscript allow you to call a function within a function cuz it sure appears not!
My code: looks like this


ActionScript Code:
package asdata{
    //<import list suppressed >
   public class Racers extends Sprite {
   // game variables
   private var arrowLeft, arrowRight, arrowUp, arrowDown:Boolean = false;

   private var racer:Sprite = new Sprite();
   private var loader:Loader = new Loader();
   private var rq:URLRequest = new URLRequest("car.jpg");

   public function Racers() {
      //load external car image here
     addEventListener(Event.ADDED_TO_STAGE, addedHandler);

   }

//other functions here but not mentioned for a compressed version

   private function addedHandler(event:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, addedHandler);
        this.addEventListener(Event.ENTER_FRAME,gameLoop);
        stage.addEventListener(KeyboardEvent.KEY_DOWN,keyDownFunction);
        stage.addEventListener(KeyboardEvent.KEY_UP,keyUpFunction);
   }

   public function gameLoop(event:Event):void {
       if (arrowUp) {
          moveFoward();  //<--- here is where it can't find the function, it's right below! agh.
       }
   }
   
   public function moveForward(){
        var angle:Number = 2*Math.PI *(racer.rotation/360);
        var dx:Number = speed * Math.cos(angle);
        var dy:Number = speed * Math.sin(angle);

        racer.x += dx;
        racer.y += dy;        } 
     }
}

Upon compiling I get the error in the title, unable to find moveForward. Now, I'm totally stumped. The function is right there! Am I referencing the moveForward function not fully?

Also, when I show my code, should I give the full version or a compressed version? I compressed it but if someone were to try running it, it's not really a real working (or not working in this case) version.

Any hints on how to approach this is appreciated.
A puzzled AS3 newbie programmer

Setting Up An Event Listener To Listen For An Event Inside Of Another Movieclip.
I'm trying to set up an event listener on the stage that will listen for a mouseEvent.CLICK on a certain button inside a movieclip on the stage, but i cant seem to figure out how to target that specific button. Any help would be greatly appreciated.

Passing Parameters From Event Listener To Event Handler
Hi Chaps,

First of all, apologies as I know this question has been asked before, but I have spent the last twenty minutes reading this thread and still can't seem to figure out how to apply it to my situation - probably because I'm thick!

I have a number of objects which need to be rotated according to different parameters. I have a function which takes those parameters, then uses the tween class to handle the rotation. I'm then using the tweenEvent class to check for when the motion is complete. Then, I need access to those same parameters in the complete handler to do further operations. The problem I have is that the tween event class doesn't allow me to pass the parameters along to the cpmpleteHandler, so I'm stuck getting my parameters from the first function to the second function:


Code:
function rotate(parameters){

rotationTween = new Tween(object,parameter1,parameter2,........);

rotationTween.addEventListener(TweenEvent.MOTION_FINISH,completeHandler);

}

function completeHandler(e:TweenEvent){

//need access to the paremeters passed into the first function here!!

}
From reading the thread mentioned above, I have a feeling I may need a custom class to do this - please don't laugh but I've never written (or had the need to) write my own class before, so I really wouldn't know what to do. Any help greatly appreciated, but an actual code snippet which demonstrates this would be even better!

Ric.

Event Listener Mouse Event Click - Obstructions
This is an oversimplification of my problem.

I have an event listener on a sprite.
I then have portions of this sprite covered with other sprites or moveclips.

If I click a movieclip, it blocks my eventlistener on the sprite underneath it.

Is it possible to listen to the even click 'through' a movieclip. I dont want interaction with them, but I dont want them as bitmap data onto the base sprite either...

I Am Getting Error:TypeError: Error #2007: Parameter Listener Must Be Non-null.
I converted this code from actionscript2.0 to 3.0 and it is giving type error:TypeError: Error #2007: Parameter listener must be non-null.
at flash.events::EventDispatcher/addEventListener()
at live_fla::MainTimeline/frame1()



function playLiveStream()
{
nsPlay = new NetStream(nc);
//nsPlay.addEventListener(NetStatusEvent.NET_STATUS, event);


trace ("the NetStream status information");
var nc:NetConnection = new NetConnection();
nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
var client:Object = new Object( );
client.onMetaData = function(infoObject:Object)
{

trace("onMetaData");

// print debug information about the metaData
for (var propName:String in infoObject)
{
trace(" "+propName + " = " + infoObject[propName]);
}

};

}



// trace the NetStream status information
//nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
// function netStatusHandler(event:NetStatusEvent)
function netStatusHandler(evt:NetStatusEvent): void
{trace("Trace1")
// switch (event.info.code) {
switch (evt.info.code) {
case "NetConnection.Connect.Success":
playLiveStream();
videoLastW = 0;
videoLastH = 0;
videoSizeTimer = setInterval(updateVideoSize, 500);
break;
case "NetStream.Play.StreamNotFound":
trace("Connection failed: Try rtmp://[server-ip-address]/live" );
break;
}

}

Mouse Event Add Event Listener?
sorry, could not think of a better title!
anyway,
I downloaded a class that perfectly works for me,
it's basically a cube that rotates depending on mouse movement,
the way it does it is with the following line:

spBoard.addEventListener(MouseEvent.MOUSE_MOVE,boa rdMove);


what this does is, whenever the mouse moves the cube moves
the boardMove function does the movement based on the mouse's current position

but what i want to do is the keep the cube moving, if the mouse is on its left, it keeps rotating left, and on its rght, keep rotating right...and preferably to have the speed increase/decrease depending on how far/close mouse is to the center of the cube

any suggestions?
firstly is there an event listener that keeps calling the function just for the mouse 'being there' ? i tried rollover, didn't work

or maybe the boardMove function should be modified? i have no idea how though, totally new to AS3, here's the boardMove function for refrence:


ActionScript Code:
private function boardMove(e:MouseEvent):void {
        
                var locX:Number=prevX;
               
               
       
                if(doRotate){
               
               
                prevX=spBoard.mouseX;
                               
               
               
               
                               
                curTheta+=(prevX-locX);
                                   
               
               
                renderView(curTheta);
               
                e.updateAfterEvent();
               
                }
    }

Event Listener?
Hi,

I have an flv playing in my media display, but when the flv ends I want to "go to and play" a specific frame. The media diplay is a movie with additional graphics and a media controller attached to it. I am working in "screens" mode, does this pose any problems like having to tell it which frame # in which screen?

Event Listener?
Hello everyone,

I'm trying to learn Flash from a book and I've been getting on OK but I want to do something that my book doesn't cover.

I've got an invisible button the same size and shape and in the same position as a square dynamic text field. When the button is pressed, a movie-clip (about twice the size of the button/text field) plays around the same position. The movie-clip has 39 frames but I've set it to stop on frame 20. On frame 20, the user is presented with a set of buttons numbered 1 to 9 (and a delete button labelled 'X') arranged in a dial around the dynamic text field (and, of course, the invisible button). If the user clicks one of the numbered buttons, that number is placed in the dynamic text field, and the movie-clip completes. The movie-clip also completes if the user clicks the original invisible button a second time (this leaves the dynamic text field unchanged.) The general effect is that the dial of numbered buttons grows from the centre of the text field and then shrinks back into it when a number is chosen.

All this works fine so far, however I have several invisible buttons (with associated dynamic text fields and movie-clips) identical to the one above, and I only want one movie-clip to be active at any one time. What I'm hoping to do is to arrange things so that the movie-clip will complete if the mouse-pointer moves outside of the movie-clip area.

I imagine I'd need some kind of event listener to do that and possibly something to do with _xmouse and _ymouse, but I haven't been able to work out how to do it.

Any help you can give me would be much appreciated.

Cheers,

Jeff

Event Listener?
Hello everyone,

I'm trying to learn Flash from a book and I've been getting on OK but I want to do something that my book doesn't cover.

I've got an invisible button the same size and shape and in the same position as a square dynamic text field. When the button is pressed, a movie-clip (about twice the size of the button/text field) plays around the same position. The movie-clip has 39 frames but I've set it to stop on frame 20. On frame 20, the user is presented with a set of buttons numbered 1 to 9 (and a delete button labelled 'X') arranged in a dial around the dynamic text field (and, of course, the invisible button). If the user clicks one of the numbered buttons, that number is placed in the dynamic text field, and the movie-clip completes. The movie-clip also completes if the user clicks the original invisible button a second time (this leaves the dynamic text field unchanged.) The general effect is that the dial of numbered buttons grows from the centre of the text field and then shrinks back into it when a number is chosen.

All this works fine so far, however I have several invisible buttons (with associated dynamic text fields and movie-clips) identical to the one above, and I only want one movie-clip to be active at any one time. What I'm hoping to do is to arrange things so that the movie-clip will complete if the mouse-pointer moves outside of the movie-clip area.

I imagine I'd need some kind of event listener to do that and possibly something to do with _xmouse and _ymouse, but I haven't been able to work out how to do it.

Any help you can give me would be much appreciated.

Cheers,

Jeff

Key Event Listener
Hi,

i'm doing a game using the keyboard as controls.

I upload it onto the web and not all keys are working. Is it because of the below?


Quote:




A Flash application can only monitor keyboard events that occur within its focus. A Flash application cannot detect keyboard events in another application.




But if that is the case, why not all keys but only some are not working?

The arrow keys are working fine but the letters are not?

Anyone, any idea?

Event Listener...
I have a client that would like his video to auto play on initiation(frame 6) but as soon as the video is over gotoAndPlay(5) which would give the user the option to play the video again or select other various options(which means the video needs to be gone).

I was trying to use a listener to determine when the FLV is finished to navigate back to another frame. I believe I'm missing something here... Here is my script in frame 6

stop();
var listenerObject:Object = new Object();
listenerObject.stopped = function(eventObject:Object):Void {
gotoAndPlay(5);
};
my_FLVplybk.addEventListener("stopped", listenerObject);

Event Listener
Hi!

Is there any way of getting all the events triggered by an SWF? We need to get the name of the component (MovieClip, Button, Input Text...) which has received the event.

Any clue?

Best

Event Listener Help
What is the most efficient way of detecting when a movie clip has reached a certain frame?

The only method i know atm is adding a onEnterFrame listener and then checking every frame, but i doubt this is really efficient.

Event Listener Help
Hi, I am trying to get an event listener to work. It is just a mouseclick that traces "Click". Right now it only works when I click on the movieclip. I want it to work when I click anywhere on the stage.

Here is my code:
Main:

Code:
package src{
import src.Character;
import flash.display.MovieClip;
public class Main extends MovieClip {
public var char:Char;

public function Main() {
char = new Char();
char.x = char.y = 50;
stage.addChild(char);
}
}
}
Character:

Code:
package src{
import flash.display.MovieClip;
import flash.events.*;
public class Character extends MovieClip {

public function Character() {
this.gotoAndStop(1);
this.addEventListener(MouseEvent.CLICK, Click);
}
function Click(e:MouseEvent) {
trace("Click");
}
}
}
Please help.

Some Help Please With An Event Listener
Hi guys,

How can I create an event listener that detects when I resize
a text field dynamically?


ActionScript Code:
inputField.addEventListener(Event.CHANGE,onResizeField);

function onResizeField(event:Event):void{
   
    trace("has been resized");
}

The above doesn't work and I have tried already Event.RESIZE
without access.

Any ideas?

Thanks a lot

Event Listener
Hey there. I am, to say the least, new at writing code. Here is my problem. I currently have a video that plays thru my instance called clydeplayer as seen in the following code:

on (rollOver) {
this.gotoAndPlay("s1");
}
on (releaseOutside, rollOut) {
this.gotoAndPlay("s2");
}
on (release)
{
_root.myMC.clydeplayer.contentPath = "http://www.clydemedia.com/Video_for_site/GAN111.flv"
}


What I would like to happen after this video clip "GAN111.flv" plays is to have another video, located in the same spot, start playing automatically.

like I said, I really have very little knowledge on how to do this so any help would be great. thanks!

Event Listener?
Can anyone help me....

I am making a flash banner and it goes like this...

I have the first moveicip playing on the main timelne and then buttons that contrtol the movie loadd in... you can click on button 1 and it will take you to frame 122 where the second movie clip is and clilck on button 2 to go to frame 123 which is the third movieclip and button three restarts the first movieclip by going back to frame 1....

however, there are two things I am trying to do... I want to figure out the code that will make the movie (on main timeline) play frame 122 then frame 123... if no buttons are pressed and reloop.... but go to a specific movieclip when pressed...

and also in my movies... the buttons are not going the the main timeline.... they're playing frame 122 anda frame 123 of the current timeline (i loaded the second and third moviecip onto the timeline on frames 122 and 123 respectively)....

where do i put the code and does anyone have any ideas... I know i may have to use an event listener i think to control the timeline.. i dunno.. i'm pretty new at this.. a bit stuck...

jan

Event Listener
Hi Guys,

How can i create custom event in AS 3.0.

Thanks
MS

Event Listener
I have a script that creates falling snow. I want to be able to control the amount of snow from a slidebar how would I do this? In this case "snow_per_second" controls how much it will snow.
The current script: (sorry it's a bit long)








Attach Code

var speed:Number = 3;
var total_snow:Number = 20;
var snow_per_second:Number = 4
var hit_target:MovieClip = myObject
//
var holderSnow:Sprite = new Sprite();
var target_shake:Boolean = false;
//
addChild(holderSnow);
//
hit_target.mainX=hit_target.x;
hit_target.mainY=hit_target.y;
//
function createSnow() {
var snow:MovieClip = new MovieClip();
snow.graphics.beginFill(0xFFFFFF);
snow.graphics.drawCircle(0,0,Math.random()*3);
reset(snow);
addBlur(snow);
snow.addEventListener(Event.ENTER_FRAME,fall);
holderSnow.addChild(snow);
}
function reset(s:MovieClip) {
s.hit=s.shake=false;
s.y=0;
s.x=Math.random()*970;
s.xspeed=Math.random()*speed-(speed/2);
s.yspeed=Math.random()*speed+1;
}
function init(e:Event) {
for(var i=0; i<snow_per_second; i++) {
createSnow();
}
snow_id++;
if(snow_id>total_snow) {
removeEventListener(Event.ENTER_FRAME,init);
}
}
function addBlur(s:MovieClip) {
var blurX:Number = Math.random()*2+3;
var blurY:Number = Math.random()*2+3;
var filter:BitmapFilter = new BlurFilter(blurX, blurY, BitmapFilterQuality.LOW);
var myFilters:Array = new Array();
myFilters.push(filter);
s.filters = myFilters;
}
function fall(e:Event) {
if (!e.target.hit) {
e.target.x+=e.target.xspeed;
e.target.y+=e.target.yspeed;
if (e.target.y>600) {
reset(MovieClip(e.target));
}
if(!e.target.shake) {
if (hit_target.hitTestPoint(e.target.x,e.target.y,true)) {
e.target.hit=true;
}
}
}else{
if(target_shake) {
e.target.hit=false
e.target.shake=true;
}
}
}
function shake_int(e:TimerEvent) {
hit_target.x=hit_target.mainX+Math.random()*5-2.5;
hit_target.y=hit_target.mainY+Math.random()*5-2.5;
}

target_shake=true;

//
hit_target.addEventListener(MouseEvent.CLICK,shake_start);
function shake_start(e:Event) {
target_shake=true;
//shake_timer.reset();
//shake_timer.start();
}
//
var snow_id:int = 0
addEventListener(Event.ENTER_FRAME,init);

Event Listener, Help
If ten mc's are going to have the same MOUSE_DOWN event, how can I, inside the mouseDown-function, know which mc it is? Like;

ActionScript Code:
for(var i=0;i<10;i++) {this["mc"+i].addEventListener(MouseEvent.MOUSE_DOWN, press);}function press(e:Event) { // lol? Could it be mc0 or mc2 or mc9? wtf...}

Error: Error #2094: Event Dispatch Recursion Overflow.
??? what the heck is this error from?

Error: Error #2094: Event dispatch recursion overflow.


Code:
package com
{
import flash.display.Sprite;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.events.EventDispatcher;

public class ThemeButton extends Sprite
{
public function ThemeButton(str:String)
{
graphics.beginFill(0xFF0000);
graphics.drawRect(0,0,100,25);
graphics.endFill();

var t:TextField = new TextField();
t.text = str;
t.selectable = false;
t.autoSize = TextFieldAutoSize.LEFT;

addChild(t);

addEventListener(MouseEvent.CLICK, p_onClick);
}
private function p_onClick(event:MouseEvent):void
{
dispatchEvent(new MouseEvent(MouseEvent.CLICK));
}
}
}
what am i doing wrong? i thought this is how i did other events. why is the error happening.. i don't get it

External COM Event Listener
ok heres the deal i want to know if this is possible.

using CE.NET for pocket pc.. which only supports flash player 6.. can you build a COM event listener that waits for an action from the server. then envokes an action within flash and also sends a result out of flash back to the server.

I have found a few examples of listeners within flash but they are dependent on actions within flash. I need to build a flash movie that sits static until a result is sent by the server.. not a user actively clicking on a button or anything.

can anyone point me to something like this that has been built? and what i need to study up on to make this work..

Thanks,
Kirk

Datagrid And Event-listener
Ive got a DataGrid, and Id like to get the value from one of the cells as soon as it has been changed (its editable).

Problem is, I only know how to get ahold of the row-index, and the column-index, but not the data inside the cell.

Anybody knows?

code:
myDataGridListener = new Object();
myDataGridListener.cellEdit = function(event){
var colIndex = event.columnIndex; // gets columnnr
var rowIndex = event.itemIndex; // gets rownr

var myCellsValue = event.?????? // How do I get the value inside this cell?
}
myDataGrid.addEventListener("cellEdit", myDataGridListener);

[F8] TextInput Event Listener
I’m in Flash 8 and working with the TextInput component.

My question is about setting up an event listener. I would like to fire off a few methods when the user clicks out of the TextInput with there mouse, or by tabbing out of the field.

Does anybody know of a good way to do this?
Is there a way to setup an unfocus event?
Thanks!


PHP Code:



var my_ti:mx.controls.TextInput;
var tiListener:Object = new Object();
tiListener.change = function(evt_obj:Object) {
trace("trigger methods”);
};
my_ti.addEventListener("??field_unfocus??", tiListener);

Event Listener Not Listening
I have a component that dispatches an event like this:
dispatchEvent( new Event( "fooChanged" ) );

In my Application
<mx:Application ... creationComplete="init()">
<mx:Script>
<![CDATA[
private function init() : void {
addEventListener( "fooChanged", handleChange );
}

public function handleChange (event:Event) : void {
....
}
]]>
</mx:Script>

The handleChange function never gets fired. Is there some big important piece I am missing?
Thanks

Event Listener Issues
Howdy,

I'm making a game with multiple characters. You move them by clicking on them, then clicking where you want them to move. Everything works great, except for when one character is traveling, and the user changes his or her mind and clicks somewhere else before the character reaches their destination. For some reason, my code will not remove the old event listener before assigning the new one.


heres the code:


stage.addEventListener(MouseEvent.CLICK, moveStarter);

function moveStarter(e:MouseEvent){
var xx = root.mouseX;
var yy = root.mouseY;

frank = personcontainer.getChildByName(whichCharacter);

///frank is the name of the variable i use tell the program which character is selected. the variable whichCharacter is defined elsewhere.


////in the code below, the hasEventListener command works, returning "true"
only when the character is moving. But the removeEventListener command does nothing.

if (frank.hasEventListener(Event.ENTER_FRAME)){
frank.removeEventListener(Event.EnterFrame, frankmover)
}else{
trace("not currently moving");
}

frank.addEventListener(Event.ENTER_FRAME, frankmover);

function frankmover(e:Event){
////there is code here that moves the character to the point xx, yy then removes the eventListener. It all works fine.

}

}



If anyone has any ideas, please let me know before i get too angry and dropkick my computer.

thanks so much!

-kenny

Generic Event Listener
Using the Loader class, I'm loading a SWF on to the stage. In AS 2.0, I would have a single event listener call a specific function based on the event triggered. In AS 3.0, can I do the same thing. Because I am using the Loader constructor, I only want the one listener to call 3 possible function based on that event.

Seems to makes sense to me. I would use the following:


Code:
screen_mc.addListener(screen_listener);


The screen_listener would be declared as an Object previously.

Event Listener - First Time Ever
Hi, I'm trying to add an event listener. So that when a button is pushed it will skip a AS frame in another MC.

Graphically what it's supposed to be is a plane_mc is flying and when the button is pushed the loop frame gotAndPlay(1); is skipped and the plane looks as if its landing.


Code:
var obj = new Object();

obj.click = function(evt) {

_root.carribean_mc.onRelease = function() {
_root.Plane_mc.Plane_mc2.skip(108);

};
};

_root.carribean_mc.addEventListener("click",obj);
I'm not sure about this. Its my first time trying something like this

Event Listener Question
I have my Main Document Class and it registers an event listener for an instance of another class, we'll call it CommMgr. CommMgr dispatches 2"Event.COMPLETE" events and I want the Main class to process each of those differently, so for example (pseudo-code):

commMgr.listener(event, doSomethingForFirstEvent)
commMgr.listener(event, doSomethingForSecondEvent)

how would I differentiate between which event is being fired (1st or 2nd?) because they are both the same type of event (Event.COMPLETE in this case)? plz advise! thx!

Listener Event Burp
Well, I have this strange problem...I won't ask people to look at my code (unless they think it would help) I'm just wondering if anyone has seen this issue:

http://www.geocities.com/dr_baboom/Pong.swf

after you click the start, all of the key listeners do not kick in until I click the screen again.

Any ideas of what could cause that?

[F8] Is An Event Listener Required?
I am relatively new to Flash8, have no prior programming experience and this is my first plunge. Performance is inconsistant when using the following conditional statement to direct a movie clip instance to the appropriate frame label:

lowerback_mc.onRollOver = function (){
if (speedo_mc.needle_mc._rotation == -45) {
speedo_mc.gotoAndPlay("135d180");
} else if (speedo_mc.needle_mc._rotation == -90) {
speedo_mc.gotoAndPlay("90d180");
}
}

My guess is that an event listener needs to be implemented in order to track the current needle_mc rotation. If so, how? If not, any suggestions?

Parameters With Listener Event
I may just be looking wrong, but I can't find a very good method for passing parameters into a function that is being used for an event...I would like to accomplish this:


PHP Code:




public function loadTilePixelData(PixData:String, TilesWide:int, TilesHigh:int, DataCellWidth:Number, DataCellHeight:Number):void {
    loadedPicture.load(new URLRequest(PixData));
    loadedPicture.addEventListener(Event.COMPLETE, pictureLoadComplete(TilesWide, TilesHigh, DataCellWidth, DataCellHeight));
}







hopefully without having to assign a bunch of random vars to get the data from one function to the next via event.

Any recommendations for this one?

Can I Use An Object As An Event Listener?
I have a mouse (rat_mc) and an elephant (dumbo_mc). The rat_mc is a draggable object and the elephant is sitting on the stage. Can I make it so that when a user drags the rat over the elephant, the elephant does something (jump, run away... etc).

Any ideas? What should the script look like to do that?

I'm a noob obviously.

Thanks!

Can I Use An Object As An Event Listener?
I have a mouse (rat_mc) and an elephant (dumbo_mc). The rat_mc is a draggable object and the elephant is sitting on the stage. Can I make it so that when a user drags the rat over the elephant, the elephant does something (jump, run away... etc).

Any ideas? What should the script look like to do that?

I'm a noob obviously.

Thanks!

Event Listener Mouseclick
Is it possible to pass a variable to the eventListener?

The current As2 code is like this.
aButton.onPress=function(){
changeColor(this);
}

function changeColor(mc:MovieClip){
mc.alphaTo(50,.5,"linear");
}

The AS 3 is using the event listener, but is there a way to pass mc as a variable to the function during the function call??


aButton.addEventListener(MouseEvent.CLICK, changeColor);// anyway to pass the aButton reference to the function call?
function changeColor(event:MouseEvent, mc:MovieClip):void {
mc.alphaTo(50,.5,"linear");
}

Thanks

Felix

Maybe An Event Listener Question AS2
I've looked topics here and didn't find what any. So here's my problem. Hope someone can help. Basically, I have an index page that has navigation like below and an intro animation. I am using attachMovie and mcTween for these.

About
Portfolio
Music
Blog

Problem:
The Intro has its own animation which is in the actual swf(not external)
When the user clicks on the "about" link , I have a function that makes the intro animation do a transition to 0% of the alpha and an external swf is loaded in its place. Now, when the page loads, if the user clicks the navigation before the intro animation starts, the intro animation gets all wonky. I'm trying to find the best approach to this. Should I do a listener or just deactivate the nav until the animation is done. Not sure how to do a listener or deactivate. Any help would be great! Hope that wasn't confusing!

[as2]Event Listener In A Class... HELP
I can't seem to figure out how to use an event listener in an AS2 class. Someone please help me. I feel like a moron. Here's my code, and please excuse if it's completely wrong, I'm not very good at classes yet:


PHP Code:



import flash.filters.BlurFilter;import flash.ui.Mouse.*;import flash.geom.Point.*;class ProximityBlur extends MovieClip{        var targetX:Number;    var targetY:Number;    var distance:Number;        var myStage:MovieClip; //stage        var bf:BlurFilter;        var mLis:Object = new Object();        var targetClip:MovieClip;        function ProximityBlur(myClip:MovieClip, movieHome:MovieClip)    {        targetClip = myClip;        targetX = targetClip._x;        targetY = targetClip._y;                myStage = movieHome;        bf = new BlurFilter(0,0,3);//I've used multiple methods trying to get this to work... thus the reason you see both of the lines below...                myStage.onMouseMove = blurClip(targetClip);                Mouse.addListener(mLis);    }        mLis.onMouseMove = function()//ERROR on this line! "This statement is not permitted in a class definition"    {        distance = Math.sqrt(((targetX - _xmouse)*(targetX - _xmouse)) + ((targetY - _ymouse)*(targetY - _ymouse)))        trace(distance);    }        function blurClip(myMC:MovieClip)    {        distance = Math.sqrt(((targetX - _xmouse)*(targetX - _xmouse)) + ((targetY - _ymouse)*(targetY - _ymouse)))        trace(distance);        if(distance <= 100)        {            bf.blurX = distance/10;            bf.blurY = distance/10;            myMC.filters = [bf];        }    }}




Any help would be very much appreciated. I just don't understand why I can't use a mouse event in an AS2 class. Oh, I forgot to mention that I got this working perfectly just coding it on the timeline, but I want to make it reusable and I can't seem to get how to turn it into a class.

Event Listener Question
If i have something like this where an object has an event listener on it, but then you removeChild the object and set it to null, does the event listener still exist?

randomObject.addEventListener(MouseEvent.CLICK, reaction);
removeChild(randomObject);
randomObject = null;

//does randomObject's event listener still exist?

Event Listener Problem
Hi-

I have an flv playing through a .swf file, After the flv finishes I would like a static image to appear. I thought this would work:


Code:
hands._visible = false;

listenerObject.complete = function(eventObject:Object):Void {
hands._visible = true;
};
myPlayer.addEventListener("complete", listenerObject);
"hands" being the image, "myPlayer" being the video - But i must be doing something wrong. The video plays, no problem - but the static image never reappears.

thanks in advance

Re-use Event Listener Object?
Hi Everybody,

I have about 10 buttons on my stage.
I don't want to write 10 addEventListener objects, but write just 1 OO-function like:


Code:
thisButtonListener = new Object();
thisButtonListener.click = function() {
// my actions...
}
thisButton.addEventListener ("click", thisButtonListener);
So, actually, I want to re-use this object for all my 10 buttons...
IS this possible? And if so, can anyone show me a code example?

Regards,
Vic

Event Listener Coding...
Hey there,
It's just more to know how you guys are developing.
I mean with the EventDispatcher class it becomes really easy to use only the EventDispatcher way to dialog between instance, instead of eg, if you have a composition in a class and do yourotherobjectinstance.themethod();

So just wondering what is the best way.
Always using EventDispatcher (I can't see drawbacks). If not if you could explain me why...

Cheers...

Multi - Event Listener;
Hi,

Is there any way to add an Event listener which listens to any event that a class dispatches rather than a specific one?

I am trying to work out a generic way of getting events out of one swf into the swf that loaded it. The main swf loads a variety of different swfs, and needs a set way of listening to their events, so I thought I could use a standardised function in each swf that is loaded which catches all events broadcasted by any classes instanciated and which can be subscribed to by a manager class in the main swf.

Delegate/event Listener Help
I'm looking for help resolving a scoping issue whenever I use the onMotionFinished function of a tween. Is there a way to use delegate to increase the scope of the onMotionFinished function to my entire manager class?

Event.ID3 Listener Runs Twice?
I'm trying to get the id3 tags of a song and when i load the sound the id3 triggers twice.Here is the code

Code:

//an mp3 file is send to the function
private function addMusicToPlaylist(file:File):void{
var url:String = file.url;
var mp3URLRequest:URLRequest = new URLRequest(url);
var music:Sound = new Sound();
music.load(mp3URLRequest);
music.addEventListener(Event.ID3,sendID3);
}

private function sendID3(event:Event):void{
trace(event.bubbles);
var title:String = event.target.id3.songName;
var artist:String = event.target.id3.artist;
var url:String = event.target.url;
var album:String = event.target.id3.album;
var xml:XML = <mp3>
<title>{title}</title>
<artist>{artist}</artist>
<url>{url}</url>
<album>{album}</album>
</mp3>
parentDocument.parentDocument._xmlData.appendChild(xml);
//trace(parentDocument.parentDocument._xmlData);

Copyright © 2005-08 www.BigResource.com, All rights reserved