Flash CS5 Cannot load SWF during “Test Movie” or Startup Screen is blank.
Flash CS5 Cannot load SWF during “Test Movie” or Startup Screen is blank., Posted in Actionscript 3, Flash, May 10th, 2011

On OSX this typically means that you have moved your “Home” folder to another drive or have another drive mounted on the root /Users folder.

To resolve this issue you will need to create a symbolic link to the /Users folder from the /Volumes folder.

In my scenario, my Volume Name is “Users” which is being mounted to /Users using fstab.

$ cd /Volumes
$ sudo ln -sf /Users ./Users

In FINDER, you can goto /Volumes and it will show a hard disk icon which will direct you to /Users folder.

This fixes an issue with the startup screen and the test/debug movie functionality.

Create a proper deep clone in AS3
Create a proper deep clone in AS3, Posted in Actionscript 3, Flash, July 25th, 2009

I’ve implemented this in com.emoten.core.data.JKDataObject in EmotenCore.swc

The [Transient] metadata is very important. ( keeps it from tying to infinitely clone itself )

I looked elsewhere and it seems that no-one has noticed that the [RemoteClass] metadata is required to reconstruct the class from its AMF-serialized state.

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[Transient]
		/**
		 * Creates a Clone of this class.
		 * <p>
		 * In order for your returned class to be typed correctly you must put the following
		 * above "public class"
		 * 
		 * <code>
		 * [RemoteClass(alias="com.emoten.core.data.JKDataObject")]
		 * </code>
		 * 
		 * Replacing "com.emoten.core.data.JKDataObject" with your class's FQN.
		 * 
		 * @return		A new copy of your class.
		 */
		public function clone():*
		{
			var ba:ByteArray = new ByteArray();
			ba.writeObject( this );
			ba.position = 0;
			return ba.readObject();
		}
?View Code ACTIONSCRIPT
1
2
        [RemoteClass(alias="com.emoten.core.data.JKDataObject")]
	public class JKDataObject extends JKObject implements Cloneable

UPDATE: Krilnon over at Kirupa made a good point I forgot to cover. The restrictions are that of the AMF specification. You cannot pass things like DisplayObjects and you cannot have required constructor arguments. If you don’t have those, your cool. The clone() functionality is only really intended for data models.
http://www.kirupa.com/forum/showpost.php?p=2489122&postcount=597

The replacement of EventDispatcher, 26% faster
The replacement of EventDispatcher, 26% faster, Posted in Actionscript 3, Flash, July 21st, 2009

I designed a pure ActionScript event method following a similar API of JKEvent. In most circumstances it just barely beats out the speed of the native EventDispatcher but EventDispatcher is left in the dust when you start timing the whole event lifecycle: “connect, dispatch, disconnect, dispatch”.

Cons: You don’t get priority

Pros: You get Silent Events, Argument Events, Remove All(event connections) from Observer, Remove All(event connections) from Sender. Its fast.

How it works: Its built using Dictionaries and LinkedLists. Turned out pretty good since I wrote it last week and never tried to actually run it until now.
Results

I recorded a variance of 0.5%+/-.

I licensed EmotenCore under LGPL and it is currently distributed as a compiled library.

Here is the License: License Here is the SWC: EmotenCore.swc Here is the docs: Emoten Core Docs

JKAbstractTranslatorLink & JKTranslatorTunnel
JKAbstractTranslatorLink & JKTranslatorTunnel, Posted in Actionscript 3, Flash, July 18th, 2009

I’ve built this methodology for allowing the easy design and implementation of sequential bi-directional data translation using the InputFlowConnector / InputFlowTerminator interface model.

I’ve uploaded the example here: http://labs.emoten.com/projects/Juki/JKAbstractTranslatorLink/TranslatorTunnelTest.html
Note: The Easy User Input Translator does not understand AM/PM.

