Event listener does not not in a class

Hello!

I have a problem, I have 2 files, one that is the main .fla, which is called game.fla and another file named PacMan.as.

I just started with as3 and would like to know why I can´t create a KeyboardEvent on the .as file.

I created a movieclip which would be the player and linked to the. as. I checked and it works when I use the trace command in the .as file.


But when I add a function and an eventListener trace command dosen´t work...

Here's what I have:

*. As leader (PacMan.as):

PacMan class
package gamecontent.classes
{
import flash.display.MovieClip;
import flash.ui.Keyboard;
import flash.events. *;

PacMan/public class extends MovieClip
{

public void PacMan()
{
var newPacMan:PacMan = new PacMan;
newPacMan.addEventListener (KeyboardEvent.KEY_DOWN, testFunction);

trace ("class expenses");
}
function testFunction(e:KeyboardEvent):void
{
trace ("key...");
}
}


}

*.fla (game.fla) file, I just "spawn" the reader of the library:

Player: PacMan var = new PacMan();


addChild (player);

Position of objects...
Player.x = 39;
Player.y = 559;

Any help is much appreciated...

Hello

try to add the listener to the stage instead:

stage.addEventListener (KeyboardEvent.KEY_DOWN, testFunction);

This will pick up all keyboard events - if you add a keyboard listener to a specific object, the event only fires if this object has focus

Tags: Adobe Animate

