Can Action Script 3, someone place where my code is wrong?

I want to have my controlled characters separately, with "FireBoy" moving with the left until the right keys and "WaterGirl" moving with the a, w and d keys. However to modify my code somehow WaterGirl now moves with the right button instead of the d key. Please, someone can find where I made a mistake and advise me on how to solve the problem.

My code for main.as is:

package

{

Import 12345678910111213import;

import flash.display.Sprite;

import flash.events.Event;

import flash.events.KeyboardEvent;

import flash.events.MouseEvent;

/**

* ...

* @author Harry

*/

SerializableAttribute public class Main extends Sprite

{

private var leftDown:Boolean = false;

private var rightDown:Boolean = false;

private var aDown:Boolean = false;

private var dDown:Boolean = false;

private var FireBoy:Hero = new Hero();

public var StartButton:Go;

public var WaterGirl:Female = new Female();

public var Door1:Firedoor;

public var Door2:Waterdoor;

public var fire: wash;

public var water: Blue;

public var Green: Gem;

public void Main (): void

{

If init() (stage);

of another addEventListener (Event.ADDED_TO_STAGE, init);

}

public void init(e:Event_=_null):void

{

StartButton = new getCurrentCard;

StartButton.x = 100;

StartButton.y = 5;

addChild (StartButton);

StartButton.addEventListener (MouseEvent.CLICK, startgame);

}

private void startgame(e:Event_=_null):void

{

removeEventListener (Event.ADDED_TO_STAGE, init);

entry point

removeChild (StartButton);

FireBoy.y = 495;

addChild (FireBoy);

stage.addEventListener (Event.ENTER_FRAME, HerocheckStuff);

stage.addEventListener (KeyboardEvent.KEY_DOWN, HerokeysDown);

stage.addEventListener (KeyboardEvent.KEY_UP, HerokeysUp);

WaterGirl.x = 70;

WaterGirl.y = 495;

addChild (WaterGirl);

stage.addEventListener (Event.ENTER_FRAME, FemalecheckStuff);

stage.addEventListener (KeyboardEvent.KEY_DOWN, FemalekeysDown);

stage.addEventListener (KeyboardEvent.KEY_UP, FemalekeysUp);

Door1 = new Firedoor();

stage.addChild (Door1);

Door1.x = 5;

Door1.y = 62;

Door2 = new Waterdoor();

stage.addChild (Door2);

Door2.x = 100;

Door2.y = 62;

Fire = new Lava();

stage.addChild (Fire);

Fire.x = 160;

Fire.y = 570;

Water = new Blue();

stage.addChild (Water);

Water.x = 350;

Water.y = 160;

Green = new Gem()

stage.addChild (Green);

Green.x = 500;

Green.y = 100;

graphics.beginFill (0 x 804000, 1);

graphics.drawRect (0, 0, 800, 40);

graphics.endFill ();

graphics.beginFill (0 x 804000, 1);

graphics.drawRect (0, 170, 600, 40);

graphics.endFill ();

graphics.beginFill (0 x 804000, 1);

graphics.moveTo (800, 200);

graphics.lineTo (800, 700);

graphics.lineTo (400, 700);

graphics.lineTo (100, 700);

graphics.endFill ();

graphics.beginFill (0 x 804000, 1);

graphics.drawRect (0, 580, 800, 40);

graphics.endFill ();

}

public void Collision (): void

{

If (WaterGirl.hitTestObject (Fire))

{

WaterGirl.x = 70;

WaterGirl.y = 495;

}

If (FireBoy.hitTestObject (Water))

{

FireBoy.x = 15;

FireBoy.y = 495;

}

}

public void HerocheckStuff(e:Event):void

{

If (leftDown)

FireBoy.x-= 5;

If (rightDown)

FireBoy.x += 5;

FireBoy.adjust ();

Collision();

Check_Border();

}

public void HerokeysDown(e:KeyboardEvent):void

{

If (e.keyCode is 37)

leftDown = true;

If (e.keyCode is 39)

rightDown = true;

If (e.keyCode is 38)

FireBoy.grav = - 15;

Collision();

Check_Border();

}

public void HerokeysUp(e:KeyboardEvent):void

{

If (e.keyCode is 37)

leftDown = false;

If (e.keyCode is 39)

rightDown = false;

}

public void FemalecheckStuff(e:Event):void

{

If (aDown)

WaterGirl.x-= 5;

If (rightDown)

WaterGirl.x += 5;

WaterGirl.adjust2 ();

Collision();

Check_Border();

}

public void FemalekeysDown(e:KeyboardEvent):void

{

If (e.keyCode is 65)

aDown = true;

If (e.keyCode is 68)

dDown = true;

If (e.keyCode is 87)

WaterGirl.grav = - 15;

Collision();

Check_Border();

}

public void FemalekeysUp(e:KeyboardEvent):void

{

If (e.keyCode is 65)

aDown = false;

If (e.keyCode is 68)

dDown = false;

}

public void Check_Border (): void

{

If (FireBoy.x < = 0)

{

FireBoy.x = 0;

}

ElseIf (FireBoy.x > 750)

{

FireBoy.x = 750;

}

If (WaterGirl.x < = 0)

{

WaterGirl.x = 0;

}

ElseIf (WaterGirl.x > 750)

{

WaterGirl.x = 750;

}

}

}

}

