Archive for the ‘Flash’ Category
Silly: Loading Text From XML
Made a silly mistake while loading text from an external XML file and I really really don’t want anybody to follow in my footsteps. :P
<strings>
<string id="someString">
<![CDATA[Sentence one\nSentence two]]>
</string>
</strings>
Does the above code looks flawed to you? Take a moment and look it through. :)
When you do the below AS2 codes in flash, what the \n does in the string is basically creating a newline, and thus "Sentence two" will appear below "Sentence one".
var txt:TextField = createTextField( "txt", _root.getNextHighestDepth(), 100, 100, 200, 200 );
txt.text = "Sentence one\nSentence two";
Happily, I ported all these original strings into an XML and got it loaded. What puzzled me was that, when these text were actually loaded, the \n didn’t work! The textfield simply displayed "Sentence one\nSentence two" without the newline. I sought help from a fellow colleague, Arul, and together, we still could not see what’s wrong with it. We left office without solving that "bug".
That night, Arul called to say, "Hey, with CDATA, we don’t need the \n! We simply just need to hit <enter>!" Immediately it struck me, oh ya! That’s the whole idea of using CDATA isn’t it? We got too engrossed with the wrong problem! :D
The next day, I changed all the \n to <enter> key, and expected things to work. Unfortunately though, the text did not turn out as expected. Flash had interpreted my <enter> in XML as double <enter>s when it’s being displayed on the textfield!
I sought Arul’s advice again and this is what I got. Flash interprets <enter> in external text sources as "\r\n", which explains the double <enter>s being rendered. So, what I actually had to do is to run through the string, strips off the "\r", and change it to "" (empty string).
Here’s the code that solves the above issue.
function _processString ( s:String ):String
{
if ( s.indexOf( "\r" ) ) s = s.split("\r").join("");
return s;
}
Hope this helps! ;)
Apollo, Moxie, Frogstar
I have no idea which one I should be more excited about! :D

Codename: Apollo
Name: Adobe Integrated Runtime (AIR)
Info: http://labs.adobe.com/technologies/air/
Description: Adobe® AIR™, formerly code-named Apollo, is a cross-operating system runtime that allows developers to use their existing web development skills to build and deploy rich Internet applications to the desktop.
Download Runtime (Beta) | Download SDK (Beta)

Codename: Moxie
Name: Flex 3
Info: http://labs.adobe.com/technologies/flex/
Description: Adobe® Flex™ 3 is a cross platform, open source framework for creating rich Internet applications that run identically in all major browsers and operating systems.
Download Builder (Beta) | Download SDK (Beta)

Codename: Frogstar
Name: Flash Player Update 3
Info: http://labs.adobe.com/technologies/flashplayer9/
Description: Adobe® Flash® Player is the high-performance, lightweight, highly expressive client runtime that delivers powerful and consistent user experiences across major operating systems, browsers, mobile phones, and devices.
Download Player (Beta)
Along with the above mentioned series of exciting betas, there’s also a contest going on called Adobe AIR Developer Derby! Read more here!
History Panel in Flash IDE
Ever tried the History Panel in Flash IDE? :)
Even though the history panel made it’s way into Flash since the MX 2004 days, I couldn’t find a good reason to use it. I mean, why would I need an extra panel to clutter up my screen estate when it’s already tough to juggle between the designer and developer related panels? I could easily do a Ctrl-Z(Undo) and Ctrl-Y(Redo) at any time that I want~
Well, times have changed. :D Since I’ve started messing around with JSFL, the history panel becomes the basic tool to learn JSFL commands. Don’t believe me? Follow me through then. ;)
1. In Flash IDE, go to Window –> Other Panels –> History (Ctrl-F10)
2. Click on the options button , under View, you should see a menu as follows:
The Default view that you see, shows the commands in normal layman English that everyone will understand. I have still yet to find any purpose with the Arguments in Panel view, so I’m gonna skip that. The JavaScript in Panel view is what we’re interested with.
3. Here’s the JavaScript in Panel view.
Did you notice the lines and lines of codes in the history panel now? Well those are JSFL codes! If there’s something that you wish to create for Flash IDE, and have no slightest idea where to begin, yet you know that there’s something similar been done already, you now know where to look!
Further Reads:
Using History and Flash Panels for Faster Development
Comments (3)
Leave a Comment
Leave a Comment