<?xml version="1.0" encoding="utf-8" ?>

<rss version="2.0" 
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:admin="http://webns.net/mvcb/"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
   xmlns:wfw="http://wellformedweb.org/CommentAPI/"
   xmlns:content="http://purl.org/rss/1.0/modules/content/"
   >
<channel>
    <title>Anna Filina - ActionScript</title>
    <link>http://annafilina.com/blog/</link>
    <description></description>
    <dc:language>en</dc:language>
    <generator>Serendipity 1.1.2 - http://www.s9y.org/</generator>
    <pubDate>Sat, 08 Mar 2008 02:50:49 GMT</pubDate>

    <image>
        <url>http://annafilina.com/blog/templates/default/img/s9y_banner_small.png</url>
        <title>RSS: Anna Filina - ActionScript - </title>
        <link>http://annafilina.com/blog/</link>
        <width>100</width>
        <height>21</height>
    </image>

<item>
    <title>Data Binding expressions</title>
    <link>http://annafilina.com/blog/archives/29</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/29#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=29</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=29</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    In MXML, you may use expressions as a source of data binding.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;pre&gt;&amp;lt;mx:Label text=&quot;Beer&quot; visible=&quot;{age &gt;= 18}&quot; /&amp;gt;&lt;/pre&gt;The Label will only be displayed if the person is 18 or older.&lt;br /&gt;