My Hero.as code (FireBoy) is:

package

{

Import 12345678910111213import;

import flash.display.Sprite;

SerializableAttribute public class Hero extends Sprite

{

[Embed (source = "... / assets/FireBoy.jpg")]

private static FireBoy: Class const;

private var FireBoy:Bitmap;

public var grav:int = 0;

public var floor: int = 535;

public void Hero()

{

FireBoy = new Hero.FireBoy ();

scaleX = 0.1;

scaleY = 0.1;

addChild (FireBoy);

}

public void adjust (): void

{

This.y += grav.

If(this.y+this.height/2 < Floor)

Grav ++;

on the other

{

Grav = 0;

This.y = floor - this.height / 2;

}

If (this.x - this.width / 2 < 0)

This.x = this.width / 2;

If (this.x + this.width / 2 > 800)

This.x = 800 - this.width / 2;

}

}

}

And finally my code for Female.as (WaterGirl) is:

package

{

Import 12345678910111213import;

import flash.display.Sprite;

/**

* ...

* @author Harry

*/

SerializableAttribute public class female extends Sprite

{

[Embed (source = "... / assets/WaterGirl.png")]

private static WaterGirl: Class const;

private var WaterGirl:Bitmap;

public var grav:int = 0;

public var floor: int = 535;

public void Female()

{

WaterGirl = new Female.WaterGirl ();

scaleX = 0.1;

scaleY = 0.1;

addChild (WaterGirl);

}

public function adjust2 (): void

{

This.y += grav.

If(this.y+this.height/2 < Floor)

Grav ++;

on the other

{

Grav = 0;

This.y = floor - this.height / 2;

}

If (this.x - this.width / 2 < 0)

This.x = this.width / 2;

If (this.x + this.width / 2 > 800)

This.x = 800 - this.width / 2;

}

}

}

You should make use of the function trace to troubleshoot your treatment.  Put traces in the instructions conditional movement function different to see which is used in what circumstances.  You can consider putting the movement code into a function because they all run when you deal with a keyboard in any case event.

Tags: Adobe Animate

