Skip to main content
Mercinova
Known Participant
April 11, 2013
Answered

What's the code for Scaling a MovieClip at Runtime?

  • April 11, 2013
  • 1 reply
  • 876 views

I can't believe how difficult it's been to find an answer for such a simple question.  I found a thread in this forum titled "How to Resize a MovieClip at Runtime?", but the code that was posted as an answer has been removed from the post.  WHY?!?!  Is it a highly guarded secret?!?!

Anyway...I just want to know how to scale a movieclip at runtime with a drag function...and also while the parent movieclip already has a drag function active.

Any help would be much appreciated.

BTW...I've found a cure for death that also instantly makes you the richest person in the world with all the knowlege of the universe...

It can be found here:

This topic has been closed for replies.
Correct answer kglad

Ok...I got it to resize, but WOW it resizes quick! 

Is there a way to slow it down and keep it proportionate?


onMouseUp and onRelease is usually (but not always) the same.

you can use a scaling factor:

var scaleFactor:Number = .3;

mc.onPress=function(){

resize_mc = this;

startX =_xmouse;

startY = _ymouse;

this.onEnterFrame=resizeF;

}

mc.onRelease=function(){

delete this.onEnterFrame;

}

function resizeF():Void{

resize_mc._width+=(_xmouse-startX)*scaleFactor;

resize_mc._height+=(_ymouse-startY)*scaleFactor;

}

1 reply

kglad
Community Expert
Community Expert
April 11, 2013

if a parent movieclip has mouse handlers assign, mouse events for the child will be intercepted.  you'll need to use a loop and hittest to detect when the child undergoes a mouse event.

the messages on the adobe forums that seem to have disappeared were caused by a forum conversion a few years ago.  that's why many threads for a few years ago (or earlier) seem to have missing responses.

Mercinova
MercinovaAuthor
Known Participant
April 11, 2013

Much Thanks for the quick reply, Kglad, but I'm a complete noob of AS and need a code example...if it's not too much to ask.

kglad
Community Expert
Community Expert
April 11, 2013

what's the code you're using now for the parent?

what's the instance name of the child?

on press of what movieclip/button do you want to start resizing the child?