currentTarget is undefined

HI I am trying to play a game, and when you click with the mouse on a given target, it's supposed to assign the currentTarget corresponding to a number that represents the clip you clicked, but it does not work, the number appears as "NaN" not a number. Anyone know what I'm doing wrong? Thanks, here's the function that I have a problem with:

public void clickBeast(event:MouseEvent) {}

/ / avoid the mouse clicks while showing the sequence

if (gameMode! = "replay") return;

var thisBeast:String;

var value1:Number = repeatOrder.shift ();

if(value1 == 0) {}

thisBeast = "Cat1";

{ } ElseIf ((value1 == 1) |) (value1 == 2) | (value1 == 3) | (value1 is 4)) {

thisBeast = "Dog1";

{ } ElseIf ((value1 == 5) |) (value1 == 6) | (value1 is 7)) {

thisBeast = "Cat2";

{ } ElseIf ((value1 == 8) |) (value1 is 9)) {

thisBeast = '2 ';

{ } else if(value1 == 10) {}

thisBeast = 'Cat3 ';

}

trace (thisBeast);

var thisBeast2:String;

var value2:Number = event.currentTarget.beastNum;

if(value2 == 0) {}

thisBeast2 = "Cat1";

{ } ElseIf ((value2 == 1) |) (value2 == 2) | (value2 == 3) | (value2 is 4)) {

thisBeast2 = "Dog1";

{ } ElseIf ((value2 == 5) |) (value2 == 6) | (value2 is 7)) {

thisBeast2 = "Cat2";

{ } ElseIf ((value2 == 8) |) (value2 is 9)) {

thisBeast2 = '2 ';

{ } else if(value2 == 10) {}

thisBeast2 = 'Cat3 ';

}

trace (value2);

trace (thisBeast2);

/ / OK game

if (thisBeast2 == thisBeast) {}

beastOn (event.currentTarget.beastNum);

/ / checks if the sequence is completed

if (repeatOrder.length == 0) {}

nextTurn();

}

/ / got it wrong

} else {

textMessage.text = "game on!"

gameMode = "gameover";

}

}

You cannot process an interactive object as a number, and I don't see where the code you have tried that.  If you talk about the property beastNum that you are trying to use, it could be a case of how you define / set this value.  You need to explain this.

For the first lines in that function set...

trace (Event.currentTarget);

trace (Event.currentTarget.beastNum);

For the first line, it must copy the object that was involved in the event.  What is produced by the second line?

Tags: Adobe Animate

