A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: new to using classes - if statement

  1. #1
    Senior Member
    Join Date
    May 2000
    Posts
    814

    new to using classes - if statement

    I have a simple question, i'm new to clases as i've always worked on timelines etc.

    i'm playing around with a simple scrolling text box that i've picked up from gotoandlearn tuts. My problem is with my if statements, i'm trying to remove my sb (scroll bars) when the imported text is shorter than the sb.

    I have it working on the timeline but when i move the code inside the class i get no response. I can trace both heights for the text content and scrollbars, and if i add sb.visible = false; as a test i get that to work. my if statements are just not happening.

    Code:
    package com
    {
    	import flash.display.*;
    	import flash.events.*;
    	import com.greensock.*;
    	import com.greensock.easing.*;
    	
    	import flash.text.TextFieldAutoSize;
    	
    
    	public class ScrollBox extends MovieClip
    	{		
    	
    
    		public function ScrollBox():void
    		{
    		
    			
    			sb.addEventListener(ScrollBarEvent.VALUE_CHANGED, sbChange);
    			
    			content.news_text.condenseWhite = true; 
    			content.news_text.multiline = true;
    			content.news_text.autoSize =  TextFieldAutoSize.LEFT ;
    			content.news_text.wordWrap =  true ;
    
    trace(content.news_text.height);
    trace(sb.height);
    
    			
    			if(content.news_text.height <= sb.height)
    			{
    				sb.visible = false;
    				}
    				
    			if(content.news_text.height >= sb.height)
    			{
    				sb.visible = true;
    				}
    		
    
    			
    			//sb.visible = false;
    		
    		}
    		
    		private function sbChange(e:ScrollBarEvent):void
    		{
    			TweenLite.to(content, 1, {y:(-e.scrollPercent*(content.height-masker.height)), ease:Expo.easeOut});
    			
    		}
    	}
    }

  2. #2
    Senior Member
    Join Date
    May 2000
    Posts
    814
    done some more testing and i think it is more to do with the TextFieldAutoSize not working in the class, and not the if statements.

    And adding the loading text to the class seems to have solved it.
    Last edited by ratboy; 06-21-2012 at 09:03 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center