Austin Kottke's Code Site

Thoughts about Architecture – Java, C/C++, JS, Objective-C, Swift, Groovy, Grails, (RIP Flash)

January 11th, 2009

2009 – Actionscript 4?

8 Comments, actionscript, as2, flex, by austin.

Is there any kind of official word on whether there is going to be an actionscript 4? Im curious, as i develop mainly in as2.0 and some 3, but the jumps are huge. Is there just going to be actionscript 3 and small modifications to it as the player comes out?

Is it me, or did Colin Moock’s post stir up some feelings I have about flash 9 cs3?

I’ve used flash 8 for years and haven’t had a single problem with it except for the slow compile times. Now, adobe comes out with the new flash 9 cs3. Not only do they take out the data services, they add in this really odd way of generating classes and re-work the entire way the objects are created on the stage. This makes the workflow not as simple and generally re-works the flow.

So, my question on flash 9 cs3 is, why?

1. Why take out the data services? So we all move to flex?

I do flex projects, don’t get me wrong. I think flex is great for what it is. But the problem is in flash there is SOOO much more freedom because of assets and the timeline and animation and designs are so much easier to create.

2. Why make it more complex?

Why make every object it’s own class? What if we have a whole series of nested objects and don’t want to make every nested symbol a property in a file? Why not just simply let it be by itself… Keep it simple. The amount of times I’ve opened a project and not been able to compile it because of the “Automatically declare stage instances.” really gets on my nerves.

Error messages — Man – some of these just don’t make sense. They are verbose and unclear. In flash 8 it was simple.

3. Runtime mxml?

Why not make it easy to load in runtime mxml in flash 9 cs3?
This way we can load in xml on the fly and have it generate form data? I think this would be awesome and very useful.

4. How about a set of layout controls for flash 9 cs3? Use flash for what it’s good for…

Don’t get me wrong. I think as3 is cool and the speed factor is cool, but I think the workflow of flash 9 cs3 is what is the most important thing. Its not the language – with fdt 1.5 I felt complete with as2.0. Never had a problem, could do anything I wanted to do. With as3 its a bit of a headache sometime because of all of these changes.

I’ve been thinking a few things out on a dynamic layout engine written in xml. Flex mxml layouts are all precompiled. This makes it faster at loading, however it makes the layout xml not reside on disk which therefore makes it harder who do not know flex to make modifications.

We recently wrote an entire actionscript 2.0 layout engine which was an enormous amount of work, but we achieved the point of having other developers make modifications to the xml without them having to know the entire flex framework. So it was pretty cool.

But, the question is – what are the advantages and disadvantages of doing a new layout engine for flash 9 cs3. Is it worth it? My problem with the flex framework is that the movies always seem over bloated some times.

As an example, the actionscript 2.0 layout engine, the core layout code ended up being 60k, for full HBox, VBox, widget set.

What do you think?

I was on a project which required me to be able to take a 60 second intro that I did in flash and save it to dvd. I thought this would go smoothly now that flash 9 cs3 can export to quicktime video.

Little did I know that this was ultra lame as when cs3 records the movie to quicktime it screws up the frame rate and the .mov looked really bad. After a bunch of unsuccessful attempts at getting it right, I tried screen recorders (about 10) and couldn’t find any that worked right. Adobe needs to work a little harder on this one as DV pros need to be able to have a constant framerate which can be burned to DVD, etc – otherwise it’s almost impossible to recreate the flash movie.

The animation I made combines actionscript with frames, creating random actionscript particles and just recording it is very hard.

So I grabbed a program called MagicSWF and this recorded it at 22 frames per second to an AVI. It was smoothe as hell.

I then took the AVI into after effects and recomposited the quicktime video with a wav file and the AVI file and voila I had a flash animation prepared for going HD. And it looked almost as good as the original SWF. I could blow it up — stretching and the hardware scaling worked great.

Anyway, this is a tip for anyone trying to record a flash movie to HD.

Man, I want to move over to actionscript 3, but I still can’t do it yet. I have so much proficiency with actionscript 2 for the last 4 years that I can’t do it yet. I’m so used to it.

I want to do 3, but it seems like I have such a cool workflow right now with what I got, events, separation of responsibilities, that moving over to 3 seems like a waste of time. I mean, obviously I could do it, but the penetration isnt right yet. What do you think?

I’m also a bit weary because flash 9 cs3 still has issues. It’s not fully developed past 9.0.45 – if it had more penetration then I might jump over to using 3 and start fully developing in 3 now. But the component set in flash 9 cs3 only works with a player version as of a couple months ago.

I think the main jump that will push me over is now that FDT 3 is out I might start going hardcore actionscript 3 now.

The only thing I really liked about actionscript 2 was that FDT was so awesome and there were no bugs I couldn’t figure out in as2 – it’s just like everything could be overcome. It seems like because we’re building on an existing framework with flash 9 cs3 it might get a bit complicated. I’ve already seen some weird posts on flash 9 cs3 and no web service support that it’s not really worth it yet.

What are your guys thoughts?

One thing which I found in dealing with all of the flash 8 and flex projects is that in translations for styling of CSS and XML – I’ve found a pretty effective way to do this so that in projects you can have a stylesheet applied with variable font sizes and XML being parsed at the same time.