&lt;br /&gt;
Did you try a more complex expression?&lt;br /&gt;
&lt;pre&gt;&amp;lt;mx:Label text=&quot;Beer&quot; visible=&quot;{age &gt;= 18 &amp;&amp;amp; gender == &#039;male&#039;}&quot; /&amp;gt;&lt;/pre&gt;Ah ha! You get a compiler error. Why? Because you&#039;re inside MXML and the &amp;amp; character is special.&lt;br /&gt;
&lt;br /&gt;
Solution: replace the &amp;amp; with &amp;#38;amp;&lt;br /&gt;
&lt;pre&gt;&amp;lt;mx:Label text=&quot;Beer&quot; visible=&quot;{age &gt;= 18 &amp;#38;amp&amp;#38;amp; gender == &#039;male&#039;}&quot; /&amp;gt;&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Fri, 07 Mar 2008 19:37:32 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/29</guid>
    
</item>
<item>
    <title>[Bindable] public override</title>
    <link>http://annafilina.com/blog/archives/28</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/28#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=28</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=28</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    I stumbled upon a compiler error when overriding a setter function with the Bindable metadata tag: &quot;overriding a function that is not marked for override&quot;&lt;br /&gt;
&lt;br /&gt;
The answer is short and simple: use --[Bindable] public override-- instead of --[Bindable] override public--&lt;br /&gt;
It may sound silly but the override actually has to come second in order for the compiler to interpret it properly in this particular situation. 
    </content:encoded>

    <pubDate>Fri, 07 Mar 2008 14:51:34 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/28</guid>
    
</item>
<item>
    <title>Instantiating and displaying MovieClips from loaded SWF</title>
    <link>http://annafilina.com/blog/archives/27</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/27#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=27</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=27</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    So you want to dynamically load a .swf, instantiate it and add to to a SWFLoader control.&lt;br /&gt;
&lt;br /&gt;
First, loading the .swf:&lt;br /&gt;
&lt;pre&gt;var loader:Loader = new Loader();&lt;br /&gt;
loader.load(url);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Now, to get its classes, we need to listen for the loading completion:&lt;br /&gt;
&lt;pre&gt;loader.addEventListener(Event.INIT, callbackFunction);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Once done, the callbackFunction will get and instantiate a class:&lt;br /&gt;
&lt;pre&gt;var mcClass:Class = &lt;br /&gt;
  loader.content.loaderInfo.applicationDomain.getDefinition(&quot;instanceName&quot;) as Class;&lt;br /&gt;
var mc:MovieClip = MovieClip(new mcClass());&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Hurray! Now we can add it to some appropriate container:&lt;br /&gt;
&lt;pre&gt;someSwfLoader.addChild(mc);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Now we want to scale it to fit the available space:&lt;br /&gt;
&lt;pre&gt;mc.scaleX = mc.scaleY = someSwfLoader.width / mc.width;&lt;/pre&gt;(a more complex algorithm may be used)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
A problem may arise if your clip content is not at 0,0 coordinates:&lt;br /&gt;
&lt;pre&gt;var bounds:Rectangle = mc.getBounds(Application.application.stage);&lt;br /&gt;
mc.x -= bounds.left &amp;#42; mc.scaleX;&lt;br /&gt;
mc.y -= bounds.top &amp;#42; mc.scaleX;&lt;/pre&gt;(if you have an ActionScript project instead of Flex, you&#039;ll need to access the stage by other means) 
    </content:encoded>

    <pubDate>Thu, 06 Mar 2008 18:03:47 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/27</guid>
    
</item>
<item>
    <title>AS3 data binding and component states</title>
    <link>http://annafilina.com/blog/archives/26</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/26#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=26</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=26</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    If you ever developed a complex data-driven application, you probably stumbled upon the data binding nightmare. Altough a great feature in Flex (a central one in my opinion), it lacks a bit of control.&lt;br /&gt;
&lt;br /&gt;
I needed a form with multiple states depending on the flavor of the edited object. This way, I could have common fields to all object types and add a couple of fields based on the object type. However, these fields&#039; values were bound to properties of the edited object. When selecting an object from the list, the fields should update themselves. Bindings are executed to set field values. Now, since I use form states, all fields are technically on the stage and all bindings will execute, regardless of the type of the selected object.&lt;br /&gt;
&lt;br /&gt;
Basic example&lt;br /&gt;
I have a form to edit animal properties (number of legs, head size, etc.)&lt;br /&gt;
I have some extra fields depending on the animal type (mammals have fur length and density, birds have wing span, etc.)&lt;br /&gt;
Every animal type has an associated state:&lt;br /&gt;
&lt;pre&gt;&amp;lt;mx:Form&amp;gt;&lt;br /&gt;	&amp;lt;mx:FormItem label=&amp;quot;Legs&amp;quot;&amp;gt;&lt;br /&gt;		&amp;lt;mx:TextInput text=&amp;quot;{animal.legs}&amp;quot;/&amp;gt;&lt;br /&gt;	&amp;lt;/mx:FormItem&amp;gt;&lt;br /&gt;	&amp;lt;mx:states&amp;gt;&lt;br /&gt;		&amp;lt;mx:State name=&amp;quot;mammal&amp;quot;&amp;gt;&lt;br /&gt;			&amp;lt;mx:AddChild position=&amp;quot;lastChild&amp;quot;&amp;gt;&lt;br /&gt;				&amp;lt;mx:FormItem label=&amp;quot;Fur length&amp;quot;&amp;gt;&lt;br /&gt;					&amp;lt;mx:TextInput text=&amp;quot;{Mammal(animal).furLength}&amp;quot;/&amp;gt;&lt;br /&gt;				&amp;lt;/mx:FormItem&amp;gt;&lt;br /&gt;			&amp;lt;/mx:AddChild&amp;gt;&lt;br /&gt;		&amp;lt;/mx:State&amp;gt;&lt;br /&gt;	&amp;lt;/mx:states&amp;gt;&lt;br /&gt;&amp;lt;/mx:Form&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The animal variable is set when an element is selected from a list. It can be an instance of a custom class Mammal or Bird which extends the Animal class. The state also changes according to the type selected. The problem occurs when I select a non-Mammal. The binding will execute, expecting a Mammal for the TextInput&#039;s text property. An error will be thrown saying that Bird (or other) could not convert to Mammal. This is to be expected, as the TextInput in question remains on the stage even if the state is invisible.&lt;br /&gt;
&lt;br /&gt;
What&#039;s the solution? Perhaps not the most neat, but it works: create extra variables for every type. Now you will have animal:Animal, mammal:Mammal and bird:Bird variables with their respective types. When an animal is selected, every type except the needed one is set to null. The animal variable still points to the selected animal. The MXML changes:&lt;br /&gt;
&lt;pre&gt;&amp;lt;mx:TextInput text=&amp;quot;{mammal.furLength}&amp;quot;/&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
What happens? When the bindings execute, if a Mammal is selected, the mammal variable is equal to a Mammal instance and everything is smooth. If a Bird is selected, the mammal variable is null and everything is smooth again. Hurray! It took me about 2 hours to figure out. If you have a better solution, please share. 
    </content:encoded>

    <pubDate>Thu, 28 Feb 2008 15:54:47 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/26</guid>
    
</item>
<item>
    <title>AIR Prerelease Tour</title>
    <link>http://annafilina.com/blog/archives/23</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/23#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=23</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=23</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    &lt;img src=&quot;http://www.adobe.com/devnet/air/images/air_logo2.jpg&quot; align=&quot;left&quot; style=&quot;margin: 5px 10px 10px 0&quot; /&gt;I attended a presentation on Flex and AIR yesterday. Mike Potter was unable to come and was replaced by LordAlex Leon. The presentation began with a long description of Adobe applications and their integration, but an hour later finally reached AIR. The part about AIR was quite short and did not teach me anything new.&lt;br /&gt;
&lt;br /&gt;
For those of you who don&#039;t know, AIR is coming out soon. It stands for Adobe Integrated Runtime (or RIA backwards). It allows you to run Flash/Flex apps on the desktop, read and write local files, query SQLite databases... all this cross-platform.&lt;br /&gt;
&lt;br /&gt;
I did learn something interesting from one of the slides though. BlazeDS has just been released under an LGPL licence. This technology allows real-time data pushing. For me, it means developing multiplayer games! 
    </content:encoded>

    <pubDate>Fri, 08 Feb 2008 14:40:46 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/23</guid>
    
</item>
<item>
    <title>FlexNativeMenu Tutorial &amp; Issues</title>
    <link>http://annafilina.com/blog/archives/21</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/21#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=21</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=21</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    So you want to have cool menus when you right-click an object in your flex app.&lt;br /&gt;
&lt;br /&gt;
First, create the FlexNativeMenu:&lt;br /&gt;
&lt;pre&gt;&lt;mx:FlexNativeMenu id=&quot;popupMenu&quot; labelField=&quot;text&quot; dataProvider=&quot;{popupMenuDataProvider}&quot; itemClick=&quot;popupMenuItemClick(event)&quot;&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The popupMenuDataProvider refers to an Arraycollection:&lt;br /&gt;
&lt;pre&gt;[Bindable] private var popupMenuDataProvider:ArrayCollection = &lt;br /&gt;
  new ArrayCollection([&lt;br /&gt;
    {text:&quot;Add something&quot;, action: &quot;add&quot;},&lt;br /&gt;
    {text:&quot;Remove something&quot;, action: &quot;remove&quot;}]);&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
The menu will be displayed within a listener such as rightClick on a component of your choice:&lt;br /&gt;
&lt;pre&gt;private function onRightClick(e:MouseEvent) {&lt;br /&gt;
  popupMenu.display(this.stage, e.stageX, e.stageY);&lt;br /&gt;
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Now we need to handle the click in the menu:&lt;br /&gt;
&lt;pre&gt;private function popupMenuClick(e:FlexNativeMenuEvent):void {&lt;br /&gt;
  txtLog.text = e.item.action;&lt;br /&gt;
}&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I ran into a bit of trouble when I tried to modify the dataProvider for the FlexNativeMenu component. It seems that the NativeMenu that it wraps does not receive the dataProvider updates. A solution was to reassign the dataProvider after a change:&lt;br /&gt;
&lt;pre&gt;popupMenuDataProvider.addItem({text:&quot;Edit something&quot;, action: &quot;edit&quot;});&lt;br /&gt;
popupMenu.dataProvider = popupMenuDataProvider&lt;/pre&gt; 
    </content:encoded>

    <pubDate>Tue, 05 Feb 2008 12:31:31 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/21</guid>
    
</item>
<item>
    <title>AS3 and RSL</title>
    <link>http://annafilina.com/blog/archives/20</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/20#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=20</wfw:comment>

    <slash:comments>4</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=20</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    Runtime Shared Libraries have been quite a puzzle for me for some time now. Here are a few problems that I solved:&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Exporting an imported asset&lt;/strong&gt;&lt;br /&gt;
When in AS3 you want to import an asset from a swf, you get it by its linkage name. What if this asset needs to be imported from another swf? Flash only allows you to import OR export an asset for Runtime Sharing. Simple: in Flash, encapsulate the imported asset in a MovieClip, and export the parent clip with a different linkage name.&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Load swf with RSL dependencies&lt;/strong&gt;&lt;br /&gt;
If you use the Loader class to load assets into your AS3 app and the source swf has RSL dependencies, the Loader might not fire a COMPLETE event. Although you expect your app to go look for dependencies in the path relative to your source swf, it actually looks for it relative to the app. Since it doesn&#039;t find it, your app has unpredictable behavior. Solution: move shared.swf to root, make an alias in root or change the linkage path in myassets.swf (might be tiresome).&lt;br /&gt;
&lt;br /&gt;
Here is an example:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;main.swf&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;assets&lt;/li&gt;&lt;br /&gt;
  &lt;ul&gt;&lt;li&gt;myassets.swf&lt;/li&gt;&lt;br /&gt;
   &lt;li&gt;shared.swf&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
myapp.swf is an AS3 app that loads myassets.swf&lt;br /&gt;
myassets.swf imports assets from shared.swf using the path &quot;./shared.swf&quot;&lt;br /&gt;
myapp.swf will look for dependencies in &quot;root/assets.swf&quot;, because that is the folder that contains the app.&lt;br /&gt;
&lt;br /&gt;
Solution:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;main.swf&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;shared.swf&lt;/li&gt;&lt;br /&gt;
&lt;li&gt;assets&lt;/li&gt;&lt;br /&gt;
  &lt;ul&gt;&lt;li&gt;myassets.swf&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
It took me a long time and a bit of luck to figure it out. Hopefully you will benefit from it. 
    </content:encoded>

    <pubDate>Fri, 25 Jan 2008 12:19:20 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/20</guid>
    
</item>
<item>
    <title>Working with types in AS3</title>
    <link>http://annafilina.com/blog/archives/19</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/19#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=19</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=19</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    ActionScript 3 is strong-typed, which is great to detect possible errors at compile-time. Here are a few tips for working with types.&lt;br /&gt;
&lt;br /&gt;
Type wildcard&lt;br /&gt;
&lt;pre&gt;var someVar:*;&lt;/pre&gt;&lt;br /&gt;
This is not recommended (can cause runtime errors) but is possible. I suggest using a common parent (DisplayObject, for example) whenever possible.&lt;br /&gt;
&lt;br /&gt;
Type checking&lt;br /&gt;
&lt;pre&gt;if (someVar is MovieClip) {}&lt;/pre&gt;&lt;br /&gt;
This is most useful. Example: getting the list of MovieClip children from a parent MovieClip (you don&#039;t want shapes and all). This line might prevent the whole app from blowing up in your face.&lt;br /&gt;
&lt;br /&gt;
Type casting&lt;br /&gt;
&lt;pre&gt;var item:Object = ComboBox(event.currentTarget).selectedItem;&lt;/pre&gt;&lt;br /&gt;
This will prevent type-mismatch complile errors. The same applies to simple types, such as int and uint. 
    </content:encoded>

    <pubDate>Thu, 24 Jan 2008 10:31:16 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/19</guid>
    
</item>
<item>
    <title>Touchless interface</title>
    <link>http://annafilina.com/blog/archives/18</link>
            <category>ActionScript</category>
    
    <comments>http://annafilina.com/blog/archives/18#comments</comments>
    <wfw:comment>http://annafilina.com/blog/wfwcomment.php?cid=18</wfw:comment>

    <slash:comments>0</slash:comments>
    <wfw:commentRss>http://annafilina.com/blog/rss.php?version=2.0&amp;type=comments&amp;cid=18</wfw:commentRss>
    

    <author>nospam@example.com (Anna)</author>
    <content:encoded>
    Here is a really cool, futuristic interface (remember Minority Report?). It uses IR emitting gloves, Wiimote and Flash.&lt;br /&gt;
&lt;br /&gt;
&lt;object width=&quot;425&quot; height=&quot;373&quot;&gt;&lt;param name=&quot;movie&quot; value=&quot;http://www.youtube.com/v/7CoJGrtVs4c&amp;rel=1&amp;border=1&quot;&gt;&lt;/param&gt;&lt;param name=&quot;wmode&quot; value=&quot;transparent&quot;&gt;&lt;/param&gt;&lt;embed src=&quot;http://www.youtube.com/v/7CoJGrtVs4c&amp;rel=1&amp;border=1&quot; type=&quot;application/x-shockwave-flash&quot; wmode=&quot;transparent&quot; width=&quot;425&quot; height=&quot;373&quot;&gt;&lt;/embed&gt;&lt;/object&gt; 
    </content:encoded>

    <pubDate>Wed, 23 Jan 2008 13:59:17 -0700</pubDate>
    <guid isPermaLink="false">http://annafilina.com/blog/archives/18</guid>
    
</item>

</channel>
</rss>