A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Errors in displaying textfields and graphics.

  1. #1
    Member
    Join Date
    Nov 2002
    Posts
    43

    Errors in displaying textfields and graphics.

    Hello everybody.

    I am consistently bugged with some errors that come and go without my understanding of what is happening.

    Every time I draw a gradient box throuh the code (I use a lot of them for the backgrounds with dynamic colours) I can just pray that it shows on the stage. Most of the time it does, but some times it doesn't. The trace statement is lying to me that the graphics is on the stage.

    I resize dynamically a textfield to the height of the text in it. Most of the time it resizes correctly, but some times it doesn't, and makes my next line of text invisible. The trace statement again is lying to me that the textfield was resized.

    Is there any way to make sure that my code is executed correctly or at least to find the error and fix it?

    The example of the text animation and dynamic background I use is here:
    http://rxtv.ca/DSS_demo/demoDell.html

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    There are so many factors as to why this could be happening its really hard to try to troubleshoot , in a forum like this. I've been working with flash for 8 years , writing code for longer , and in my experience , 90 % of problems can be identified as one or more of the following :

    Scope : ex : ( this ) , is no longer what it was because it is localized to something else
    Timing( Order Of Operations ) : ex : when you test locally , through apache , etc , or directly through the flash ide there is almost ZERO latency , unless of course you throttle your connection with download simulation etc. This is a problem because as you test, your application appears to work fine but then you get it on a server and things start happening strangely , because now it is a the mercy of the isp.
    Security : Permission sercurity sandbox stuff , sometimes very hard to resolve.
    Syntax : Typos , using the wrong class , silent errors, soft lock , etc.

    Very rarely are issues ever logic related , meaning that even following the procedure as intended , will not produce desired results.'

    So have you gone down that list , and thought about each of those things ? Have you tried step debugging , on the server , meaning literally put a trace statement before and after every problem line of code , and use a debugger to capture the output ?

    I mean to me personally , i would almost gaurantee its a order of operations thing. Probably somewhere in the code , you are trying to place something , or size something off of a value that does not exist yet. For example, Stage.

    stage.stageWidth works great assuming your object is a child of the caller , or has been added to the display list , otherwise , it dont work so good. So are you using event handlers , like on_added_to_stage , etc to keep track of the event cycle ?

    see if you can round up some more data about the specific errors , ie , exactly when they occur , is it browser specific , is it only in the flash ide , do they not show up once every 15 times. etc.

  3. #3
    Member
    Join Date
    Nov 2002
    Posts
    43
    Thank you for the reply, AttackRabbit.

    I found the source of one of the errors in my graphic display: in XML file alpha number was assigned twice - it broke my gradient box this time. The object was placed on stage (as the trace statement says), and didn't complain about anything, it just wasn't visible.

    As for the textfield size - I am still struggling.
    According to your advice I honestly checked every step in debugging mode (through all EnterFrames ), and everything worked fine, and showed correct data, and text was displayed properly. Putting traces after every line is my usual practice, and in this case it shows correct values. When I create .swf - text is broken again.

    I don't think that the order of operations error can be applied in this case, because this text display changes lines over several frames, each time comparing values. If it was late on the first frame, it would be catching up later (I think ).

    I managed to make the file work, publishing it from CS4 instead of CS3 (keeping .fla file as CS3 file). And when I check uploaded movie in the browser, I see it working or broken from different computers, all of which have the latest Flash plugin installed.

    I used this same class to expand and move the text field many times, and only in this case it is consistently broken if published from my Flash CS3. The difference with previous applications is that this time the initial height of the text field is dynamic - it depends on the height of the title (as shown in example). By the way, I don't know if you see example as broken or working properly.

    I hope I answered all your specific questions and maybe you will be able to point me to the source of the problem.
    Last edited by olka_sb; 11-02-2009 at 12:01 PM.

  4. #4
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    Well , one thing that could be affecting the way your application is running , is the fact the you are using the timeline , in congruently with script. The timeline can really mess things up , especially in as3. Im not saying dont use it , im just saying that is presents new issues into the development arena. You say that the textfield is changing sizes , and or content , over a series of frames. It could be that certian computers , on slower connections , with different profiles , could be causes the timeline to run slowed the your export setting , lets 30 fps. Sometimes , the timeline can hang up , causing you to lose scope or reference to stage objects.

  5. #5
    Member
    Join Date
    Nov 2002
    Posts
    43
    I was wrong in describing the behavior as going over multiple frames. In fact, the letters are added to the string (and the textbox height is compared and resized) on timer event. It is only the spring action that goes on "ENTER_FRAME". And the spring behaves correctly, changing Y property of the textbox.

    I don't use timeline frames in this application (only the first one), but I found that it is easier for me to create most of the graphics and textboxes on stage and put them in movieclips in the library, instead of creating them dynamically. They are much more maintainable this way, and I avoid most of the font embedding problems.

    Here is the function for updating the textfield. Does it have any obvious pitfalls?
    (txtNews is the textbox)
    PHP Code:
    function onTimerHandle(te:TimerEvent)
    {
        if(
    _count <= _strNews.length){
            
            var 
    subStr _strNews.substring(0_count); 
            
    txtNews.text subStr;
            
            if(
    txtNews.textHeight > (txtNews.height)){
                
    txtNews.height txtNews.textHeight 20;
                
    trace("txtNews.height = " txtNews.height);
                
    trace("txtNews.textHeight = " txtNews.textHeight);
                
    SpringXY.springXY(txtNews0txtNews.-_lineHeight);
            }
        
            
    _count++;
        }
        else {
            
    _timer.stop();
            
    trace("COMPLETE");
            
    trace("txtNews.height = " txtNews.height);
            
    dispatchEvent(new Event(Event.COMPLETE));
        }


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