One Giant :Blog

Technology, Resources, Tips, Bugfixes, Web Design, Flash, AS3 (Actionscript), FlashDevelop, + more...

  • The Best Animation Engine for Flash / Flex - A Developer's Must-Have for Actionscript

    This is one of those things that is so good, you almost want to keep it to yourself just to have your own secret weapon.  Unfortunately, the generous author of such an ActionScript library, Jack Doyle, is such a good programmer and has given so much to the community that I feel obligated to pay it forward.

    IMHO- the Greensock Tweening Platform, TweenLite, TweenMax, etc... is the best animation engine and as3 utility library ever made.

    The Fastest.
    You can use the benchmarking application jack has on his site to test his engine with a particle generator script- check it's performance against Tweener, Flash, and other major tweening engines and the comparison is obvious- the particles fly fast and smooth at a much, MUCH higher count than any of the other engines can handle without looking like 3 fps.

    The Easiest.
    Besides being ridiculously easy to use with a quick 1-liner syntax, you can add event handlers and other interesting things all in line.  Here's a 1 second slide/fade in that cues a function called "nextAnimation()":

    TweenLite.to(anyObject, 1, {x: 100, ease: Strong.easeOut, alpha: 1, onComplete: nextAnimation} );

    The Smoothest.
    Watch your animations slide across the screen smoothly with plenty of well optimized easing classes included with the library.

    Thanks and kudos to Jack and his excellent work, the Greensock library has become a not-so-secret weapon for many flash developers. Check out the Greensock site to see how many other awesome classes you can get for things like full screen layouts, filter tweening, sequencing, easing, managing XML, and a lot more.

    Get the Greensock Tweening Platform and other great actionscript classes here.

  • Google Announces That Internet Explorer 6.0 Won't Be Supported

    Google's web developers must have rejoiced today with Google's public email announcement to Google Apps users that it will no longer be supporting Internet Explorer 6.0 for any of it's services, including services like Google Docs and Google Analytics.  Web developers are very familiar with what a pain developing for IE6 is, and how bad bugs Internet Explorer 6.0 can be- it will definitely not be missed.

    Quote from Google's email:

    "In order to continue to improve our products and deliver more sophisticated features and performance ... As a result, over the course of 2010, we will be phasing out support for Microsoft Internet Explorer 6.0 as well as other older browsers that are not supported by their own manufacturers."

    It's true- IE6 is so bad not even Microsoft wants to take any responsibility for it.  This will be good for non-savvy non-wev developer types too as IE6 is known to be a walking trojan virus, hijack, malware, adware, spyware basically every other (insert bad prefix)ware in existance.

    The truth is, you really should avoid using any version of Microsoft Internet Explorer.  More about how scary IE is in general (and why the German government banned it entirely) in a recent post:

    Yet Another Scary Reason to Avoid Internet Explorer - Use Firefox or Get Hacked

     


  • The Usual Suspects: 14 Common Web-Safe Fonts

    Here are common fonts that are considered "web-safe" - meaning they are commonly found on almost all Windows and Mac systems and will be displayed in most web browsers for these operating systems. Sorry Ubuntu, you're still just the random guy in the internet corner.  ;)

    Of course, if text is created as an image, font support is not an issue as the font is only needed on the computer that creates the image. Also, in Flash content any font can be "embedded" in the movie so to be supported wherever it is viewed. 

    Arial ~ Arial ~ Arial
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Verdana ~ Verdana - Verdana
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Tahoma ~ Tahoma - Tahoma
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Times New Roman ~ Times New Roman - Times New Roman
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Georgia ~ Georgia - Georgia
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Century Gothic ~ Century Gothic - Century Gothic
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Trebuchet MS ~ Trebuchet MS - Trebuchet MS
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Lucida Sans Unicode ~ Lucida Sans Unicode - Lucida Sans Unicode
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Arial Narrow ~ Arial Narrow - Arial Narrow
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Copperplate Gothic Light ~ Copperplate Gothic Light - Copperplate Gothic Light
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Lucida Console ~ Lucida Console - Lucida Console
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Courier New ~ Courier New - Courier New
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Impact ~ impact - impact
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

    Arial Black ~ Arial Black - Arial Black
    Lorem ipsum dolor sit amet, consectetur adipiscing elit. Maecenas volutpat velit ut magna porttitor eget suscipit tellus pellentesque. Fusce ac augue sem. Quisque consectetur sagittis quam vel suscipit. Duis ut enim leo. Suspendisse potenti. Etiam dolor justo, lobortis nec imperdiet facilisis, hendrerit vitae eros. Duis vitae suscipit ipsum.

  • FlashDevelop Not Tracing / No Output (Fix)

    AS3 FlashDevelop project tracing will only work if you have the Debugger version of FlashPlayer installed.  With the debugger version you will also get flash pop-up messages from the web browser when an error occurs in the flash movie.

    1)  You will need to select a TestMovie option that works, I use "play in popup" which seems to use the operating system's default browser.  Set FlashDevelop's "Test Movie" option here:

    FlashDevelop Top Menu -> Project -> Properties -> Output (tab) -> Test Movie (dropdown) -> Play in Popup

    2)  You need to install the debug flash player for the right browser, there is one for IE (internet explorer) and one for Netscape/Mozilla (FireFox).

    Since FlashDevelop uses your operating system's default web browser for the "play in popup", that's the one you want to install the debug player for (which should be FireFox if it isn't already - click here to see how to set default browser in Vista).  Install it for both, if you want.  I like to have one browser with debugger version and one with regular flash player just for testing both.

    You can download the debugger player from adobe here:

    Adobe Flash Player 10 — Debugger Versions (aka debug players or content debuggers)

  • Organize Your Windows Desktop Icons Quick and Easy

    I've tried a few different desktop organizers for windows, and this one is, in my opinion, the best (easiest, quickest, simplest, nice looking)

    http://www.stardock.com/products/fences/

     It's a great app that will allow you to drag out labeled boxes on your desktop so that you can drop desktop icons into groups.  You can then drag, size, move and place the groups as you wish around your desktop and it will retain your layout after startup.

    My desktop used to be cluttered and now it is beautiful.  :)

  • How To Set Firefox as Default Browser in Windows Vista

    To set FireFox as the default browser for Windows, open firefox and go to:

    Tools -> Options -> Advanced -> General (tab)   and check the box that says "Always check to see if FireFox is the default browser on startup", and then click "check now"

    If firefox says something like "Firefox is already the default browser" but another browser loads sometimes, use this method to force FireFox as the default browser:

    1) Open "Run..." in windows (start menu, type run, press enter)

    2) Copy / paste this into the run text box:    firefox.exe -silent -setDefaultBrowser
    (and then press enter or click OK)

    reference page:  http://kb.mozillazine.org/Default_browser

  • How to get music off an iPod or iPhone 3g / 3gs (firmware 2.x+)

    Ah Apple, you jerks!  With all of your smug commercials about how much better your products are than Microsoft, you would think iTunes would be less annoying!  Nope!  Just when you thought you had a workable solution to an annoying problem, Apple goes and makes it even more annoying, all over again.  Doht!  Don't worry, thanks to the rockstar nerds of the world, there will always be new workable solutions.

    *This is  a follow up to the previous article  addressing the same problem (1st gen iphone or ipod devices):
    (http://www.onegiantmedia.com/how-to-get-music-off-an-ipod-or-iphone)

    Problem:

    How to get your music off your iPhone or iPod so that you may take the music to another computer- this may be necessary if you have an existing iPhone/iPod that was synced with one computer, and then:

    • You get a new computer and want your music from your iPod / iPhone
    • You have to reformat your hard drive and your only copy of your music is on the iPhone/iPod
    • You want to bring your music to another computer via iPhone/iPod
    • You want to merge your iTunes library from home with your iTunes library at work (new computer)
    • You want to back up your entire device

    The problem is, on the 2nd or new computer (not the original synced computer) iTunes will want to erase the device to sync up.  Lame!

    Solution 1:  Copy all music off iPhone / iPod manually, reimport wherever you want

    1)  Use alternate software (options listed below) to copy all of your music from your iPhone down onto your computer safely (see links below)
    2) Let iTunes do it's annoying business (connect your device, activate your acct, sync/erase all of your music off the device)
    3) Import all of your music that you manually saved to your computer back into itunes
    4) Re-sync now that your entire library is in iTunes, getting it all back onto the device

    Software Options:

    There are many new software packages for purchase around $20, but there are still some free options too.

    Wikipedia's list of Software - most can copy music off your iPod / iPhone:

    Free software recommended (in wiki list):

    Free software recommended (not in wiki list):

    Pay software recommended (in wiki):

    Solution 2:  Hack itunes so that it will sync with both computers

    You will need the original sync'd computer with itunes still on it to pull your registration key, then insert it manually into the new computer's itunes via hex editor.  It's easier than it sounds, just follow the instructions carefully.

    Great article / instructions here:  

    http://www.andrewgrant.org/2008/03/30/how-to-sync-an-iphone-with-two-or-more-computers.html

    Note:  This is only if you want to use the same account on multiple computers, don't do this to a friend's computer or their itunes will be permanently on your account.  If you want to just share your whole library use steps 1 and 2 from Solution 1.

  • XML to Flash / Flex text field - line break instead of \n or <br>

    I was trying to put a line break in my XML file and wasn't working.  I came across this blog and finally found the answer!

     And the answer is...

    &#xD;

    Hope this helps!

    Found here: http://viviangper.wordpress.com/2008/06/17/xml-line-break-in-flash/ 

  • Parsing XML in Actionscript (AS2 / AS3, Flash / Flex) - the EASY way

    AS2

    If you've come from a longer history with Actionscript & XML. you may have written some pretty elaborate / gnarly AS1/AS2 XML parsers in the past- and you probably know what a pain that can be.  (especially when someone tells you to change the spec!)

    If you are stuck in corporate America and thus still working in AS2, save yourself more headaches and get Jack Doyle's Greensock XML manager.  XPATH is great too, but this might be easier.  It allows you to convert XML to Object with arrays and properties, and reference nodes by name.  All in all, it's very well documented / explained with examples and very easy to use- yet another useful and stable class from Jack:

    http://blog.greensock.com/xmlparseras2/

    AS3

    If you are in AS3, you don't need much to parse XML anymore, thanks to E4X (an ECMA script approach to XML).  In fact...

    ...if you've written any for() loops to parse XML, you've already gone too far!!!

     

    Here's a great tutorial on E4X from Senocular:

    http://www.senocular.com/flash/tutorials/as3withflashcs3/?page=4#e4x 

    Here's another at dispatchEvent:

    http://dispatchevent.org/roger/as3-e4x-rundown/

  • HTML CSS Tip: Horizontal List - UL LI tags

     

    To make an HTML list appear horizontally instead of stacked vertically, simpy set the list item tag's display style to "inline" in your CSS file or style attribute, and be sure your container element's width is wide enough for the list items to be stacked horizontally.

    example:

    .exHorizontalListClass {

      /* Horizontal List Items: */ 
      display: inline;

      /* To remove bullets: */
      list-style: none;

    }

     

  • Shorter than Shortcuts - Best Free Windows App - A Must Have for Computer Professionals

    Make Windows way, way less annoying.



    http://humanized.com/enso/

    Enso is a free application for windows that allows you to use your computer with instant short-cut commands that you can type in plain English while in any (or no) application to do things that usually entire reaching for the mouse, shaking it around to find it, going to the start menu, scanning the list, maybe go to submenus, etc... etc... etc...  FORGET THAT

    For all my MacBoy friends, let me start by saying mac already has this basically built in with CTRL+SPACE or whatever... CONGRATULATIONS - I like Enso better :-P

    If you're a daily Windows Vista user, you may know you can press the "window" key and then type into the search area to find things quickly.  This is OK, but kind of slow and you can't make custom commands or type out Enlgish like "open Firefox".

    If you are comfortable typing on a keyboard, and you don't have this application, you're missing out!  (and probably wasting tons of time a couple seconds at a time, hundreds of times a day, every day).

    Without touching your mouse, you can set easy commands to do things like:

    • open a program
    • google something
    • google-map
    • spellcheck something
    • find on wikipedia, ask.com, yahoo, youtube..
    • get the definition of a word
    • close a window
    • switch to a window
    • minimize
    • maximize
    • count words highlighted
    • count characters highlighted
    • calculate math equations (eg: 23423432 * 713.4 - 20938123) on the spot in any text in any window
    • skip to the next track in itunes, winamp, pandora's box, others...
    • play an artist by name in compatible players (like itunes)
    • play song by name
    • mute/unmute
    • set new commands
    • remove old commands
    • + a lot more...

    Many of these commands will use any currently highlighted text in any program.

    Use case example: 

    Your scanning a Microsoft Word document and you don't know the definition - highlight it, hold CAPSLOCK, and type "define" or "google" and release.  You won't even have to type the whole word before it guesses which command you were intending.  Your browser opens right to the page you needed, you read it, hold CAPSLOCK and type "cl" and let go- it guesses "close" your browser closes and your back.  Then as a bonus you hold CAPSLOCK and type "Next Tr" and let go, it guesses "Next Track" and your music changes to the next song. 

    AWESOME.

    I've probably typed "open My Doc" for My Documents about 500 times in the past couple months, and never had to find the icon in my start menu or on my desktop. 

    Do I even have a start menu? :)

    It takes some getting used to but not much (a day or two of using it). You'll be amazed you ever used a windows computer without it!

  • PHP Opening Posted

    Are you an expert PHP developer available for part-time work?  Please review our requirements on our openings page and let us know if you sound like a match!

  • AS3 MovieClip / Sprite / DisplayObejct Filters does not work like Array - .push() .pop() .slice()

    To apply effects filters to display objects (sprites, movie clips, etc) ActionScript 3 display objects have a nice little .filters property that allows you to set an Array of effects filters at runtime.  This is great for effects like Bevel, Drop Shadow, Glow, Blur, Inner Shadow, KnockOut, etc..

    ex:

    (assuming you've created the filter instances myBevelFilter, myGlowFilter, myDropShadowFilter)

    1) Works:

    _myMovieClip.filters = [myBevelFilter, myGlowFilter, myDropShadowFilter];

    2) Works:

    var fx:Array = new Array();
    fx.push(myBevelFilter);
    fx.push(myGlowFilter);
    fx.push(myDropShadowFilter);

    _myMovieClip.filters = fX;

    3) Doesn't Work:

     _myMovieClip.filters.push(myBevelFilter);
     _myMovieClip.filters.push(myGlowFilter);
     _myMovieClip.filters.push(myDropShadowFilter);

    You're not doing anything wrong, this is just how Adobe has created the filters property.  From AS3 docs:

    Changing filters at run time

    If a display object already has one or more filters applied to it, you can’t change the set of filters by adding additional filters to or removing filters from the filters property array. Instead, to add to or change the set of filters being applied, you must make your changes to a separate array, then assign that array to the filters property of the display object for the filters to be applied to the object. The simplest way to do this is to read the filters property array into an Array variable and make your modifications to this temporary array. You then reassign this array back to the filters property of the display object. In more complex cases, you might need to keep a separate master array of filters. You make any changes to that master filter array, and reassign the master array to the display object’s filters property after each change.

    http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7db3.html

    AS3 Filters:

    http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7dba.html

  • Common Flash/Flex AS3 Mistake... Loader Doesn't Work - No Events Working When Loading External URLs

    If you seem to have everything set up correctly with a Loader class instance, but there's just nothing happening... You probably made the same mistake I've made a number of times when coding a little too quickly:  attaching the event listeners to the Loader object itself, rather than your loader's property: .contentLoaderInfo - where all the information and events on loading status actually occur.

    For example...

     The Common Wrong Way:


    var myLoader:Loader = new Loader();
    myLoader.addEventListener(Event.COMPLETE, onLoadComplete);
    myLoader.load( new URLRequest("externalExampleImage.jpg") );

    ...and then you wonder why the event never fires, there is no error, and you know your image is there... doht!

    The Right Way:


    var myLoader:Loader = new Loader();
    myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
    myLoader.load( new URLRequest("externalExampleImage.jpg") );

    ... works every time!

    Adobe Documentation Reference:

    http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/flash/display/LoaderInfo.html

  • FlashDevelop Error Creating New AS3 Projects in an Existing Project's Directory

    If you try to create a new as3 project in a directory of an existing project, you may get this error:

    Could not create the requested project:  The file '...\expressInstall.swf' already exists.

    ...or similar error for "swfobject.js'

    Careful!Don't delete these files or remove bin/ and create a new project b/c it will overwrite existing classes like Main.as!

    Your best bet is to copy your the entire existing project directory to a new directory and create a new project there. Then, copy over whatever is overwritten into the new project directory, and test build.

  • Hex Codes: The ONE Website You Need

     

    Do you find yourself always looking for hex codes?  Either a specific color code, matching colors, etc.?  If so, bookmark this page right now!!  http://kuler.adobe.com/#create/fromacolor

     Your google searches for hex codes ends now. :) Enjoy!

     

     

  • Get Rid of Annoying Outlook Reminders That Cannot Be Removed / Found

    This really, really annoying bug started popping up for me not too long ago when a co-worker created some reoccurring  event in outlook that I accepted as attending, and at some point she must have removed it incorrectly or something, because it would always come up as "Canceled:" but when I would try to dismiss or OK it... I would always get this error message prompt (every freakin' day!):

    "Cannot turn off the reminder.  You may be reminded again.  Cannot locate recurrence information for this appointment"

    Solutions:

    1)  /cleanreminders

    First, try launching Outlook.exe with the “/cleanreminders” command line argument:

    C:\Program Files\Microsoft Office\Office12\OUTLOOK.EXE /cleanreminders

    2) Use Microsoft utility MFCMAPI manually remove the entry (not hard at all)

    If solution 1 does not work
    Download MFCMAPI tool from http://support.microsoft.com/?ID=291794

    1. Run MFCMAPI on the desktop

    2. Go to Session->Logon and Display Store Table

    3. Select your profile by name

    4. Right click Mailbox and choose “Open Store”

    5. Expand “Root Container”

    6. Find & Right click “Reminders” and select “Open Contents Table”

    7. New Window Launches with list of Reminders

    8. Select only the reminder items that you want to remove, Right click and select “Delete Message”

    9. Close MFCMAPI

    Restart outlook- you should not have those annoying reminders any more.

  • Flash/Flex AS3 - How to Select / Highlight All Text in an Input Text Field On Click

    This took forever to google for some reason...

    Issue:

    You want an input textbox to highlight everything in it when the user clicks it (on focus). Problem is, when the user clicks the text box places the carat, thus un-highlighting the text. I could be wrong, but the second problem seems to be that if you use the FocusEvent.FOCUS_IN event setting selection doesn't work, so you're forced to use MouseEvent.CLICK event... but if you highlight the entire box every time the user clicks, the user can't select any text because it always just highlights the entire box... also, once the box has been highlighted once, you want the user to be able to place the carat without re-selecting the entire box again.

    Solution:

    What you want to do is check if the user is highlighting or if the box was already highlighted since last focus, and if not, stop flash player from putting the carat at the location clicked with event.preventDefault() function, and then set selection from beginning to end. Event.preventDefault() is a sneaky little function you call right on the event object in your event handler, and it prevents whatever the default actions would be for that event (in this case, clear selected text and place carat)

    as3 code example:

    // assuming you have a textbox input called _myTextInputBox
    
    import flash.events.FocusEvent;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    
    _myTextInputBox.addEventListener(MouseEvent.CLICK, onClickTextBox);
    _myTextInputBox.addEventListener(FocusEvent.FOCUS_OUT, onTextBoxLoseFocus);
    
    var _highlightTextOnClick:Boolean = true;
    
    function onClickTextBox(e:Event):void {
    
      var didUserHighlight:Boolean = Boolean(e.target.selectionBeginIndex != e.target.selectionEndIndex);
    			
      if ( _highlightTextOnClick && !didUserHighlight)  {
        e.preventDefault();
        e.target.setSelection(0, e.target.text.length);
        _highlightTextOnClick = false;
      }
    
    }
    
    function onTextBoxLoseFocus(e:FocusEvent):void 
    {
      _highlightTextOnClick = true;
    }
    
  • AS3 / Flash / FlashDevelop - scaleY = 0 ... Bug with scaleY value on Custom Class

    I haven't found much on the web about this...

    Issue:

    Has anyone experienced an issue where a custom class extending a library MovieClip instantiated on stage has an initial scaleY value of 0, but scaleX is 1?

    example:

    - class MovieClipAndThenSome extends
    - class MovieClipPlus extends class FL_MCFromLibrary
    - class FL_MCFromLibrary is generated by flash when not found in the classpath (it is the linkage name of a library movie clip in flash) and extends MovieClip

    //as3 example..

    var newCustomMC:MovieClipAndThenSome = stage.addChild(new MovieClipAndThenSome());

    trace(" >> scaleX: " + newCustomMC.scaleX); // output: >> scaleX: 1
    trace(" >> scaleY: " + newCustomMC.scaleY);// output: >> scaleY: 0


    is this a known flash bug?

    solution:

    an obvious workaround... call this line after object is added to stage..

    this.scaleY = this.scaleX = 1;

  • AS3 - Load a Remote Image from Any URL / Domain with No Stupid Security Sandbox Errors

    Issue:

    You want to load an image from an unkown external URL. It works on your computer... Sandbox Security error online (and/or the annoying images just showing up as solid white feature).

    By default, Flash wants a crossdomain.xml file on the server you are loading from, but let's say there is none, because it's probably not your website.  Well, then the flash player isn't going to let you take that data and do what you want with it.

    Attempting to do so will give you some error similar to:

    *** Security Sandbox Violation ***
    SecurityDomain 'http://www.designercolin.com/temp/ispire/get_boards.php' tried to access incompatible context 'somewebsite.com/someImage_here.jpg'

    Half-Solution (aka the adobe way):

    According to adobe's docs you need to do a couple things to work around this (to not access this remote data directly)- bypass policy file, and don't manipulate it in any way (ahem-lame).  See the next solution if you need to access or smooth the bitmap data.

    1)  Use a LoaderContext instance with checkPolicyFile=false - this will tell it not to worry about the cross-domain issue and use the loader context object as 2nd parameter in Loader.load() call

    var lc:LoaderContext = new LoaderContext();
    lc.checkPolicyFile = false; // bypass security sandbox / policy file - does this effect quality when scaling?

    _myLoader = new Loader();
    _myLoader.contentLoaderInfo.addEventListener(Event.INIT, onImageLoaded);

    // load new url
    _myURLRequest = new URLRequest($url);
    _myLoader.load(_myURLRequest, lc);

     

    2) Show the loaded image - This is where you may get the error (this is what had me pulling my hair out) 

    Even with the checkPolicyFile = false set, I had to add the loader to a SPRITE (not movieclip, and not the loader content!), as this would be accessing data outside the sandbox

    private function onImageLoaded($e:Event):void
    {
      _innerImage = this.addChild(new Sprite());
      //_innerImage.addChild($e.currentTarget.content); // doesn't work. sandbox security error
      _innerImage.addChild(_myLoader);
    }

    ...by doing this, you will not have accessed this image data in any way to get the error, so you can load the image data but if you need to access the bitmapdata directly (or create a movie clip apparently?), I don't think it will work.

    I'm not sure exactly why adding to a Sprite() instead of MovieClip() allowed it to work for me, they both are DisplayObjects, maybe there is something in the MovieClip constructor that accesses the image data... Whatever, it's stupid that you have to do that in the first place, so why would the method make sense!  See the other / better solution below..

    Quality Question- for remote image data without policy file:

    What I really want to know is (for printing purposes) - using this method, since there is no access directly to the image data, when you scale the image... does it not render with smoothing / anti-aliasing?  Is it poor quality outside of native dimensions?  Or is it basically the same quality as scaling a local image within security domain?  Final conclusion is that it's better to use a proxy if the image has to be anything but native (original size/scale)...

     

    Better Solution- Go Around It

    Well, since flash is finicky and now has had different bugs with different flash player versions, the smart thing to do is cut your losses and just go around this issue.  A local .php file or similar service as a proxy to cross-domains URLs will do the trick and retrieve the images and flash will basically think they were hosted locally.

    Then, in flash you should set up a class that will prefix URLs for you, maybe extend the URLLoader...

    However you do it, you want to prefix remote URLs with your proxy URL, and pass along the intended URL something like:

    http://www.YourFlashSite.com/proxy/getimage.php?url=http://someOtherWebsite.com/someImage.jpg

    On creating the PHP proxy to retrieve the file.. theres a few you can find with google but i have had issues with the majority of them-

    One common proxy issue with Flash is that if your progressEvent.bytesTotal is 0 (making your preloader show Infinity) it may be because your server has gzip enabled.  You can use an app like Charles to see what your http activity looks like and see if there is gzip compression on the responses... turn off gzip for your proxy file and you're golden.

  • Listen to Pandora Without a Web Browser (windows desktop app / tray widget)

    I love Pandora for listening to music.  But, I hate having to keep a tab open for it all day.  Luckily, thanks to CFDan, now I have Pandora in my windows taskbar with a nice right-click menu.

    Get Pandora's Box for Windows Here (free)

    Many Thanks to cfdan!

  • Migrating AS2 to AS3 - Easiest "Bring to Front" / "Stay On Top" for a MovieClip

    In the days of AS2, the quick and dirty little line...

       mc.swapDepths(mc.parent.getNextHighestDepth()); 

    ...would do the trick, and the MC would be on top.

    In AS3 there is no "getNextHighestDepth" function.  Instead, there is a display stack with no missing slots.

    Thus, this is the easiest way to set a MovieClip (or Sprite or DisplayObject, for that matter) to the foremost depth of it's parent container:

    public function bringMCToFront($mc:MovieClip){

        $mc.parent.setChildIndex($mc, $mc.parent.numChildren-1);
    }

    or, as a dirty 1 liner:

      anyMC.parent.setChildIndex(anyMC, anyMC.parent.numChildren-1);

    * remember this only sets $mc to the highest depth within it's parent MC.  If the parent MC is beneath other MC's in the same level, the parent will need to have it's depth set as well.  Same for the parent's parent, and so on...

    Cheers.

  • Flash/Flex AS3 BugFix: Error: #1074: Illegal write to read-only property String on global.

    #1074: Illegal write to read-only property String on global.

    What an extremely obscure description that is.  Most google results say something or other about setting "application domain".  This can be an issue if you are using / loading external files across domains...

    In my case, this issue was simply a loose type declaration:

     ex:

    _baseURL:String = _domainURL;

     left over :String from when it was a function scope variable...  removing the :String fixed error.

  • How to Kill a Frozen iPhone App (v 3.0+)

     

    In version 2.X of the iPhone software, if an app froze, pressing/holding the main home button would kill the app process and un-freeze your phone.  In 3.0... not so much.  This is actually because after the 3.0 software update, this was changed.  Now, to force an app to close to unfreeze your phone, you must:

    1) Hold the power button (top right) until the red power off slider appears.

    2) Hold down the home button to quit the unresponsive application and return to the main home screen.

     

  • Image -> AS3 -> BitmapData -> JPG -> PHP -> Server / Hard Drive

    How to encode Bitmap Data as a JPG and save it a remote server:

    (and/or back down to your hard drive)  

    hint:  Unless you want to re-invent the wheel, get AS3 CoreLib actionscript library from google docs  ...

    Great articles, really clear / short and helped me breeze through getting this working compared to some other tutorials that came up first.

    http://actionscript-blog.imaginationdev.com/5/save-jpg-jpeg-png-bmp-image-action-script-3/

    http://designreviver.com/tutorials/actionscript-3-jpeg-encoder-revealed-saving-images-from-flash/

    enjoy.

RSS Feed