Similar Questions

  • Action/Script Photoshop to place the vertical line at the center of the Image

    How to create an action (or a script) in Photoshop that creates a vertical line in the center of the page?

    Here is an example of what I'm looking for.

    001-002.jpg

    First go to view > rulers, then right-click on the rule, and the percent change units.

    (so the action registers per cent and will work on different size documents)

    Then drag a vertical guide at the Center, drag one to the top of the image and the other down.

    (the goal is so the online tool is aligned with the top and down and you know where is the center of the document)

    For action, you can use the online tool and just save lines from the top of the image down along the center guide.

  • Can someone check where exactly I'm wrong

    I do this task using sbRIO9642 and sounds and vibrations box signal (looking for manual) on FPGA Simulator

    using "TACH OUT" signal box thus measure the speed edge sbrio ports

    I'm trying to measure the speed of the fan and this is the code for this

    every time when I run this code

    RPM from scratch, but I want the final value of the display...

    So that I can use this as a process variable to control the fan speed using pid

    irfan789 wrote:

    RPM from scratch, but I want the final value of the display...

    What happens if you leave the register shift uninitialized?

  • Action scripts when the PDF opens in the browser

    I may be in the wrong forum or can answer this question already

    I think that the answer will be no. but thought I would ask

    I use Adobe Pro and our institution as a whole has a license for Adobe Pro

    I wrote a script of Action that retrieves certain pages of a document package, some of them emails, records some of them and destroy them before that parts of the package that need signed are printed

    Here's my number

    We have Adobe Pro xi

    Windows 7

    THAT IS TO SAY 10

    The formula in question is generated from a browser application. All employees have the ability to go into tools - manage add-ons - and enable or disable Adobe Reader

    Mine is always disabled

    Several members of the staff have it turned on and open the document in the browser

    -so far all document javascripts I have written have worked anyway

    Action script though - I can't call when I go and activate Adobe Reader as the only elements that show to the staff's signature and comments form. The 'Tools' option is not there, and this is where my action script.

    I could force the staff to open in PDF format - but they won't be happy if I force this option

    is far from having the tools - and so my action script work if they open the PDF file in the browser?

    I guess I could try to do all the action script code in a JSButton if this is not possible, but action script allowed me to break the code into the section

    Thank you

    Acrobat/Reader install a limited Player plug-in and allows only some features that allow to interact with the file PDF is displayed in the browser for playback and recording. It does not features.

    If you need this plug-in, save the PDF file on the local system, and then open the saved PDF file.

  • Adding an itemRenderer to a list of spark using action script

    Hi guys,.

    IM, adding a spark list using action script.

    ... IM kinda a new to Flex, I want to add a picture to an item in the list, should I use an ItemRenderer component for this?

    If so, once created Im having trouble to add it with the action script...

    my code looks like this...

    list: list var = new List();

    list.dataProvider = collection;

    I tried...

    list.itemRenderer = "views. ItemRend ".

    and...

    list.itemRenderer = ItemRend

    But I get the same error...

    1067: coercion of a value of type String to an unrelated type mx.core:IFactory. InputBox.as /RegSpotter/src/com line 68 Flex problem

    or...

    1067: constraint implied a value of class type to a type unrelated to mx.core:IFactory. InputBox.as /RegSpotter/src/com line 68 Flex problem

    Thank you

    Aidan

    myList.itemRenderer = new ClassFactory(MyItemRenderer);
    
  • Someone know where I can find a disk for an older MacBook utility? It seems that Apple can't MacBook since 2007.

    Someone know where I can find a disk for an older MacBook utility? It seems that Apple can't MacBook since 2007.

    If you were able to call Apple support (after-sales applecare or apple?) and ask if they

    can know if you can still buy replacement system installation DVD of restoration for your MacBook

    they could tell you if it is possible if they have your serial number, to look further into it.

    • How to identify MacBook - Apple Support models

    • Find the serial number of your Apple - Apple Support product

    Depending on where you are, some support Apple or Apple Care facilities cannot

    be able to comply with a demand for vintage and filtering software obsolete spare.

    Some models introduced in 2007 started with 10.4 Tiger (with the version of the Intel-based OS)

    and went as far as Lion 10.7.5 as their higher upgrade system. All systems prior to 10.7

    usually included a system restore DVD media kit, gray-label of this Mac-specific disks.

    If you bought the computer in 2007, it may have been a year of construction 2006 model, in order to

    be able to identify the computer model exactly, the discovery of a boot of replacement keys is

    DVD that can also be used to prepare the computer for a replacement of the HDD, etc.. The

    utility disc on the DVD installation-restoration is an important tool; so is the installation disc & software.

    A detail of (if any) the system drive on the computer, if those who took on DVD

    would be a bootable disk utility version in the installation program. The DVD of grey original label

    media can be found in resale, are used or old stock, published initially with a Mac, new.

    Places online like Amazon may be able to provide the specific software package if you knew

    exactly the part numbers your computer had when new on these original discs.

    Serial number of Mac news - your Apple series number search:

    https://www.PowerBookMedic.com/identify-Mac-serial.php

    If you identify a number before contacting Apple computers on-line software resellers

    You may be able to narrow down. In addition, if identify the computer exactly, there may be some

    This time DVD media (exact details, new or used; original gray-replacement of labels, used.)

    And finally, if the computer running Snow Leopard 10.6.8 and he is older than the date of this

    OS X system, you could buy a DVD of Snow Leopard 10.6.3 retail on Apple Store online, to get

    http://www.Apple.com/shop/product/MC573Z/A/Mac-OS-x-106-Snow-Leopard

    the installation program which has a utility disk in the package. You start from the DVD to use these

    utilities include in the installation program. It can also erase everything. If the computer shipped with the

    last supported OS X installed 10.7, who no doubt had a key task to install USB, not a restore DVD.

    Later computers have their built-in OS X Recovery, a partition on the hard drive which has the OS X

    Utilities and a way to go online for the software of system recovery and restore without media disks.

    Nothing is as simple as it sounds. the first thing is to correctly identify the computer; If you call

    Apple (depending on where you are in the world), results may vary. their after-sales service or Apple

    Nobody care may be able to help or tell you that they cannot, on the basis of the serial number.

    In any case...

    Good luck & happy computing!

  • How a beginner can learn Action Script?

    I don't have a technical background, but I've been addicted to Flash for 2 years.  Where can I find really Action Script?  (Should I be worried?)

    If you have trouble is a good question.

    I think you'd be better to learn javascript if you're thinking about 10-40 years from now.  JavaScript been around and looks like he will stay longer than actionscript.

    However, actionscript and javascript are very similar so if you want to use flash learning you earn will be widely applicable to javascript.

    For more ActionScript, use the help files adobe and tutorials of senocular (senocular.com).

  • How can I reproduce a field in JavaScript, including its action script?

    Hello

    I saw ways to reproduce effectively the value of a field in JavaScript.  The following code is from a JavaScript for Acrobat API document:

    f = this.getField ("myField");

    for (var I in f) {}

    try {}

    If (typeof f [i]! = 'function') / / do not list the field methods

    Console.println (I + ': ' + f [i])

    } catch (e) {} / / an exception occurs when we get a property that

    } / / does not apply to this type of field.

    With the exception of all the scripts that could be associated with the field, I think that the code actually gives the variable "f" a copy of the field "MyField" - with all of its properties and values.  At this point how would I be able to get a copy of all the scripts in action the field?  I want to go to a certain extent, where I could possibly add them to the field 'f'  Is it possible to do this?

    Thank you for your time and consideration,

    Mike

    PS: I use Acrobat Pro XI for the development.

    No, you can not what actions/scripts are attached to field (events) with JavaScript triggers.

  • I liquidated my bar. As the search bar when you type in the web address, and now I can get it back. I handed to the clicked place where I did to trun off (unchecked it), and I don't see anything again?

    I liquidated my bar. As the search bar when you type in the web address, and now I can get it back. I handed to the clicked place where I did to trun off (unchecked it), and I don't see anything again?

    Hold down the key (key in OSX) and press the following letters in this exact order: V T M
    The bar of menus must now appear permanently, unless you turn it off again (view > toolbars). Turn on/off the menu bar is a new feature in version 3.6.

    See the other bars under view > toolbars. By clicking on one of them will place a check mark (display) or remove the check mark (not shown).

    Then, in the Menu bar, go to view-> toolbars-> customize, then press the Restore Default Set .

  • If I created my iPad to the text can I communicate with someone who is not an apple product?  If yes where can I start the process?

    If I created my iPad to the text can I communicate with someone who is not an Apple product?  If so, where should I start this process. She is studying how to set up his tablet to the text for me. Is this possible?  Explicit detail please... I am new to this. Thank you.

    To be able to not text on an iPad Apple devices, you need an associated iPhone to the Apple ID, the iPad is using.

    Read the following support document SMS since it deals with sending SMS through continuity.

    Continuity allows you to connect your iPhone, iPad, iPod touch and Mac - Apple Support

    With continuity, all SMS and MMS text messages that you send and receive on your iPhone may also appear on your Mac, iPad, and iPod touch. You can also meet your contacts from any device is closer to you, including your iPad or Mac.

  • Example: Pavilion 550qe: have just got a QED Pavilion and can not find the place where the monitor.

    Have just got a 550qe of Pavilion and can not find the place where the monitor.   The image on the book they sent shows the exact card, I need but can't find anywhere on the back of the PC.    There are a few plates little who have the drivers there, but do not want to start removing the panels unless this is where some of the connections are hidden.

    Hello

    Can't find the official specs of HP. But since the following specifications

    |-Intel-Core-i7-|-Windows-10-|-Silver.product.100241370.html http://www.Costco.com/HP-Pavilion-550qe-desktop-

    There

    Ports:

    • 2 x USB 3.0
    • 2 x USB 2.0
    • 1 x HDMI
    • 1 x VGA
    • 1 x jack Headphone-out/microphone-in the drop-down list
    • Multi format card reader

    Depending on your monitor, you can use HDMI or VGA to connect. What is your monitor (make and model)?

    Kind regards.

  • I bought a HP with Windows 10 Tower preloaded. Is there place where I can get help with installing Windows 7?

    * Original title: Windows 10 disappointment

    Recently, I bought a HP with Windows 10 Tower preloaded.  I gave up 10.  I would like to return to the Windows 7 desktop.  If I buy or buy this software, I guess I have to 'wipe' 10 of my machine?  Or I would just download 7 top?   What I have found online are instructions for people who have updated to 10 and want to revert to an earlier version of windows.  In my case, I never had an earlier version on the machine I have now.  Is there place where I can get help with installing Windows 7?  Online, local dealer?  Thank you.

    If I were you, I call HP and tell them that you do not want this computer with Win10.  They are very likely still sells machines with Win7 for businesses, because most companies do not affect the Win10 with a 10 foot barge pole.

    Dell is selling them for sure.  I've been helping my clients by computers Dell Win7 for a very long time now and just had one on my desk a week ago.  Look at the range of Dell Vostro of computers.

    The trick is to approach Dell as a businessman, and not as a normal consumer.

  • Unsolved - hyperlinks can not find the place where

    When you export my .indd to epub, I get the error message unresolved hyperlinks 14796 and another 14800.

    How can I find what who and where they are?

    I looked in the hyperlinks and cross-references - there is no URL to convert (they are already defined as hyperlinks).

    Under window/links, all 9 hypertext links are correct and functioning properly.

    All TOC links work correctly, go to the correct page.

    Can someone help me to know how to identify these links not resolved?

    Thank you!

    Try cross-references resolved or obsolete in the document

  • I have a Windows Server 2008 R2 system. I use Adobe Acrobat Pro XI. I'm looking for the place where I can change the default font of Calibri Minion Pro? Tools, content editing, formatting

    I have a Windows Server 2008 R2 system. I use Adobe Acrobat Pro XI. I'm looking for the place where I can change the default Miinion Pro to Calibri font?

    Tools, content editing, formatting

    You can't change it.

    Tuesday, January 13, 2015 11:22, tonywaidmann [email protected]>

  • How can I redirect with action script?

    Cannot not find it, I used to create a button in the action script that will send me to the new URL.

    This illustrates what you want:

    
    
    
    
        
    
    

Maybe you are looking for

  • My answer was edited by someone else

    Once an hour since my comment in a discussion topic has been published, I noticed that the text has been edited ⏤ someone has apparently added a note to my answer. Is it possible that someone (like the author of the thread or a community Apple Manage

  • How can I set the number of days that FF remembers a visited website?

    Using FF 8, a site link visited turns color to show that it was visited. I wish I had this color to return to normal after 14 days. In other words, I want FF remember I visited a site by turning the link a different color for only 14 days. At the mom

  • How to get txture dtx to NASCAR_Thunder_2004 compression

    HP windows xp

  • Hide a full menu with a click of the wheel

    Hello I have not created any menu in my application. I dynamically add a button to the screen using this code: ButtonField getDetailsButton = new ButtonField("See details", Field.FOCUSABLE | Field.FIELD_RIGHT); getDetailsButton.setChangeListener(new

  • Errors when trying to add GG DDL suport

    HelloI'm trying to add support for the DDL in an Oracle database using GG Version 11.2.1.0.3 Linux 11.2.0.4.The marker configuration script work fine.But the ddl_enable.sql contains errors:SQL > ddl_setup.sqlConfigure Oracle GoldenGate DDL replicatio