A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: using if with dynamic text

  1. #1
    Junior Member
    Join Date
    Jul 2013
    Posts
    1

    using if with dynamic text

    Hello everyone i'm trying to make a movie clip move horizontally across the screen and then back again when it reaches the edge of the stage.

    I'm extremely rusty with actionscript and i was trying to use two movie clips either side of the screen to change the text in a dynamic text box which the code would change the direction depending on which word was displayed in the box. as the code is currently it wont move left or right. if i just want it to move in one direction and take out one of the directions it moves across fine but then doesnt stop or go back.

    here is the code i am using on the movieclip that i want to move on the screen

    onClipEvent (enterFrame) {
    if (this.hitTest(_root.stage_mov.right_mov))
    {
    _root.stage_mov.hittext.text = "left";
    }
    if (this.hitTest(_root.stage_mov.left_mov))
    {
    _root.stage_mov.hittext.text = "right";
    }
    }

    onClipEvent (enterFrame) {
    if (_root.stage_mov.hittest.text == "right")
    {
    xspeed = 3;
    this._x += xspeed;
    }
    else
    {
    if (_root.stage_mov.hittest.text == "left")
    {
    xspeed = 3;
    this._x -= xspeed;
    }
    }
    }

    any advice would be very gratefully appreciated, oh and i'm currently using the latest flash

    thanks mike

  2. #2
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    i'm currently using the latest flash
    this is irrelevant since you're using as2, it is impossible to target latest flash.

    regardless, before any of hit tests (or some other code) set the text, your second enterFrame handler will not know where to move.
    who is this? a word of friendly advice: FFS stop using AS2

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