I give up! Some clues?

Here’s a little piece of code. Paste it in the first frame of en empty animation:

//Creates a circle 100 pixels large
this.createEmptyMovieClip("circle",-1);
circle.lineStyle(50,0,100); 
circle.lineTo(.15,.45); 

//Grow and shring functions
maxSize=400;
minSize=30;

function Grow(){
	this._xscale+=10;
	this._yscale+=10;
	if (this._xscale >= maxSize) this.onEnterFrame=Shrink;
}
function Shrink(){
	this._xscale-=10;
	this._yscale-=10;
	if (this._xscale <= minSize) this.onEnterFrame=Grow;
}

//We launch the movement
circle.onEnterFrame=Grow;

The first 3 lines create the circle. To see how it works, check the AS tricks about the drawing API. Other than that, I use callback functions, always very useful, so you can check that AS trick too.

If you have questions, don’t hesitate to post.

pom :slight_smile:

Umm… thank u … nice change of look over here he, he… nice, very nice, he, he…

Now really thanks so much. I thought you said i could avoid functions but the harder i tried the more i thought i would need them. Now i see i really need to get into the functions stuff or i’ll be missing a great powerful weapon.

Need more training.

Now, back to flashing. :wink:

Well, the code works perfect, and i understad how everything works (which is no guarantee that i can develope something like this that works myself, at least for the moment) But i only have a couple of doubts:

  1. When you write this line:

[COLOR=darkblue]

this.createEmptyMovieClip(“circle”,-1);
[/COLOR]

why depth is [COLOR=darkblue]-1[/COLOR] ?? Any reason or is it just because you like it like that?

  1. If I wanted to add this to a movie clip, it should go something like this, but when launching movement, the thing won’t stop growing. why?

[COLOR=darkblue]
onClipEvent (load){
maxSize=150;
minSize=90;
}
onClipEvent (enterFrame){
function Grow(){
this._xscale+=10;
this._yscale+=10;
if (this._xscale >= maxSize) {
this.onEnterFrame=Shrink;
}
else{
this.onEnterFrame=null;
}
}
function Shrink(){
this._xscale-=10;
this._yscale-=10;
if (this._xscale <= minSize) {
this.onEnterFrame=Grow;
}
else{
this.onEnterFrame=null;
}
}

this.onEnterFrame = Grow;

}
[/COLOR]

-1 to avoid confusion when I duplicate.

And you’re mixing dynamic and static event handlers. All you need to change is the name of the clip that you make grow at the end of the code.

pom :asian:

And you’re mixing dynamic and static event handlers.

:frowning: don’t understand. Sure is something very simple and i fell very stupid. Could you please explain???

Well, onClipEvent is static, onEnterFrame is dynamic. The problems in your code:

onClipEvent (load){
  maxSize=150;
  minSize=90;
}
onClipEvent (enterFrame){
// you redefine the function on EnterFrame: not good
  function Grow(){
    this._xscale+=10;
    this._yscale+=10;
    if (this._xscale >= maxSize) {
// you're inside a static handler, and you're trying to redefine the
// dynamic handler: won't work. Same after.
      this.onEnterFrame=Shrink;
    }
    else{
      this.onEnterFrame=null;
    }
  }
  function Shrink(){
  this._xscale-=10;
  this._yscale-=10;
  if (this._xscale <= minSize) {
    this.onEnterFrame=Grow;
  }
  else{
    this.onEnterFrame=null;
  }
}

Do you see why it doesn’t work now?
To make it work, simply replace circle.onEnterFrame=Grow; with yourClip.onEnterFrame=Grow;

pom :asian:

I never read post with titles like this one, some others do, some don’t, it’s just too long to look through all those “i need help”, “urgent help”, “i give up”, “newbie needs actionscript hero” , or whatever else is meant to grab attention, it just doesn’t, state what you want/ what the problem is in the title, so everybody knows if it’s interesting, if they might know the answer, if they’d like the answer too etc…

And now I’m going to post that in all the other one’s with similar titles…beerdrinkers and hellraisers…(ZZ Top)…