The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • ActionScript
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 ActionScript

  • JimTester Author 
    • 24212 
    • 0 
    • 3 
    TextField autoSize - Height not updating
    JimTester

    Last reply Apr 25 2008, 06:24 AM

    by JimTester

    Posted: Apr 24 2008, 10:32 AM

    by JimTester

     

yes

Hi

Can anyone tell me if there is something wrong with my code?
I followed a tutorial word for word on Lynda.com to create a dynamic text field and scroll some text in it.  The tutorial on Lynda.com works ‘fine and dandy’ but mine doesn’t.

I have attached my code and accompanying files.

Basically I load some text and apply a stylesheet. 
I then load this into the dynamic textfield (external_txt) which lives within text_mc.
I then perform some calculations and attempt to scroll.
I am certain the calculations are correct.  It is just that when the textfield doesnt resize the values end up wrong and the results is th text scrolls in the wrong direction.


There is a line of code that says:
text_mc.external_txt.autoSize = TextFieldAutoSize.LEFT;

However, when I trace the height of text_mc (within the textLoaded function) the height has shrunk rather than autosized to a bigger value.

The result of this is that my text scrolls in the wrong direction when I use the drggable scroller (scroller_mc).

Can anyone advise?

Many Thanks

good

  3 REPLIES
 
JimTester Author 
1  
JimTester

Ok.  I’ve fixed this.  I’m just looking at why and then I’ll post again with the new files and hopefully the reason why.

  • 24 April 2008 11:56 AM
  •  
JimTester Author 
2  
JimTester

Ok, the problem was this.

The line:
text_mc.external_txt.htmlText = textLoader.data;
needed to be in the textLoaded function instead of the cssLoaded function.

Moving this line of code fixed the problem.  Although I have to admit that I’m not sure EXACTLY why this is.  If anyone can figure out why this is the case I would be very grateful.

I’ve uploaded a new .fla called textTest.fla.  You can get the css file and txt file out of the zip file in my original post.

Does anybody know exactly why this works and my first fla didn’t? confused

Cheers

:-)

  • 24 April 2008 12:10 PM
  •  
JimTester Author 
3  
JimTester

Ok…After sticking several trace statements in the code I figured out the reason is to do with the fact that the cssLoaded() handler had not finishing processing its code and the textLoaded() handler had gone ahead and calculated the minScroll and maxScroll values using the initial/current value of text_mc.height (which is about 19.9000000 - which I assume is the height of 1 line of text).  [It’s approx 20 and this I think is to do with “twips” but that’s another topic!]

BUT text_mc.height had not been updated as the following line of code had not executed:
text_mc.external_txt.htmlText = textLoader.data;

By the time it had executed and cssLoaded() had finished its work it was too late.

By moving this line of code into the textLoaded() handler everything works because autoSize kicks in and thus text_mc.height gets updated appropriately.

I thank you and good night

good

  • 25 April 2008 06:24 AM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 780  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,729  Assets
  • Profiles 284,156  Members
  • Topics 93,805  Topics
  • Blog 4  Blog
  • Facebook 1,679  Facebook
  • Twitter 1,160  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Thu, February 23, 2012 - 18:26:52