Similar Questions

  • Keyboard event listener does not work in the browser

    Is there a reason why a keyboard event listener would not work if the flash is embedded in an HTML element? The rest of my game runs well in the background, but I can't launch the movieClip "nextCar." My code is below, if that makes a difference...

    goNow function (event: KeyboardEvent): void {}
    thisOtherKey = event.keyCode;
    If (thisOtherKey == 32) {}
    nextCar.gotoAndPlay (2);
    parkingQue.play ();
    tent ++;
    }
    }
    stage.addEventListener (KeyboardEvent.KEY_DOWN, goNow);

    This is perhaps a silly question, but have you tried to click on your swf file once it opens in the browser and then try the keyboard controls?

    I don't know any problems that may cause debugging workwhen event listeners, but not in a browser.  So I think that maybe your just not well centered on the swf.

  • Tween event listener does not

    Hello

    In a frame script, I have an event listener that must call "onFinish" function when the motion tween is completed. (See the relevant parts in red below). I never see this output "done the interpolation. It fails silently. I tried the addEventListener method in different places... nothing helps. What Miss me?

    Thank you!

    Fl.transitions import. *;
    Fl.transitions.easing import. *;
    Import fl.transitions.Tween;
    Import fl.transitions.TweenEvent;

    var currentFrameMC = animImg;

    var scaleXTween:Tween = new Tween (animImg, "scaleX", Bounce.easeOut, 1,2,2.4, true);
    var scaleYTween:Tween = new Tween (Bounce.easeOut, 1,2,2.4, animImg, "scaleY", true);
    var alphaTween:Tween = new Tween (animImg, "alpha", Strong.easeOut,.5, 1, 11, true);

    Put a listener on the MC I can't tell when it's interpolation of the scale.
    currentFrameMC.addEventListener (TweenEvent.MOTION_FINISH, onFinish);

    This is another event listner put a button:
    (The button, when clicked, will raise the narrowing of the MC animImg)
    reverseTween1.addEventListener (MouseEvent.CLICK, shrinkFrameMC);

    Retractable / scale down the anImg by interpolation
    This shrinkFrameMC(e:MouseEvent) function evolves down playback video clip
    {
    scaleXTween = new Tween (currentFrameMC, "scaleX", None.easeNone, currentFrameMC.scaleX, 1, 3, true);
    scaleYTween = new Tween (currentFrameMC, "scaleY", None.easeNone, currentFrameMC.scaleY, 1, 3, true ");
    Interpolation of the alpha of the clip again, this time to reverse state
    alphaTween = new Tween (Strong.easeOut, 1,.5, 11, currentFrameMC, "alpha", true);
    }


    onFinish(e:TweenEvent):void //This function performs an action when the MC frame interpolation
    {
    trace ("tween completed");
    NEVER SEE THIS OUTPUT
    }

    You set the event listener Tween interpolation, not of the object being interpolated.

  • LoaderInfo event listener does not

    Hello

    I'm that requires little things like;

    1 swf should play if the customer open it to its end (it will be detected by the verification of a text file that contains the variable on the local disk say 'C')

    2 swf should preload is flashvars from HTML file on the server by user

    3. If both the conditions of work dosent then swf above should not play

    I got some what in the present. If I run the file without preloader it works fine. but when I add the preloader for it something goes wrong.

    Please check the code;

    import flash.text.TextField;

    to import flash.events.ProgressEvent;

    import flash.events.Event;

    import flash.display.MovieClip;

    var Progress_txt:TextField = new TextField();

    var myFlashVar:String;

    var myVar:String;

    var paramObj:Object = LoaderInfo (this.root.loaderInfo) .parameters;

    for (myVar in paramObj)

    {

    myFlashVar = String (paramObj [myVar]);

    }

    checkFlashvar();

    function checkFlashvar (): void

    {

    trace ("CHECKING Flash VAR");

    If (myFlashVar is "varInHTML")

    {

    InternalPreloader();

    trace ("pass found var");

    }

    on the other

    {

    trace ("VAR NOT FOUND");

    gotoLocalVar();

    }

    }

    function gotoLocalVar (): void

    {

    var myLoader:URLLoader = new URLLoader();

    myLoader.dataFormat = pouvez;

    myLoader.addEventListener (Event.COMPLETE, chkLocalVar);

    myLoader.addEventListener (IOErrorEvent.IO_ERROR, onLoadError);

    myLoader.load (new URLRequest("C:/key.txt"));)

    function chkLocalVar(event:Event):void

    {

    If (myLoader.data.passKey is "grantAccess")

    {

    trace ("pass key found");

    InternalPreloader();

    }

    on the other

    {

    trace ("Local VAR NOT FOUND");

    Stop();

    parent.removeChild (this);

    }

    }

    }

    function onLoadError(evt:IOErrorEvent):void

    {

    trace ("TXT FILE NOT FOUND");

    Stop();

    parent.removeChild (this);

    }

    function InternalPreloader (): void

    {

    Stop();

    Progress_txt.x = stage.stageWidth / 2;

    Progress_txt.y = stage.stageHeight 2;

    addChild (Progress_txt);

    trace ("load progress event");

    loaderInfo.addEventListener (ProgressEvent.PROGRESS, onProgress);

    loaderInfo.addEventListener (Event.COMPLETE, onComplete);

    }

    function onProgress(p:ProgressEvent):void

    {

    Progress_txt. Text = String(Math.floor((p.bytesLoaded/p.bytesTotal)*100));

    trace ("verification of progress");

    }

    function onComplete(d:Event):void

    {

    trace ("loaded, start my movie.");

    Play();

    loaderInfo.removeEventListener (ProgressEvent.PROGRESS, onProgress);

    loaderInfo.removeEventListener (Event.COMPLETE, onComplete);

    }

    I'm not getting where I do the wrong thing...

    your swf file has already completed loading when you start listening so that it loads then progress events and load are not dispatached.

    to remedy this, add an if statement to check if all the bytes or managers are responsible.

  • ORA-12505, TNS: Listener does not currently of SID in the connection descriptor (code: 2 011)

    I get this error when you try to create a data store for Oracle database of the Disqualification.

    ORA-12505, TNS: Listener does not currently of SID in the connection descriptor (code: 2 011)

    I am able to connect to this database by using the same credentials through SQL, but the Disqualification, I'm not. Do I need to do anything in linux server before the implementation of Oracle data warehouses?

    Thank you

    Ravi

    There are a number of ways.

    1 use a JNDI connection configured in WebLogic and select by name

    2. use the LDAP connection or TNS - see http://docs.oracle.com/middleware/1213/edq/DQEXT/config_dbase.htm#DQEXT202

    3. Add an oracle.xml file in [local disqualification home] / dbconnectors with the following content. This will allow you to select the service name in the standard Oracle data store wizard:

    Class = "com.datanomic.utils.databasespecies.species.Oracle"

    MaxNameLength = "30" invalidnamechars ="" ' >

    {JDBC:Oracle:Thin:@${service = "srv"? /': "} ${host}: ${port} {service ="srv"? '/' : ':'}${sid}

    Oracle

    {JDBC:Oracle:Thin:@${service = "srv"? /': "} ${host}: ${port} {service ="srv"? '/' : ':'}${sid}

    ${superior (schema = "? user: schema)}

    dbproductname ~ = '(?i) oracle'

    name ~ = ' $BIN\\ [A-Za-z0-9 + /] {22, 24} ==------$\\p {digit} +'

    user = ${user}

    password = ${password}

    FetchSize = 100

    BatchSize = ${export.batchsize}

    void = TRUNCATE TABLE %s

    ALTER SESSION SET CURRENT_SCHEMA = ${schema}

    1521

  • SoundChannel event.sound_complete does not? Help?

    Hello

    For some reason, my soundchannel event.sound_complete does not work. In fact, my class is to import its in and to allow the use to change their volumes and sound technology.

    This is the tutorial for speed

    http://blog.Andre-Michelle.com/2009/pitch-MP3/

    Right now, what I want to do is to auto loop back the song once the song ended the game, but I saw troubled do. No matter which, can help me?

    The code will pass by the SoundForward() function

    Inside, it will trigger _mp3.addEventListener (Event.COMPLETE, complete);

    and the activity function Rollback() will.

    Inside, it will trigger a _soundChannel.addEventListener (Event.SOUND_COMPLETE, loopMusic);

    but then the function fires once the song ended he played.

    Benson

    Thank you

    ------------------------------------------------------------------------------------------ -----

    {package examples

    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.SampleDataEvent;
    import flash.media.Sound;
    import flash.media.SoundChannel;
    import flash.net.URLRequest;
    import flash.utils.ByteArray;

    SerializableAttribute public class SoundForward extends Sprite
    {
    private const blockSize:int = 3072;

    private var _mp3:Sound;
    private var _sound:Sound;
    private var _soundChannel:SoundChannel;

    private var _target:ByteArray;
    private var _position:Number;
    private var _rate:Number;
    private var _stop:Boolean;


    private var _pausePoint:Number;

    public void SoundForward (url: String, stop: Boolean)
    {
    _target = new ByteArray();

    _mp3 = new Sound();
    _mp3.addEventListener (Event.COMPLETE, complete);
    _mp3. Load (new URLRequest (url));

    _stop = stop;

    _pausePoint = 0;
    _position = 0.0;
    _rate = 1.0;

    _sound = new Sound();
    _sound.addEventListener (SampleDataEvent.SAMPLE_DATA, sampleData);

    _soundChannel = new SoundChannel();

    }

    private void complete(event:Event):void
    {
    _soundChannel = _sound.play ();
    _soundChannel.addEventListener (Event.SOUND_COMPLETE, loopMusic);
    }

    private void sampleData(event:SampleDataEvent):void
    {
    Reuse instead of leisure
    _target.position = 0;

    Shortcut
    var data: ByteArray = event.data;
    var scaledBlockSize:Number = blockSize * _rate;
    var positionInt:int = _position;
    var alpha: Number = _position - positionInt;

    var positionTargetNum:Number = alpha;
    var positionTargetInt:int = - 1;

    need var: int = Math.ceil (scaledBlockSize) + 2;
    var read: int = _mp3.extract (_target, need, positionInt);

    var n: int = read is need? blockSize: read / _rate;

    var l0:Number;
    var r0:Number;
    var l1:Number;
    var r1:Number;

    for (var i: int = 0; i < n; ++ i)
    {
    If (int (positionTargetNum)! = positionTargetInt)
    {
    positionTargetInt = positionTargetNum;

    Reading objective FIXED position
    _target.position = positionTargetInt < < 3.

    Read Stero two samples for linear INTERPOLATION
    L0 = _target.readFloat ();
    R0 = _target.readFloat ();

    L1 = _target.readFloat ();
    R1 = _target.readFloat ();
    }

    Write amplitudes interpolated streaming
    data.writeFloat (l0 + alpha * (l1 - l0));
    data.writeFloat (r0 + alpha * (r1 - r0));

    Increase the position of the target
    positionTargetNum += _rate;

    FRACTION OF THE INCREASE AND THE CLAMP BETWEEN 0 AND 1
    += Alpha _rate;
    While (alpha > = 1.0)-alpha;
    }

    -FILL the REST OF THE flow of DATA WITH zeros
    If (I < blockSize)
    {
    While (I < blockSize)
    {
    data.writeFloat (0,0);
    data.writeFloat (0,0);

    ++ i ;
    }
    }

    -INCREASE SOUND POST
    _position += scaledBlockSize;
    }

    private void loopMusic(e:Event):void
    {
    trace ("AB");
    }

    }
    }

    Use the code that I have suggested.  You should have only one sound (_mp3) instance in your code.

  • &amp; quot; The class being compiled does not match the class that was imported &amp; quot;

    -Actions on the timeline in sixSpices/updateSite/updateSite.fla---

    com.sixspices.updater.view import. *;
    var calDrawer:CalendarView = new CalendarView(); Listener / view

    file---sixSpices/com/sixspices/Updater/view/CalendarView.as-

    Class CalendarView {}
    public void CalendarView() {}
    }
    public void onRecieveData(listOfEvents:Array) {}
    displayEvents (listOfEvents);
    }
    public void displayEvents(listOfEvents:Array):Void {}
    trace (listOfEvents);
    }
    }

    When I test the movie (updateSite.swf) in flash, it gives me the error:
    The class being compiled, 'CalendarView', does not match the class that was imported, "com.sixspices.updater.view.CalendarView."

    I thought about it (with a little help from more advanced google search). I had to import the package ' import com.sixspices.updater.view. *; ' in the CalendarView file. I thought it would be counterintuitive because it does not use himself - he himself - and the structure of the file should be denoted where it existed. However, once I did the import, it now works without error.

    Moral of the story:

    When using the classes in several files, they should import the package they are contained in, or have their name written as:

    Class com.sixspices.updater.view.CalendarView {}

    Other discussions here

  • FRM-10142 the http listener does not work on the name of the computer to the port 80

    Hello

    During the race, the oracle 12 c form a following error message

    FRM-10142 the http listener does not work on the name of the computer to port 80. Please start the receiver or check your preferences of runtime.

    Sandy

    First, you will need to check the SST is running.

    go to admin server url in your browser, click on the target icon that is left top of your admin home go to the http server and then start your ohs1.

    and open your generator of forms go to the updated runtime default url like e.g. OSH, you can find your url such as http://localhost:7777 or http://localhost:7779.

    your full url looks like this format http://localhost:7777/forms/frmservlet or http://localhost:7779/forms/frmservlet.

    Localhost can be your default ip 127.0.0.1 or any static ip 192.0.0.10 address in this format.

  • frm-10142 http listener does not

    Hi all

    I am unable to run any form of generator of forms, I get the error frm-10142 (http listener does not)

    tried different ports (8888, 9001, 7001)

    When I connect to the console like this:

    http://127.0.0.1:7001 / console

    and click on deployments (11.1.2) formsapp is listed with the new State

    When I click on environment = > servers the following is listed:

    Name State listening Port

    AdminServer (admin) being RUN 7001

    STOP WLS_FORMS 9001

    STOP WLS_REPORTS 9002

    When I connect to the EM with http://127.0.0.1:7001 / em

    and under Farm_ClassicDomain, I open the forms node, and then click Forms

    then, in the form of deployments, it is empty

    the weblogic server is running

    OS: 64-bit windows 7

    forms: 11.1.2.2.0 64-bit

    WLS 10.3.6

    could it be caused by a recent update for java 8? (java version = 1.8.0_60)

    any ideas?

    KR

    Martin

    If you want to start the console servers, nodemanager must be running.

    Go to you $DOMAIN_HOME/bin folder and user batch file to start servers:

    StartManagedWebLogic.bat WLS_FORMS

    You will be asked for weblogic credential.

    Last output message should be something like this: "server started in OPERATION."

    Then you can try to access the forms.

    Concerning

  • Listener does not start

    Hi all

    EBS 11i

    Linux 5.5

    We didn't change anything either, but all of a sudden our listener does not start.

    start at $ /u02/oracle/oaproddb/9.2.0/appsutil/scripts/OAPROD_oel5/addlnctl.sh OAPROD

    You run addlnctl.sh version 115.6

    Logfile: /u02/oracle/oaproddb/9.2.0/appsutil/log/OAPROD_oel5/addlnctl.txt

    From process to listen OAPROD...

    addlnctl.sh: leave with the State 1



    VI addlnctl.txt

    Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

    Connection to (ADDRESS = (PROTOCOL = IPC) (KEY = EXTPROCOAPROD))

    AMT-12541: TNS:no listener

    AMT-12560: TNS:protocol adapter error

    AMT-00511: no listener

    Linux error: 111: connection refused

    Connection to (ADDRESS = (PROTOCOL = TCP)(Host=oel5.unitrade.local) (Port = 1521))

    AMT-12541: TNS:no listener

    AMT-12560: TNS:protocol adapter error

    AMT-00511: no listener

    Linux error: 111: connection refused

    LSNRCTL for Linux: release 9.2.0.6.0 - Production on June 4, 2015 12:10:14

    Copyright (c) 1991, 2002, Oracle Corporation.  All rights reserved.

    From /u02/oracle/oaproddb/9.2.0/bin/tnslsnr: Please wait...

    AMT-12547: TNS: lost contact

    AMT-12560: TNS:protocol adapter error

    AMT-00517: lost contact

    Linux error: 32: Broken pipe

    I tried Googling the error but can't find a similar solution for the error

    listener - Linux error: 111: connection refused LSNRCTL - database to stack Exchange administrators

    Help, please...

    Thank you very much.

    Blog of helios to my best friend helped

    AMT-12547: TNS-12560: TNS-00517: Linux error: 32: error during boot to earpiece | Blog of Helios

  • The onDeactivate event handler does not work in InDesign CC. Why?

    Hi guys.

    I'm working on a script in Javascript for InDesign CC.

    The big problem is that the onDeactivate event handler does not work.

    Here is an example that works in InDesign CSx, but not in InDesign CC:

    #target indesign
    var w = new Window ("dialog", "Test onDeactivate");
    var et_1 = w.add("edittext", [undefined, undefined, 300, 30], "Lorem ipsum");
    var et_2 = w.add("edittext", [undefined, undefined, 300, 30], "Dolor sit amet");
    var st = w.add("statictext", [undefined, undefined, 300, 30], "CONSOLE:\r\r", {multiline: true});
    et_1.onDeactivate = et_2.onDeactivate = function(){
         st.text = "CONSOLE: I left the field with this text:\r\t«" + this.text +"»"; }
    var b_ok = w.add("button", undefined, "OK");
    w.show();
    

    The script displays a dialog with text edit fields window 2: when a field loses focus (by clicking on the other), the "CONSOLE" shows the text of the old domain.

    Adobe, please, solve this problem as soon as possible.

    Thank you.

    Giorgio

    This is a bug, and it has been reported. Please report it to yourself, more the better reports. It's no good Adobe invite you in this forum to fix something.

    Peter

  • ORA - 12514:TNS:listener does not work

    Hi all


    My Version of DB: 10.2.0

    Operating system: Solaris


    I just stop the database and when try to restart Pb it gives me error like:

    ORA - 12514:TNS:listener does not work

    When I check the entry from the file tnsnames.ora DB is in the list

    but when I do

    lsnrctl status

    It will not display no services of db which is orcl

    can someone help me

    Vikas Kohli wrote:

    DB is now

    one more thing to ask

    Please do not put more than one topic or 'thing' in each thread that is start a new separate discussion thread / topic / problem etc.

    When you try to raise the hot backup rman I get below error:

    RMAN topics, please use the dedicated forum: {forum: id = 74}.

  • ORA-12514 TNS: Listener does not currently of service required

    Hi all


    I created a thread here only three days ago on the question above:

    ORA-12514 TNS: Listener does not currently of service required

    and I ended install oracle again this time around just after 2 days I'm getting the same problem again. I have not yet published that any same file not open it not even anywhere near her. Can anyone tell me the reason?

    Thank you and best regards,

    Lucky aka Lastw0nd3r

    Published by: lastw0nd3r on August 5, 2010 07:24

    SQL NET should now work for you.*
    If so, please mark as ANSWER

    but where was I wrong?

    the database is not started so the listener did not know the DB Service

  • ORA-12505 TNS Listener does not currently in SID

    Hello
    When I try to connect to Oracle Sql developer, error "ORA-12505 TNS Listener does not currently of SID given in connect descriptor". ""
    I use 11 GR 1 material on Windows XPSP2 platform. But several sql works very well.
    Thank you

    Published by: user12222356 on April 11, 2010 07:20

    user12222356 wrote:
    This time the Sql developer is connected successfully. But there is not a question of being happy because what happens frequently. Sometimes is connected while sometimes the connection refused... All, it seems, is that SQL Developer connection to the Oracle server depends on luck.
    Is there any solution to get rid of this problem?

    It's a matter of timing.

    First thing that should be launched is the listener. Who should be started on boot. For a laptop or another machine which uses the DHCP protocol, the listener must be configured to talk to the loopback adapter.

    Then the database should be started to talk to listening on the port of sight to the listener - it is applied either with the "LOCAL_LISTENER" database being left to null (for the default listener on 1521). This can be checked by "Lsnrctl status" showing the instance of database such as saved and available.

    Then the SQLDeveloper can start up, pointing to the same host, port, and service/instance, as shown in "lsnrctl status".

  • ERROR - ORA-12514: TNS:listener does not know now of immediate service

    Hi all
    Is the problem that I do face when I access oracle 10g database.it was wrking fine a few days back then I installed the developer 10g suite.after I am facing the problem (ERROR - ORA-12514: TNS:listener does not know currently of service requested in connect descriptor) every time I try and access my database.any 10 g help will be very appreciated.
    Thanks in advance
    Mourad

    Hello

    Make sure that you use right tnsnames.ora as you have it installled oracle developer suite after installation of the database so it could change your ORACLE_HOME as a result of developer. You have 2 choices

    1. replace oracle_home installation of oracle database in the variables env control panel system
    or
    1 copy the tnsnames.ora, listener.ora under Developer suite... location/networ/admin.

    If you are using on your local computer, you do not have this and you should be able to connect but if you use it is not bad either.

    Output from the following command post

    lsnrctl status
    

    Concerning

Maybe you are looking for

  • I need to download only Firefox 18.0

    I am currently using a program on my computer that works properly with Firefox virsion 18 now. The firefox I had on my system updated automatically at 19 and now my program will not work correctly. I uninstalled Firefox, thinking that I could go to y

  • Background blurred after reboot

    Most of the time, after I reboot, my background is the same fuzzy version of my experience that shows the login screen. There is also a dark alpha superimposed on the image channel. When I close a window on a standard desktop computer Finder, the Off

  • New home for lollipop

    For those who want to customize their home, here's a tip from google. https://play.Google.com/store/apps/details?ID=com.Google.Android.Launcher

  • Why the LV stores unchanged files in project?

    Hello I wonder why LV 'stores' files in a project that have not been changed? As a result, my configuration management tool provides these files too, although compare LV shows no difference. It is annoying because a check-in don't really reflect the

  • Error when installing on 2k8R2

    Ive installed BB on a 2k8R2 server and get an error when I click the icon CON the error is "You want to save the file, or find a program online to open. I expect to it to show the history for this. What did I do wrong. CGI is installed in IIS See you