My first reference implementation is using the class JKTranslatorTunnel as a two-way binding mechanism with translation. Essentially it makes a 2-3 line implementation to bind your Model object to some sort of View with translation. My example is a case where the Model contains a integer property representing Military time and the view displays Standard time. I’ve also attached a user-input translator that converts shorthand input to Standard time. This comes in handy so we can translate shorthand to standard then pass the standard to the translator that will translate that into military time and update the model. At the same time it will also format the View.

The reference implementation in Flex looks like this. “in1″, “in2″ are both TextInput UIControls. JKAbstractTranslatorLink is a LinkedListEntry. To add many items into the translation link just keep on populating the “.next” or “output”.
Emoten Core Docs

?View Code ACTIONSCRIPT
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<fx:Script>
        <![CDATA[
            import com.emoten.core.data.translators.JKEasyUserTimeInputTanslatorLink;
            import com.emoten.core.data.LinkedList;
            import com.emoten.core.data.JKAbstractTranslatorLink;
            import com.emoten.core.data.translators.JKMilitaryTimeTranslatorLink;
            import com.emoten.core.data.JKTranslatorTunnel;
 
            protected var _tunnel:JKTranslatorTunnel;
 
            public function onCompleteEvent( event:*=null ):void
            {
                var ls:JKAbstractTranslatorLink = new JKMilitaryTimeTranslatorLink();
                    ls.output( DirectionEnum.FORWARD, new JKEasyUserTimeInputTanslatorLink() );
 
                _tunnel = new JKTranslatorTunnel( this.in1, "text", this.in2, "text", ls );
 
 
            }
        ]]>
    </fx:Script>
Override Polymorphism versus me and a pot of coffee.
Override Polymorphism versus me and a pot of coffee., Posted in Actionscript 3, June 20th, 2009

JIRA SDK-16960
Java explanation of Late-Binding

The Issue
Subclassing has one purpose, to further specialize. If I want to extend my ‘FarmAnimal’ class and call it ‘Chicken’ that is specialization. If I extend ‘Real-Estate’ with ‘Condo’, that is specialization. So, what if I want to further restrict the acceptable properties of my sub-class? Override polymorphism allows us to redefine a inherited method from our super-class but doesn’t allow us to sub-specialize the method arguments(parameters) and return type. Why is this? If the specialized arguments and return type are fully type-safe against the requirements of the super-class then what is the problem?

The Example
Say my class ‘FarmAnimal’ has a method.

public clone():FarmAnimal {}

Now, I have a class ‘Chicken’ extends ‘FarmAnimal’. ‘Chicken’ has methods associated with it that do not exist in ‘FarmAnimal’. However, when I call chicken.clone() I still get a class instance typed FarmAnimal. Which is correct, it returns a Chicken object typed as FarmAnimal because override polymorphism says so. Now, every time I want to use methods special to Chicken. I have to retype the object as chicken.

chik:Chicken = chicken.clone() as Chicken;

This is ok. Now, what if clone() has a argument.

public FarmAnimal clone(mate FarmAnimal) {}

Thats cool but a Chicken can’t mate with a Pig so we’ve got to do something about this. Override polymorphism says we can’t change the arguments. Wouldn’t it be awesome if we could just re-define clone() as

public clone(mate:Chicken):Chicken {}

Well we can’t. What are our options? Interfaces have the same restrictions. We usually end up abandoning polymorphism completely in order to accomplish the task at hand or creating manual type checking on every override to prevent the wrong type of object being passed. All arguments aside, Chicken is a FarmAnimal so it is theoretically type-safe against the super’s version of makeSpawn. I don’t understand why the rules of polymorphism can’t be adapted to support this type of behavior.

UPDATE: Method Overloading as defined by Late-Binding in Java does partially do what I ask but does not hit the nail on the head because, ultimately, the original version is left intact whereas I would want to disallow it completely and would not be compatible when accessing typed as a Interface.

Any ideas? Hit me up on Twitter.

« Older Entries