00:00
00:00
Newgrounds Background Image Theme

BUNKUMBITCH just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

mc._width = rectangle.width (AS2)

605 Views | 7 Replies
New Topic Respond to this Topic

mc._width = rectangle.width (AS2) 2014-10-16 08:20:00


So, playing around with AS2. Yep, AS3 is better... I know. But I like to use both. Anyway.

I've got this

var wasRect:Rectangle = getAlphaBounds(txtWas);

trace(strike._width);
trace(wasRect.width);
strike._width=wasRect.width;
trace("New Width "+strike._width);

The traces work and numbers update, but the strike mc does not. Any idea why and how to fix this?


Well if the value is changing but it's not showing visually then it's likely you have an external problem. Maybe another object is covering it. Or maybe you're referencing the wrong object.

Maybe setting it's rotation to 45 or something and see if it changes. If not then you're not looking at the right object.


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

That's strange, when I use getAlphaBounds in AS2 I see there's no such function. What values do the traces return? The closest I could come up to was getBounds, and that returns an Object with properties xMax, xMin, yMax and yMin.

Alternatively, is getAlphaBounds a custom function? If so, what's the code for it?


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

Response to mc._width = rectangle.width (AS2) 2014-10-16 22:00:14


At 10/16/14 09:42 PM, Gimmick wrote: Alternatively, is getAlphaBounds a custom function? If so, what's the code for it?

That's not really relevant, trace the width before, apply whatever, trace it again. If it's different and not showing visually that's the issue.

I wouldn't say it's a custom function, it's just a function that's not in the flash package. What would you consider custom?


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

Response to mc._width = rectangle.width (AS2) 2014-10-16 22:23:52


At 10/16/14 10:00 PM, MintPaw wrote: That's not really relevant, trace the width before, apply whatever, trace it again. If it's different and not showing visually that's the issue.

Well I did this now as:

// two movieclips called "txtWas" and "strike" like in OP's
// one with width 7, the other with 140.95
trace(strike._width)         //output: 7
trace(txtWas._width)       //output: 140.95
strike._width = txtWas._width
trace(strike._width)        //output: 140.9
trace(txtWas._width)      //output: 140.95

And the first time I tried it with getAlphaBounds (not defined AFAIK):

// same arrangement, two mc's with different widths
import flash.geom.Rectangle;
var rectB:Rectangle = getAlphaBounds(txtWas)      //txtWas' width is 190, strike's is 100
trace(rectB.width)                        //undefined
trace(txtWas._width)                   //190
trace(strike._width)                     //100
strike._width = rectB.width
trace(rectB.width)                        //undefined
trace(strike._width)                     //100
I wouldn't say it's a custom function, it's just a function that's not in the flash package. What would you consider custom?

Yeah that's what I meant, something that's not included by default in the flash package.


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

At 10/16/14 10:23 PM, Gimmick wrote: Stuff

Well if the trace comes back undefined then I'm sure he'd know it and investigate his function.

I wouldn't say it's a custom function, it's just a function that's not in the flash package. What would you consider custom?
Yeah that's what I meant, something that's not included by default in the flash package.

Yeah, but that vague, technically Tween and Color are in the mx package, but I'd still consider them flash classes. And even the flash package you have to import to use. You're not meant to think about function like that, nothing is really 'default' or 'custom', when it's imported it's imported.

Although to solve this problem I agree more tracing is needed on his part.


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature

At 10/17/14 12:21 AM, MintPaw wrote: Yeah, but that vague, technically Tween and Color are in the mx package, but I'd still consider them flash classes. And even the flash package you have to import to use. You're not meant to think about function like that, nothing is really 'default' or 'custom', when it's imported it's imported.

OK; good to know, thanks! So is it okay to think of custom functions as "functions in imported non-Adobe classes"? :p


Slint approves of me! | "This is Newgrounds.com, not Disney.com" - WadeFulp

"Sit look rub panda" - Alan Davies

BBS Signature

Response to mc._width = rectangle.width (AS2) 2014-10-17 01:40:36


At 10/17/14 12:52 AM, Gimmick wrote: OK; good to know, thanks! So is it okay to think of custom functions as "functions in imported non-Adobe classes"? :p

Whatever floats your boat.


If ya have something to say, PM me. I have a lot of time to spare.

Also never PM egg82.

BBS Signature