Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

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

New Here ,
Apr 11, 2013 Apr 11, 2013

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:

TOPICS
ActionScript
819
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Apr 11, 2013 Apr 11, 2013

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;

}

Translate
Community Expert ,
Apr 11, 2013 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2013 Apr 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?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 11, 2013

i_MCMButton.onPress = function()

{

_root.playerinfo.onPress = function()

    {

     _root.playerinfo.startDrag();

    }

_root.playerinfo.onMouseUp = function()

    {

     _root.playerinfo.stopDrag();

    }

}

I want to be able to scale the _root.playerinfo with a drag function...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 11, 2013

My main question is just how to resize/scale a movieclip at runtime with a drag function...

If I could get a code example of just that, I'd greatly appreciate it...

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2013 Apr 11, 2013

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);

resize_mc._height+=(_ymouse-startY);

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 11, 2013

Thank You Very Much!!!

One question...is onRelease the same as onMouseUp?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 11, 2013

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

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2013 Apr 11, 2013

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;

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 11, 2013 Apr 11, 2013

SPLENDID!!  YOU ROCK!!

Thank You Very Much for your Time, Attention and Quick Responses!!

We need more helpful people like you in the world!! 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 11, 2013 Apr 11, 2013
LATEST

you're very welcome.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines