dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Dynamic Text/Coordinates

  1. #1
    Senior Member
    Join Date
    Dec 2000
    Posts
    147

    Dynamic Text/Coordinates

    Hi, I need a text box to be dynamically populated depenant upon where a movie clip is. I have created the following code, but when i run it the text box is poplulated with the final (3rd) option straight away???? Why is it jumping straight to this when dis_arrow is actually postioned at the 1st coordinates?

    if ((dis_arrow._y = 214.7) && (dis_arrow._x = 353.1)){
    ACN.text = "+ADC";
    }

    if ((dis_arrow._y = 234.2) && (dis_arrow._x = 353.1)){
    ACN.text = "+AF1";
    }

    if ((dis_arrow._y = 253.7) && (dis_arrow._x = 353.1)){
    ACN.text = "+AF2";
    }
    mileso

  2. #2
    Registered User nunomira's Avatar
    Join Date
    May 2002
    Location
    portugal
    Posts
    7,003
    hi mileso,

    If you want code to change over time, you'll have to continuously evaluate it.

    For example... when you move the mouse, or on enter frame...

    Also, notice that those conditions are exclusive, so you should use else..if
    code:

    this.onEnterFrame = function()
    {
    if ((dis_arrow._y = 214.7) && (dis_arrow._x = 353.1))
    {
    ACN.text = "+ADC";
    }
    else if ((dis_arrow._y = 234.2) && (dis_arrow._x = 353.1))
    {
    ACN.text = "+AF1";
    }
    else if ((dis_arrow._y = 253.7) && (dis_arrow._x = 353.1))
    {
    ACN.text = "+AF2";
    }
    };



    try this.onMouseMove instead of this.onEnterFrame to see the difference.

  3. #3
    Senior Member
    Join Date
    Dec 2000
    Posts
    147
    Hi and thanks for your reply. Unfortunetly neither options work.
    mileso

  4. #4
    http://pat.theorigin.net cresquin's Avatar
    Join Date
    Jun 2003
    Location
    Los Angeles, CA
    Posts
    685
    2 reasons: first = is the operator for setting a variable to a value. when setting a variable fails, for instance when you try to set a read-only variable _ymouse and _xmouse, this returns false. You want == the operator for evaluating equality.

    Also dis_arrow._x will probably never to be a decimal 353.1 unless it is explicitly set to that. you should try a range ((dis_arrow._y >= 253) && (dis_arrow._y <= 255) && (dis_arrow._x >= 353) && (dis_arrow._x <= 355))

    instead use

  5. #5
    Senior Member
    Join Date
    Dec 2000
    Posts
    147
    The position of mc 'dis_arrow' is set exactly, therefore i cant use >= or <=. I have changed the code to the following but it still doesnt work.

    this.onEnterFrame = function()
    {
    if ((dis_arrow._y == 214.7) && (dis_arrow._x == 353.1))
    {
    ACN.text = "+ADC";
    }
    else if ((dis_arrow._y == 234.2) && (dis_arrow._x == 353.1))
    {
    ACN.text = "+AF1";
    }
    else if ((dis_arrow._y == 253.7) && (dis_arrow._x == 353.1))
    {
    ACN.text = "+AF2";
    }
    };
    mileso

  6. #6
    Senior Member
    Join Date
    Dec 2000
    Posts
    147
    To give you a more accurate idea of what i am trying to achieve please take a look at the attached file. Whichever acyonym the arrow is pointing to should be displayed in the top right hand dynamic text box. You move the arrows using the navigation keys at the bottom.
    Last edited by mileso; 08-15-2012 at 10:22 AM.
    mileso

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center