A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: [RESOLVED] Setting up variables in different levels

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Location
    NekoCity
    Posts
    21

    resolved [RESOLVED] Setting up variables in different levels

    Actionscript Code:
    if (Key.isDown(attack2Key)&&shot2reload == 0) {
            for (i=1; i<2+1; i++) {
                shot2++;
                shot2reload = 30
                var newname = "shot2_"+shot2;
                _root.attachMovie("shot2", newname, shot2*100+1);
                _root[newname]._y = _root.player._y;
                _root[newname]._x = _root.player._x+i*40-60;
                _root[newname].onEnterFrame = function() {
                    var yVel = 10;
                    this._y -= yVel;
                    if (this._y<0) {
                        this.removeMovieClip();
                    }
                };
                trace (_root.[newname].yVel)
            }
        }

    rather than setting speed(yVel) in the onEnterFrame,
    I want to set it as I create the movieclip I'm stuffing it in.
    The trace is my attempt to access that variable

  2. #2
    Junior Member
    Join Date
    Jan 2010
    Location
    NekoCity
    Posts
    21
    Actionscript Code:
    if (Key.isDown(attack2Key)&&shot2reload == 0) {
            for (i=0; i<2; i++) {
                shot2++;
                shot2reload = 30
                var newname = "shot2_"+shot2;
                _root.attachMovie("shot2", newname, shot2*100+1);
                _root[newname]._y = _root.player._y;
                _root[newname]._x = _root.player._x+i*40-20;
                    _root[newname].yVel = 1;
                _root[newname].onEnterFrame = function() {
                    this.yVel = this.yVel+2//^1.1;
                    this._y -= this.yVel;
                    if (this._y<0) {
                        this.removeMovieClip();
                    }
                };
            }
        }

    Just solved my own problem. Sorry for wasting space.

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