Blog posts


  • Actionscript: How to check if a variable is undefined?

    September 10, 2009 | Tags: Actionscript, AS3, Flash, Snippet
    As null isn't the same thing as having a variable undefined. How then do you check if it's defined or not? Well, here's the answer:
    if(!myVariable) {
    trace("it's not defined");
    }

  • ASP.NET: Regular expression validator for e-mail address

    September 09, 2009 | Tags: ASP.NET, Validation, Snippet
    A snippet for using the RegularExpressionValidator to validate if form field holds a correct e-mail address:
    <asp:RegularExpressionValidator ControlToValidate=
    "EmailField" ValidationExpression=
    "\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" Text="*"
    ErrorMessage="Not a valid e-mail address" runat="server" />

  • Changed rotated dynamic textfield dissapears and how to solve it

    March 20, 2009 | Tags: Actionscript, AS3, Troubleshooting, Flash
    Text in Flash is a very special chapter. Static textfields works well, but once you begin to change the text dynamicly at runtime anything could happen. I recently wanted to change the text in a dynamic textfield that was slightly rotated. The text that was entered in the Flash IDE appeared as it should but once changed the textfield dissapeared completely.

    After some searching I found a couple of pages that suggested it could be a font embed problem. http://mc-computing.com/languages/ActionScript/Rotating_Text.html has some good info on that. But the problem remained since I used "Anti-alias for readability" and had the font embedded.

    Then the solution to an older problem struck me. I had prior had trouble with keeping the font format while changing the text. Appearently things like letter spacing etc is removed once the new text is set. The solution to this is to store away the font format, change the text and then set the font format back. I tested if that could be the case also for rotated text and it was!
    import flash.text.TextFormat;

    var tf:TextFormat = txtHeader.getTextFormat();
    txtHeader.text = "MY NEW TEXT";
    txtHeader.setTextFormat(tf);

  • ASP.NET: Client side validation don't work in Firefox (and solution)

    February 12, 2009 | Tags: ASP.NET, Troubleshooting
    Today we noticed a curious bug in a web application we're working on. The client side validation (RequiredField validator etc) worked perfectly fine in Internet Explorer, but not at all in Firefox! My first reaction was to check for javascript errors as they tend to prevent other functions to run properly. The error console was empty.

    What it turned out to be is the way ASP.NET renders XHTML. This is controlled within the web.config:
    <xhtmlconformance mode="Legacy"/>
    Our problem was that the automaticly generated line said Legacy, what actually means ASP.NET 1.1 compatible. As we uses strict XHTML 1.0 a better choice would be:
    <xhtmlconformance mode="Strict"/>
    And then, lo and behold, after changing mode to Strict the client side validation worked perfectly in Firefox!!

    More about xhtmlConformance:
    http://msdn.microsoft.com/en-us/library/ms228268.aspx
    
    

  • Flash: Can't save file (and solution)

    February 12, 2009 | Tags: Troubleshooting, Flash
    Got a feeling of panic when, after half a day, I tried to save my work in Flash and was met by the following error message:

    "The file may be read-only or is already open in another application.
    Save using a different name, or close the document and try again."

    However saving using a different name resulted in the exact same message.

    So how to come around this bug and save hours of work? Well here's the solution:

    1) Go to the main scene the file you cannot save.
    2) Select all frames over all layers.
    3) Right click and select to "Copy Frames".
    4) Now, open a new project and select the first frame in it.
    5) Right click and select "Paste Frames".
    6) Voila, now you can save your new file!