It starts out with the fact that you have a TextLoader class which loads in the text similar to:



public static function loadText( aStyleSheetPath:String, anInterfaceDir:String ):Void
{
Logger.log("INFO", TextLoader.toString() + " loading stylesheets and text.");
var styleSheetDir:String = aStyleSheetPath;
var interfaceDir:String = anInterfaceDir;
var currentLanguage:String = LanguageManager.getLanguage();
var cssFilePath:String = styleSheetDir + "stylesheet_" + currentLanguage + ".css" ;
var xmlFilePath:String = interfaceDir + "interface_" +currentLanguage+".xml";

/*---------------------------------------------------------------------
* Now we load in the stylesheet and once it is loaded we can then
* get the current interface and load this.
*---------------------------------------------------------------------*/

var stylesheet:TextField.StyleSheet = new TextField.StyleSheet();
stylesheet.load( cssFilePath );
stylesheet.onLoad = Delegate.create(TextLoader, function( status ) {
/*---------------------------------------------------------------------
* Once the stylesheet is loaded we then apply this to the text and
* then get it applied and the text loaded.
*---------------------------------------------------------------------*/

var interfaceTextXml:XML = new XML();
interfaceTextXml.ignoreWhite = true;
interfaceTextXml.load( xmlFilePath );
interfaceTextXml.onLoad = Delegate.create(TextLoader, function( isLoaded:Boolean ) {
if( isLoaded ) {
Logger.log("INFO", TextLoader.toString() + "Interface XML loaded ["+ xmlFilePath+"] " );
Logger.log("INFO", TextLoader.toString() + "StyleSheet CSS loaded ["+cssFilePath+"] " );
TextLoader.initialize(interfaceTextXml, stylesheet);
TextLoader.notifyListeners( new TextLoadedEvent() );
} else {
Logger.log("ERROR", TextLoader.toString() + "Unable to load xml ["+xmlFilePath+"] " );
}
});
});

}

This then loads in a stylesheet and an xml file. Then once the class loads I dispatch a notifyListeners event which then lets all other classes know that the stylesheet and xml are loaded.

I then make any listeners implement the right events.

The TextLoader class then has a method called renderText which then looks like the following:



public static function renderText( t:TextField, textFromXML:String, aTextId:String ):Void {
var cssEntry:String = "";
var defaultFont:String = "ID_DefaultFont";
t.styleSheet = styleSheet;

if( aTextId.indexOf("_he") == -1 )
{
t.embedFonts = true;
} else {
t.embedFonts = false;
}

t.html = true;
t.multiline= true;
/****************************************************************************
* Do a check if this particular class exists, if it doesn't then don't apply
* the class.
*************************************************************************/
cssEntry = ( styleSheet.getStyle( "."+ aTextId ) != undefined ) ? "class='"+aTextId+"'" : "" ;

/****************************************************************************
* Check if the active language is hebrew and forward this to the hebrew
* parsing engine to reverse the text.
*************************************************************************/
if( LanguageManager.getLanguage() == "he" )
{
t.embedFonts = false;
if( styleSheet.getStyle( "."+defaultFont ) && (styleSheet.getStyle( "."+ aTextId ) == undefined) ) {
t.htmlText = Hebrew.getConversion( textFromXML, t, defaultFont );
} else {
t.htmlText = Hebrew.getConversion( textFromXML, t, aTextId );
}
//Logger.log("DEBUG", "TextLoader().renderText - Hebrew ["+t.htmlText+"] ");
return;
}

// If there is a default font, set it to this but not if there is already
// a style defined.
if( styleSheet.getStyle( "."+defaultFont ) && (styleSheet.getStyle( "."+ aTextId ) == undefined) ) {
cssEntry = "class='"+defaultFont+"'";
}

t.htmlText = "

" + textFromXML + "

";
//Logger.log("INFO", "TextLoader().renderText - cssStyle ["+t.htmlText+"] ["+aTextId+"] ");
}

public static function getText( aTextId:String ):String {
return interfaceXML['idMap'][ aTextId ].firstChild.nodeValue.toString();
}


This allows for the renderText to then be used like TextLoader.renderText() which can then render the text applying the stylesheet similar to

— this then allows for a stylesheet to have an exact id applied to it.

This is pretty organized. Not bad a for a scientology coder, eh?


There is a new article from the blitz agency on how to use papervision with 3dsmax to skin properly.

Check out the article here

January 31st, 2007

Papervision – 3d car

No Comments, Uncategorized, by austin.

Carlos just posted a really cool demo on 3d in papervision. It looks like it has some neat effects:

Carlos car demo

January 29th, 2007

Charting library in as2

No Comments, Uncategorized, by austin.


Darren cook has released an open source project on source forge for charting. It looks pretty interesting. You can see it here:

http://dcook.org/work/charts/pie_chart_demo.html


Bytearray.org which has some incredibly cool experiments posted another bitchin project for doing page flipping. An engine which does some incredible parsing to create a realistic effect.

Check it out here: Check out the page flip effect here

Also another set of experiments on bump mapping: