A Flash Developer Resource Site

Results 1 to 13 of 13

Thread: LED Message Board?

  1. #1
    Senior Member
    Join Date
    Jan 2010
    Posts
    141

    LED Message Board?

    Hello all! I was hoping someone could point me in the correct direction. I want to create an LED message board that I can load text dynamically. I've searched for a tutorial, but can't seem to find what I am looking for. When I search for scrolling text, I get the scroll bar component. When I search Flash tutorial LED message board, I get link to make an actually LED message board, or control the content of one. I don't know if I am searching for the wrong thing, or if it just does not exist. I basically want to mimic one of these boards: http://http://www.storesupply.com/pc...FeZFMgodTDgAaQ

    Note does not need to be multi colored, just a single color.

    Thanks for any help with this. I'm going to try to mess around and figure something out, but I'm not sure I will be able to figure out how to do this on my own.

  2. #2
    Senior Member
    Join Date
    Jan 2010
    Posts
    141

    Follow up

    So after messing around with the text scroll component, I gave up on that and decided to use a tween, because i could not find a way to get the text to scroll from left to right and automatically. So far I have a dynamic text box on the stage called myText. Here is the code I have so far:

    Code:
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    
    function onEnterFrame(e:Event){
    	myText.width = 800;
    	myText.autoSize = TextFieldAutoSize.LEFT;
    	myText.text="When the moon is in the seventh house and Jupiter aligns with Mars and a whole lot of more stuff to test."
    	trace("textBox width" + myText.width);
    	TweenLite.to(myText, 3, { x:-800, ease:Linear.easeNone});
    }
    I added the trace statement when the tween was not working properly. It still seamed to have easing and would not move fully out of view. The trace statement returned stated, "textBox width1144.55". Not sure why the text is not auto formatting to the set width. Can someone help with this. I'm trying to get this step figured out before I worry about dynamically loading text and switching out the statements.

    Thanks!

  3. #3
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    Ok so I am making some "progress" I finally got code to change the size of the text to fit the text box (using while statement). However after the desired size is reached, the while statement keeps working. Any one got any ideas on how to fix this?

    Code:
    var myTextFormat:TextFormat = new TextFormat();
    var myTextSize:Number = 52;
    
    addEventListener(Event.ENTER_FRAME, onEnterFrame);
    
    function onEnterFrame(e:Event){
    	myText.width = 800;
    	myText.autoSize = TextFieldAutoSize.LEFT;
    	myText.text="When the moon is in the seventh house and Jupiter aligns with Mars and a whole lot of more stuff to test.";
    
    	while (myText.width > 800){
    		myTextSize = myTextSize -1;
       		myTextFormat.size = myTextSize;
      		myText.setTextFormat(myTextFormat);
       		myText.autoSize = "left";
    	}
    	TweenLite.to(myText, 5, { x:-737.45, ease:Linear.easeNone});
    }
    Thanks!

  4. #4
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    Okay I fixed it! I needed to remove the onEnterFrame and just make it an event.

    Code:
    var myTextFormat:TextFormat = new TextFormat();
    var myTextSize:Number = 52;
    
    sizeText();
    
    function sizeText(e:Event = null){
    	myText.width = 800;
    	myText.autoSize = TextFieldAutoSize.LEFT;
    	myText.text="When the moon is in the seventh house and Jupiter aligns with Mars and a whole lot of more stuff to test.";
    	//trace("textBox width" + myText.width);
    	while (myText.width > 800){
    		myTextSize = myTextSize -1;
       		myTextFormat.size = myTextSize;
      		myText.setTextFormat(myTextFormat);
    	}
    	TweenLite.to(myText, 10, { x:-737.45, ease:Linear.easeNone});
    }
    It also fixed the easing issues I was having.

    Now can someone help me figure out how to have the text input from an XML file? I want to have several sentences that I want to import and then one at a time have them scroll (tween). I don't know if I should import the sentences into an array and then write code to access them. Not sure where to start here. Any help would be great!

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    follow these steps:
    1 open google.com in your browser
    2 type in something like as3 loading xml file, hit enter
    3 click random link that google returns, and read
    4 repeat 3 until the problem is solved
    this is how I do it and, take my word for it, it works remarkably well.
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    realMakc,

    Love the sarcasm. I have been doing that, as I am not an idiot and not looking for someone to just give me answers with out doing the work. The problem is I can't find anything that applies to what I am trying to accomplish. I can do a ton of image galleries, or load in one continual paragraph of text, but I can't find anything that deals with the handling of multiple text statements. So can you help, or just apply more sarcasm?

    Can you tell this problem is frustrating me?

  7. #7
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    or load in one continual paragraph of text, but I can't find anything that deals with the handling of multiple text statements
    tbh I do not see how these two tasks are different. like at all.
    who is this? a word of friendly advice: FFS stop using AS2

  8. #8
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    I have an XML document with 3 sentences. I want them to show up one at a time in a text box. The text will scale to fit (800pxs) and tween across a masked area so it looks like it is on an LED Message Board. (I figured out that part). After the tween I want the text box to then load then next statement from the XML file, put back in the original placement (can do that) and scale/tween. Then the 3rd load again; then back to the first...

    That is the difference. I can get xml data in, just don't know how to change the content of the text box. I'm thinking I need to use an array, but I've not done this before. Does that help explain?

  9. #9
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    I also don't know if it would make more sense to just make 3 different text boxes and just call them in code...

  10. #10
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    923
    Quote Originally Posted by word2yerMom View Post
    I'm thinking I need to use an array, but I've not done this before. Does that help explain?
    Yes that does. To use an array, you need to:
    PHP Code:
    var array:Array = ["text 1""text 2""text 3"];
    var 
    index:int 0;
    ...
    // when it's time to change text
    index = (index 1) % array.length// 0, 1, 2, 0, 1, 2, 0...
    yourTextField.text = array [index]; 
    If you want more detailed version, use the google method above with a query like working with arrays in as3.
    who is this? a word of friendly advice: FFS stop using AS2

  11. #11
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    THANKS!!! This has been driving me bonkers!

  12. #12
    Senior Member
    Join Date
    Jan 2010
    Posts
    141
    SO I've made some progress/changes. But it still does not work. Here is my code, but I get Error: Error #1023: Stack overflow occurred. From searching error I'm getting that the fact that I call a function from a function that is what throwing the error, but I don't know how to fix.

    Code:
    import flash.net.URLRequest;
    import flash.net.URLLoader;
    import com.greensock.*;
    import com.greensock.easing.*;
    import flash.text.TextFieldAutoSize;
    
    var array:Array = new Array();
    var myXML:XML;
    var myLoader:URLLoader = new URLLoader();
    myLoader.load(new URLRequest("schoolMessages.xml"));
    myLoader.addEventListener(Event.COMPLETE, processXML);
    myText1.autoSize = TextFieldAutoSize.LEFT;
    myText2.autoSize = TextFieldAutoSize.LEFT;
    myText3.autoSize = TextFieldAutoSize.LEFT;
    
    var txLen1:Number;
    var txLen2:Number;
    var txLen3:Number;
    var twNum1:Number;
    var twNum2:Number;
    var twNum3:Number;
    var stX:Number = 596.85;
    var index:Number = 0;
    var tweenNum:Number = 1;
    
    function processXML(e:Event):void {
    	myXML = new XML(e.target.data);
    	var len:int = myXML.saying.length();
    	trace(len);
    	for(var i:int = 0; i<len; i++){
    		array.push(myXML.saying[i]);
    	}
    	//set text box text to array content; find length; 
    	myText1.text= array[0];
    	txLen1 = myText1.width;
    	//find how much text box needs to tween (text length + length of area text shows)
    	twNum1 = -(txLen1 + 524);
    	myText2.text= array[1];
    	txLen2 = myText2.width;
    	twNum2 = -(txLen2 + 524);
    	myText3.text= array[2];
    	txLen3 = myText3.width;
    	twNum3 = -(txLen3 + 524);	
    	
    	tween1();
    }
    
    function tween1(e:Event = null):void{
    	//Need to move text box 3 back to starting position; make invisible; move to start; make visible
    	myText3.visible = false;
    	myText3.x = stX;
    	myText3.visible = true;
    	//tween text box 1
    	TweenLite.to(myText1, 12, { x:twNum2, ease:Linear.easeNone, onComplete:tween2() }); //
    }
    
    
    function tween2(e:Event = null):void{
    	//Need to move text box 1 back to starting position; make invisible; move to start; make visible
    	myText1.visible = false;
    	myText1.x = stX;
    	myText1.visible = true;
    	//tween text box 3
    	TweenLite.to(myText2, 12, { x:-twNum2, ease:Linear.easeNone, onComplete:tween3() });
    }
    
    function tween3(e:Event = null):void{
    	//Need to move text box 2 back to starting position
    	myText2.visible = false;
    	myText2.x = stX;
    	myText2.visible = true;
    	//tween text box 3
    	TweenLite.to(myText3, 12, { x:twNum3, ease:Linear.easeNone, onComplete:tween1() });
    }
    If someone knows how I can just use one textbox that will after the tween change the contents then tween; change tween; etc. Please let me know. I swear I know code until I try to do something new, then I feel like an idiot. ARG!

  13. #13
    :
    Join Date
    Dec 2002
    Posts
    3,518
    Code:
    var myXML:XML;
    var stX:Number = stage.stageWidth;
    var speedX:int = 2;
    var gap:int = 20;
    var index:int = 0;
    var len:int;
    
    var myLoader:URLLoader = new URLLoader();
    myLoader.load(new URLRequest("schoolMessages.xml"));
    myLoader.addEventListener(Event.COMPLETE, processXML);
    myText1.autoSize = TextFieldAutoSize.LEFT;
    myText2.autoSize = TextFieldAutoSize.LEFT;
    
    function processXML(e:Event):void {
            myXML = new XML(e.target.data);
            len = myXML.saying.length();
            myText1.text = myXML.saying[index++].toString();
            index = (index == len) ? 0 : index;
            myText2.text = myXML.saying[index++].toString();
            index = (index == len) ? 0 : index;
            myText1.x = stX;
            myText2.x = myText1.x + Math.max(stX, (myText1.width + gap));
            myText2.y = myText1.y;
            stage.addEventListener(Event.ENTER_FRAME, mover)
    }
    function mover($e:Event):void {
            myText1.x -= speedX;
            myText2.x -= speedX;
            if (myText1.x <= 0 - myText1.width) {
                    myText1.x = myText2.x + Math.max(stX, (myText2.width + gap));
                    myText1.text = myXML.saying[index++].toString();
                    index = (index == len) ? 0 : index;
            }
            if (myText2.x <= 0 - myText2.width) {
                    myText2.x = myText1.x + Math.max(stX, (myText1.width + gap));
                    myText2.text = myXML.saying[index++].toString();
                    index = (index == len) ? 0 : index;
            }
    }

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