Similar Questions

  • I have an access of undefined property _root. and access to property may be undefined

    I have 2 errors with my script (below) it is assumed to be Actionscript 3.0.

    I'm getting a

    1120: access of undefined property _root.

    and has...

    1119: access of property may be undefined onRelease through a reference with static type flash.display:SimpleButton.

    Here is my code...

    var frameNum:Number

    function photoChange() {}

    _root.photos.gotoAndStop ("img" + frameNum);

    }

    {btn1.onRelease = Function ()}

    frameNum = 1

    photoChange();

    }

    {btn2.onRelease = Function ()}

    frameNum = 2

    photoChange();

    }

    {btn3.onRelease = Function ()}

    frameNum = 3

    photoChange();

    }

    {btn4.onRelease = Function ()}

    frameNum = 4

    photoChange();

    }

    {btn5.onRelease = Function ()}

    frameNum = 5

    photoChange();

    }

    {btn6.onRelease = Function ()}

    frameNum = 6

    photoChange();

    }

    {btn7.onRelease = Function ()}

    frameNum = 7

    photoChange();

    }

    {btn8.onRelease = Function ()}

    frameNum = 8

    photoChange();

    }

    {btn9.onRelease = Function ()}

    frameNum = 9

    photoChange();

    }

    {btn10.onRelease = Function ()}

    frameNum = 10

    photoChange();

    }

    {btn11.onRelease = Function ()}

    frameNum = 11

    photoChange();

    }

    {btn12.onRelease = Function ()}

    frameNum = 12

    photoChange();

    }

    Could someone help me please!

    _root and onRelease are not AS3, AS2 code to which they belong.  Basically, all of the code that you show treat like AS2, but will have made a mistake if you have your publication set for AS3 settings.  To implement it in AS3 code, you must follow the changes indicated below for all of the code...

    var frameNum:Number;

    function photoChange(evt:MouseEvent) {}

    frameNum = Number (String (evt.currentTarget.name) .substr (3))
    photos.gotoAndStop ("img" + String (frameNum));

    }

    Btn1.addEventListener (MouseEvent.CLICK, photoChange);

    .

    etc.

    .
    btn12.addEventListener (MouseEvent.CLICK, photoChange);

    Assuming you are using the button symbols, the function by using string manipulations to get the chassis number of the button name.  If you use MovieClips as buttons you can assign each number as a property and get this quite the contrary.  Buttons do not support the dynamic properties as do MovieClips.

    The reference to _root in AS3 is simply 'root' but which has usually need a qualifier, as in MovieClip (root).  In many cases using a root reference is not necessary.  If your code is on the main timeline, then there is no need to use references from the root because it is essentially where you are already.  If this code is inside another object on the timeline, then using... MovieClip (root). photos.gotoAndStop... etc would be a solution.

  • 1120: access of undefined property removeEnemy1.

    Hello

    im making a game in flash cs3 and I have done for a small problem. I get this error 1120: access of undefined property removeEnemy1.

    I know what it means just don't know how to fix it.here is the code

    package com.asgamer.basics1 
    {
              import flash.display.MovieClip;
              import flash.display.Stage;
              import flash.events.Event;
      
              public class Engine extends MovieClip
              {
      
                        private var numStars:int = 80;
                        public static var enemyList:Array = new Array();
                        public static var enemy1List:Array = new Array();
                        private var ourShip:Ship;
      
                        private var scoreHUD:ScoreHUD;
      
                        public function Engine() : void
                        {
                                  ourShip = new Ship(stage);
                                  ourShip.x = stage.stageWidth / 2;
                                  ourShip.y = stage.stageHeight / 2;
                                  ourShip.addEventListener("hit", shipHit, false, 0, true);
                                  stage.addChild(ourShip);
      
      
                                  scoreHUD = new ScoreHUD(stage);
                                  stage.addChild(scoreHUD);
      
                                  for (var i:int = 0; i < numStars; i++)
                                  {
                                            stage.addChildAt(new Star(stage), stage.getChildIndex(ourShip));
                                  }
      
                                  addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
      
                        }
      
                        private function loop(e:Event) : void
                        {
                                  if (Math.floor(Math.random() * 90) == 5)
                                  {
                                            var enemy:Stinger = new Stinger(stage, ourShip);
      
                                            enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
                                            enemy.addEventListener("killed", enemyKilled, false, 0, true);
                                            enemyList.push(enemy);
                                            stage.addChild(enemy);
      
                                            var enemy1:bomber = new bomber(stage, ourShip);
      
                                            enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy1, false, 0, true);//here is where i get the error 
                                            enemy.addEventListener("killed", enemy1Killed, false, 0, true);// and here
                                            enemyList.push(enemy1);
                                            stage.addChild(enemy1);
                                  } 
                        }
      
                        private function enemyKilled(e:Event)
                        {
                                  scoreHUD.updateKills(1);
                                  scoreHUD.updateScore(e.currentTarget.points); 
                        }
      
                        private function removeEnemy(e:Event)
                        {
                                  enemyList.splice(enemyList.indexOf(e.currentTarget), 1);
                        }
      
                        private function shipHit(e:Event)
                        {
                                  scoreHUD.updateHits(-1);
                        }
      
      
              }
      
    }
    
    

    What am I, I'm trying to do is to spawn 2 different enemys by using stage.pls

    use:

    package com.asgamer.basics1
    {
              import flash.display.MovieClip;
              import flash.display.Stage;
              import flash.events.Event;
    
              public class Engine extends MovieClip
              {
    
                        private var numStars:int = 80;
                        public static var enemyList:Array = new Array();
                        public static var enemy1List:Array = new Array();
                        private var ourShip:Ship;
    
                        private var scoreHUD:ScoreHUD;
    
                        public function Engine() : void
                        {
                                  ourShip = new Ship(stage);
                                  ourShip.x = stage.stageWidth / 2;
                                  ourShip.y = stage.stageHeight / 2;
                                  ourShip.addEventListener("hit", shipHit, false, 0, true);
                                  stage.addChild(ourShip);
    
                                  scoreHUD = new ScoreHUD(stage);
                                  stage.addChild(scoreHUD);
    
                                  for (var i:int = 0; i < numStars; i++)
                                  {
                                            stage.addChildAt(new Star(stage), stage.getChildIndex(ourShip));
                                  }
    
                                  addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
    
                        }
    
                        private function loop(e:Event) : void
                        {
                                  if (Math.floor(Math.random() * 90) == 5)
                                  {
                                            var enemy:Stinger = new Stinger(stage, ourShip);
    
                                            enemy.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);
                                            enemy.addEventListener("killed", enemyKilled, false, 0, true);
                                            enemyList.push(enemy);
                                            stage.addChild(enemy);
    
                                            var enemy1:bomber = new bomber(stage, ourShip);
    
                                            enemy1.addEventListener(Event.REMOVED_FROM_STAGE, removeEnemy, false, 0, true);//here is where i get the error
                                            enemy1.addEventListener("killed", enemy1Killed, false, 0, true);// and here
                                            enemyList.push(enemy1);
                                            stage.addChild(enemy1);
                                  }
                        }
    
                        private function enemyKilled(e:Event)
                        {
                                  scoreHUD.updateKills(1);
                                  scoreHUD.updateScore(e.currentTarget.points);
                        }
    
                        private function removeEnemy(e:Event)
                        {
                                  enemyList.splice(enemyList.indexOf(e.currentTarget), 1);
                        }
    
                        private function shipHit(e:Event)
                        {
                                  scoreHUD.updateHits(-1);
                        }
    
              }
    
    }
    
    
    

    What am I, I'm trying to do is to spawn 2 different enemys by using stage.pls

  • Undefined function!

    Hi all!
    First of all, I'll give you the code I'm having the problem on:

    import flash.events.MouseEvent; stop() start_btn.addEventListener(MouseEvent.CLICK, startclicked); function startclicked(e:MouseEvent):void {     gotoAndStop(10) } object1.addEventListener(MouseEvent.MOUSE_OVER, overobject1) object2.addEventListener(MouseEvent.MOUSE_OVER, overobject2) object3.addEventListener(MouseEvent.MOUSE_OVER, overobject3) function overobject1(e:MouseEvent):void {     moveobject1(); } function overobject2(e:MouseEvent):void {     moveobject2(); } function overobject3(e:MouseEvent):void {     moveobject3(); } this.stage.addEventListener(Event.ENTER_FRAME, moveMyObjects); function moveMyObjects(event:Event):void {     function moveobject1() {     object1.x -= (object1.x - mouseX) / 3;     object1.y -= (object1.y - mouseY) / 3;     }     function moveobject2() {     object2.x -= (object2.x - mouseX) / 3;     object2.y -= (object2.y - mouseY) / 3;     }     function moveobject3() {     object3.x -= (object3.x - mouseX) / 3;     object3.y -= (object3.y - mouseY) / 3;     } }

    The idea is so when I move my mouse over one of these objects, they begin to follow the pointer.
    I get these errors below:

    Scene 1, Layer 'Actions', frame 1, line 14 1180: call to a method may be undefined moveobject1.
    Scene 1, Layer 'Actions', image1, line 17 1180: call to a method may be undefined moveobject2.
    Scene 1, Layer 'Actions', image1, line 20 1180: call to a method may be undefined moveobject3.

    Have not, I defined the methods based on the moveMyObjects?
    Can someone help me to realize the idea of this way (with the corrected code) or another way (perhaps using a table )
    Thanks in advance.

    MovieClips, buttons, any... try this and tell me what he does want to make...

    Object1.addEventListener (MouseEvent.MOUSE_OVER, overobject)
    object2.addEventListener (MouseEvent.MOUSE_OVER, overobject)
    Object3.addEventListener (MouseEvent.MOUSE_OVER, overobject)

    function overobject(e:MouseEvent):void {}
    e.currentTarget.addEventListener (Event.ENTER_FRAME, moveMyObject);
    }

    function moveMyObject(event:Event):void {}
    event.currentTarget.x = (event.currentTarget.x - mouseX) / 3;
    event.currentTarget.y = (event.currentTarget.y - mouseY) / 3;
    }

  • AS of CS4 Error 1120 - access of undefined property.

    I feel like a real noob and need help!

    I'm new to Flash, but were able to dig my way through scripts for action with a little help from old messages of the forum.

    What I've done so far: developed a small map with buttons for navigation for the Web page, all worked fine with every button link to a separate page.

    What I do: I have new content that needs to be added, so I need another button. everything went fine the new button, name, new layer etc.

    I copied the same code for this button to work (just the name chaning) since the other 7 work buttons in the swf file.

    The error I get is 1120: access of undefined property wind. for the last line of code below:

    A button that does not work:

    import flash.events.MouseEvent;

    function gotoWIND(event:MouseEvent):void {}
    var windURL = new URLRequest ("http://www.hydro.com.au/node/462");
    navigateToURL (windURL, "_self");
    }

    wind.addEventListener (MouseEvent.CLICK, gotoWIND);

    Button (s) that works:

    import flash.events.MouseEvent;

    function gotoKING(event:MouseEvent):void
    {
    var kingURL:URLRequest = new URLRequest ("http://www.hydro.com.au/node/405/");
    navigateToURL (kingURL, "_self");
    }

    king.addEventListener (MouseEvent.CLICK, gotoKING);

    I did some research and found that this means that I have not named the right of the button, but I double and triple checked, redone with a simpler Word (wind) but still no joy. And the only other response, that I could find on this forum was about several images - but as it is a 'static' navigation panel there is only one image for each layer.

    Help, please!

    in the frame that contains your code, use the following syntax, click on wind and copy and paste your text from exit sign.

    import flash.events.MouseEvent;

    trace (Wind);

    function gotoWIND(event:MouseEvent):void {}

    trace("**",Event.currentTarget.Name);
    var windURL = new URLRequest ("http://www.hydro.com.au/node/462");
    navigateToURL (windURL, "_self");
    }

    wind.addEventListener (MouseEvent.CLICK, gotoWIND);

  • problem of concatenation currentTarget

    I'm just curious as to why certain a concatenation works in a trace statement but not when I use it to do something. Here's what I mean:

    private void onClick(e:MouseEvent):void
    {
    var target = e.currentTarget;
    trace (target + "On"); This trace displays correctly, the name of the added at the end with on button
    target + 'On'.alpha = 1; This example gets on error in Flex

    }

    Someone knows why "trace (target +"On"); ' returns 'buttonNameOn' but I can't actually access it. What should I do to make this work?

    If you have not set the type of target, then target will be supposed to have the button object where the event occurred.

    as said in the post treated trace only the channels, where the concatenation work.

    in the line target.tostring + "on".alpha you access an undefined object affects property coefficient alpha;

    You cannot add strings to object References and access to other objects.

    If this post meets the brand as such

  • Console developers saying function is "undefined", but the feature works well

    I'm a web developer, and I worked on creating a site ( http://mythicalslab.x10host.com/ ). On the site, I have little javascript that handles display a div with a top loading animation. In the html script tags, I have two defined function, hideLoading(), and showLoading() who respectively show and hide the loading animation.

    If I go in the Javascript console in Firefox and type hideLoading() or showLoading(), the console says "undefined", but it still works function.

    If you want to verify this put for yourself, go to my homepage ( http://mythicalslab.x10host.com/ ) and showLoading() to type in the console dev and you will see it will execute the function and display the loading animation, while saying that it is not defined.

    Undefined is on the return value of a function call.
    You will see something useful that a function returns the value.
    If nothing is returned, so you see not defined.

    • (function () {return ("OK")}) ()
    • (function () {}) ()
  • Error after installing FF34 on FF33: XML Parsing Error: undefined entity WebIDE

    Hello
    After installing FF34 on FF33 I get a window with this message when I close windows firefox closes too:

    XML parsing error: undefined entity
    Location: chrome://browser/content/browser.xul
    Line number 320, column 5: key < = "" command = "tools: WebIDE ' id = 'key_webide' keycode =" & amp; webide.keycode; "p =" ">."
    < / key >

    ^

    What Firefox locale (UI language) do you use?

    Start Firefox in Safe Mode to check if one of the extensions (Firefox/tools > Modules > Extensions) or if hardware acceleration is the cause of the problem.

    • Put yourself in the DEFAULT theme: Firefox/tools > Modules > appearance
    • Do NOT click on the reset button on the startup window Mode safe
  • Cannot add a new account to FireFTP. Get &gt; &gt; &gt; XML Parsing Error: undefined entity location: chrome://fireftp/content/accountManager.xul line number 216, column 17:

    I can't add an additional account to FireFTP. I get a yellow box with this title:

    XML parsing error: undefined entity
    Location: chrome://fireftp/content/accountManager.xul
    216, column 17 line number:
    < label of the menu = "" & charsetMenuMore1.label; "accesskey =" & charsetMenuMore1.accesskey; "datasources ="rdf:charset - menu"ref ="NC:BrowserMore1CharsetMenuRoot">

    ^

    Do not understand the problem, can anyone help please?

    Try the FireFTP update to the 2.0.20 latest version.
    An update for Firefox 32 compatibility.
    https://addons.Mozilla.org/en-us/Firefox/addon/FireFTP/

  • XMLHttpRequest is undefined

    I write an add-on bootstrap for Thunderbird on Ubuntu 13.10 computer 24.3.0.

    When you try to run the following snippet (taken for Mozilla Developer Network)

        var req = new XMLHttpRequest();
        req.open('GET', 'http://www.mozilla.org/', false);
        req.send(null);
        if(req.status == 200)
            dump(req.responseText);
    

    I get "ReferenceError: XMLHttpRequest is undefined ' error console when you try to create the object.

    This problem is very similar to Firefox:

    https://support.Mozilla.org/en-us/questions/987100

    Hmm, would it be a change in the SDK?

    It might be useful to check on this forum: http://forums.addons.mozilla.org/

  • Since the update message "XML Parsing Error: undefined entity location: chrome://browser/content/browser.xul 238, column 5 line number:" all - tried help!

    Since an automatic update ran I get the message

    "XML Parsing Error: undefined entity".

    Location: chrome://browser/content/browser.xul

    Number of the line 238, column 5:

    "< broadcaster-^" < br = "" id = "devtoolsMenuBroadcaster_ChromeDebugger" >
    When I try to open Firefox. I had to go back to Internet Explorer - tried all suggested include removing and then reinstalling Firefox, but still not get Firefox to open - help!
    < / diffuser >

    Can you reproduce in Firefox Safe mode?

    It may be an acceleration addon or material affecting (by making the error).

  • How to remove the extension add-on "undefined"?

    I have an add-on called 'indefinite' who has 5 buttons: enable, disable, Options, delete, ask to activate. I want to remove, so I clicked on the button Delete, then he said "Nation Toolbar has been removed"... but after I go back to my list of Extensions, it's still there... I already tried to remove in safe mode, what has not worked... It seems that this situation has begun to uninstall the toolbar annoying Nation who hijacked my browsers... Please help me solve this problem...
    In addition, please do not suggest to reset firefox...
    BTW, the 'indefinite' extension does not appear in the troubleshooting information...

    I fixed it! I was wrong to do not find anything in the profiles... I found a folder inside the extensions which is called as {ADFA33FD-16F5-4355-8504-DF4D664CFE09}... and found that it is what is causing the extension "undefined"... Then I deleted it, and solves the problem... Thank you all for your support!

  • 22 Firefox displays an undefined repeatedly. Also freezes at startup

    Since Firefox updated to 22, I asked problems with Firefox. It worked completely fine until now.
    There are two issues I have here.
    1 Firefox crashes when I open it. Has a small chance to hang does not sometimes, but the browser would be too slow to use.
    2. this problem happens when I go to any site. When I load a page, the undefined Word is shown repeatedly through the entire page.

    I tried to disable the following addons, but two problems:
    Internet Download Manager, Stylish, NoScript, dictionary, quick search

    I get crashes when you open the browser, so it is difficult to test the other addons. What is strange, is that these addons work very well on the desktop of my brother.
    My other addons not tested: Speedfox, WOT, Adblock, FVD fast dial, quicknote

    I'm running out of ideas to fix. There are other methods for fixing of my browser? I am able to get a list of diagnostic of my browser, I can post here for assistance?

    Are you aware that Firefox 22 is in beta test and that he will not be released for nearly 5 weeks?

    21 of Firefox is the current version.

    The reset Firefox feature can solve a lot of problems in restaurant Firefox to its factory default condition while saving your vital information.
    Note: This will make you lose all the Extensions, open Web sites and preferences.

    To reset Firefox, perform the following steps:

    1. Go to Firefox > help > troubleshooting information.
    2. Click on the button 'Reset Firefox'.
    3. Firefox will close and reset. After Firefox is finished, it will display a window with the imported information. Click Finish.
    4. Firefox opens with all the default settings applied.

    Information can be found in the article Firefox Refresh - reset the settings and Add-ons .

    This solve your problems? Please report to us!

    Thank you.

  • v19 gives an entire page of "undefined" now using v12 but relevant to security

    v19 gives continuous text pageof "undefined" - have revertd to v12 but worried about security issues

    Please update Firefox 19.0.2 Firefox updated to the latest version

    Then reset Firefox Firefox Refresh - reset the parameters and modules

  • Each link says "undefined". IE works fine.

    All links on the page that the text "undefined". The links work...

    You have the Foxreplace extension?

    Start Firefox in Safe Mode to check if one of the extensions or if hardware acceleration is the cause of the problem (switch to the DEFAULT theme: Firefox/tools > Modules > appearance/themes).

    See these discussions on the TEXT:

Maybe you are looking for

  • Gmail and all the others crash in "Oops!" Google cannot load this page for some reason any

    I am running 10.10.5 and Firefox 41.0.2. Sophos said me no problem. In case of Gmail or any other program running in Firefox, the program stops to the message of the screen;"Oops!" "Google can not load this page for some reason any." The box Try Agai

  • Pavilion 15 AB205TU: WIFI pilot missing 15 HP-Pavilion ab205tu

    I bought the HP Pavilion Notebook 15-ab205TU July 22 2016.when I tried to connect to the wireless (WIFI) network he did not to any connection and asked to connect to the internet using LAN? I opened the Device Manager and discovered that there is no

  • What happened to the second button "Open new tab" in 4.0?

    In firefox 3.x, there is a button next to the last tab, an additional tab navigation. Now, there is only a 'new tab' button. Can I get it back to have both?

  • icon library license

    Hi all I would like to use an icon from the icon of National Instruments library in my own non-LabVIEW program. The question is what, exactly, are the terms of the license for these images? There is no license included with the downloadable game and

  • Client VPN router 1841 will not establish tunnel

    We have a 1841 with IOS 12.4 (3) we have been unable to establish a tunnel to using the 4.8.01.0300 version. It will not exchange keys ISAKMP whatever we use parameters. Debugging is a variety of errors including poorly matched to encryption, authent