Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flash General Questions > Flash 9 General Questions

Reply
 
Thread Tools Rate Thread Display Modes
Old 01-10-2008, 07:50 AM   #1
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default DisplayObjects scaling incorrectly

Attached is a sample file. The problem is the displayobject called "track_mc" traces a different width than is set by the GUI. It is off by 3 pixels!

Does anyone know what is going on here? I need to the bars to be the same width.
Attached Files
File Type: zip visuals.zip (7.2 KB, 117 views)
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Old 01-10-2008, 05:32 PM   #2
dr_zeus
Feathers
 
dr_zeus's Avatar
 
Join Date: Mar 2005
Location: Silicon Valley
Posts: 1,999
Default

Sprites and MovieClips automatically resize themselves based on their content. If their content changes, their width and height values change.
__________________
Josh Tynjala | Feathers
dr_zeus is offline   Reply With Quote
Old 01-10-2008, 07:50 PM   #3
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

No...I think you missed the point. If the object shows a width of 400 in the GUI it will trace 404 pixels. Here is what is happening:

For objects that have a border, the object's actionscript width (what the object.width value with trace) is equal to the object's visualWidth (what is set in the GUI) + the object scaleX. It's a bug!

Look at the attached FLA and notice the "track_mc" with set in the GUI and then notice the width that it traces. They are inconsistent and wrong. The trace value
ActionScript Code:
track_mc.width = trackGUIwidth + track_mc.scaleX;
It is consistent among all objects with a border.

What I need is to be able to set the visualWidth with actionscript. Setting track to 300 pixels with actionscript will actually make it display at ~297 pixels.
Attached Files
File Type: zip display objects.zip (6.1 KB, 111 views)
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");

Last edited by Flash Gordon; 01-10-2008 at 07:52 PM.
Flash Gordon is offline   Reply With Quote
Old 01-10-2008, 08:24 PM   #4
Flash Gordon
rather be programming
 
Flash Gordon's Avatar
 
Join Date: Feb 2005
Location: City of Angels
Posts: 10,140
Default

attached is the conversion and fix for this BUG.

ActionScript Code:
/**  * Because of a bug with how object with border widths (and heights) are measured, we must  * convert the desired display width (as it would appear in the GUI and on screen) into  * a scaled actionscript width. The actionscript width has the following equation:  *  * ASwidth = obj.visualWidth + obj.scaleX;  *  * @obj.visualWidth is the width set in the GUI  * @obj.scaleX is the scale value of the object  * @ASwidth is the width it will trace in actionscript  */ var visualWidth:Number = 300; // how it should look on the screen var noScaleWidth:Number = track.width / track.scaleX - 1; // find the width without scaling as in GUI var scale:Number = visualWidth / noScaleWidth; // find how much it needs to scale to track.width = visualWidth + scale; trace( track.width ); // traces 303 but visually appears as 300 pixels
Attached Files
File Type: zip displayobjects scale.zip (7.3 KB, 118 views)
__________________
trace("Good bye Flash.") Log.i(TAG, "Hello Droid");
Flash Gordon is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Image scaling in Flash with Actionscript 3.0 phillyj8 ActionScript 3.0 4 01-13-2009 04:46 AM
A member attribute was used incorrectly. meddlingwithfir ActionScript 2.0 8 01-17-2008 06:53 AM
9-slice scaling doesn't work on children? astgtciv ActionScript 2.0 4 04-21-2007 06:34 AM
Scaling projector without scaling emebedded swf files burntdawn Projectors and CDs 0 03-02-2007 09:35 PM
Scaling question maxx ActionScript 2.0 0 10-19-2005 06:48 PM


All times are GMT. The time now is 12:56 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.