PDA

View Full Version : Pathing issues when drawing at runtime


Hopefooly
09-16-2003, 01:31 AM
ok, heres the code i have on the main stage, it is just to mess around and i was trying to learn a few things from my O'Rielly book by Colin Moock. I might just be missing it but heres the code with a following explanation of my problem.

this.createEmptyMovieClip("box", 1);
this.lineStyle(.25);
this.moveTo(100,100);
this.beginFill(0xFF0000);
this.lineTo(100,100);
this.lineTo(200,100);
this.lineTo(200,200);
this.lineTo(100,200);
this.endFill();

this.onLoad =function() {
this._alpha=100;
rate = 10;
}

this.onEnterFrame = function () {
if(this._alpha <5 || this._alpha >95) {
rate = -rate;
}
this._alpha += rate;
}

now when i change the this. reference to the instance name "box" it doesnt work. ive treid just box, _root.box, with the onLoad and onEnterFrame operators...and it wont work when i do it that way. it works as the way it is now...just want to know why it wont work otherwise.

annexion
09-16-2003, 02:31 AM
_root.createEmptyMovieClip("box", 0);
box.beginFill(0xFF0000);
box.lineStyle(0, 0x000000);
box.moveTo(100, 100);
box.lineTo(100, 100);
box.lineTo(200, 100);
box.lineTo(200, 200);
box.lineTo(100, 200);
box.endFill();
box._alpha = 100;
box.rate = 10;
box.onEnterFrame = function() {
if (this._alpha<5 || this._alpha>95) {
this.rate = -this.rate;
}
this._alpha += this.rate;
};

It was a pathing issue. This should do it.

Good luck.

Hopefooly
09-17-2003, 11:57 AM
awesome...it worked. thanks annexion

annexion
09-17-2003, 02:15 PM
No problem;)