Archive for the ‘ AS3 ’ Category

NEW: Papervision3D Component 2.1

I’ve just posted the latest version of the component for the Flash IDE:

http://code.google.com/p/papervision3d/downloads/list

It’s been a long long wait and I’ve been handing the component out at Flash conferences and classes that I’ve taught, but was waiting for Flash CS4 to be fixed to work with my component.  CS4 has alot of known issues with components, Adobe is well aware of the issues that cause my component not to work and I’m sure it’ll be fixed down the road sometime.

So for now, the component will only work in Flash CS3 IDE.

New Features and bug fixes:

1.  new Materials panel – now you can deal with your materials through this panel that Andy Zupko added oh so long ago 😉

2.  Code Templates:  I’ve put in 2 templates for writing code against the component all flushed out with all the event listeners etc.

3.  Many bugs fixed

Thanks all, and enjoy!

John

Flash on Tap Slides:

Flash on Tap was a GREAT conference – unbeleivably cool and laid back (at least for me it was).  It was truly great to see old friends again and hang out a bit.  Last time I went to a conference I was so stressed about about getting hours in on a project, I couldn’t enjoy Brighton.  It was a shame really.  But this time around, I really took the time to enjoy myself and just do what I wanted.  The class went great on Thursday, and the 3D panel discussion today was very cool.  I was nice to get to voice some opinions about about Flash, Unity and 3D in general.

Anyway, I rushed through my Papervision to Unity to iPhone session like mad at the end and promised I’d post the slides, so click on the image above or here.  I’d clearly planned to talk about way too much in my presentation, but I was at least able to do the sample demo app I’d put together of the obstacle course.  I was happy that people enjoyed seeing Unity in action and creating a simple game, but was bummed I didn’t even get the chance to show some scripting so they could see how very similar Unity’s Javascript is to ActionScript3.

There’s always next time!!

Seb’s Papervision black hole

THIS rocks!  I just had to give a shout out to Seb for giving me my first Papervision3D inspiration of the year!

I’d try to explain it, but I think you should just check it out for yourself 😉


Setting focus on TextFields not on stage – Papervision3D

Well, I finally came up with a fix for this issue and thought to archive it.  Basically, the issue is that when you have textfields in a Sprite that you use for a material source for Papervision3D, you want to be able to set focus to those text fields.  Without them being on stage, however, it doesn’t work to say “stage.focus = myTextField”.

So, very simply, all you have to do is add the textfield to the stage, then use stage.focus = myTextField, then re-add back to your Sprite.  Bingo, you have focus in your TextField.  Now, I should say, that i’ve seen it work with just using stage.focus = myTextField, but in this particular situation, adding it to the stage first, then setting focus, then adding it back worked.  So give it a whirl either way.

example:

stage.addChild(myTextField);
stage.focus = myTextField;
this.addChild(myTextField);

Bam! done.  As long as you’re redrawing your material so that you can see what you’re typing ( bitmapMaterial.drawBitmap()), it’ll work just fine.

Tabbing is controlled easily with:


protected function handleKeyUp(e:KeyboardEvent):void
{
if( e.keyCode == 9 ) // tab
{
if( currentField == username )
changeToPassword();
else if( currentField == password )
changeToUsername();
}
}

hope that helps someone!

Papervision3D + Xray Introspection = FINALLY

Man, after nearly 2 years of working with Papervision3D I FINALLY sat down and made it work with Papervision3D (and alot of other things).  Turns out it wasn’t that hard, I just needed to flip a switch to let other objects besides pure Objects and Array’s pass through to the interface.  It’s been digging through all of Papervision’s stuff all this time now, and I just needed to turn the key 😉  Well, there was a bit more with fixing a bug to support Dictionary’s now in Xray, but that’s all fixed now.

video: http://www.rockonflash.com/video/XrayPapervision3D.mov

You can see in this picture that I’m looking at a DisplayObject3D which is actually a child object of the loaded DAE.  You can change any of the properties you see there at runtime.  This makes it an extremely useful tool for debugging, but also for learning someone else’s application as well as optimization.  You can go through and change nearly any property at runtime to see who’s causin’ the problems.

The image below shows you the fix for Dictionarys.  DisplayObject3D’s children object is a Dictionary, and so now you can see all of it’s children and continue to click your way through to the end.  This is the group of panels in the QuadTree demo and you can see each one in the list of children.

I’ve committed the code and you can check out Xray here with your favorite svn client:
http://osflash-xray.googlecode.com/svn/trunk/

You can get the Xray interface here:
http://www.rockonflash.com/xray/flex/Xray.zip

The version you see in the video is the new AIR version which runs really well and as soon as I have time to package it up properly, I’ll release that version.

To get it working, put this in your code:

// create public var:
public var xray:Xray = new Xray();

// then, after you’re sure the stage is there in the main application:
addChild(xray);

Then just fire up the Xray Interface and hit the “go” button to take a snapshot and get started

On Demand Papervision Course: Optimization Techniques

For a few months now, I’ve been doing live workshops online through RMI and those have been going very well.  So finally, after this last run, we archived the class (recorded it) and are offering it up as an on demand course you can take any time you like!

We’d received alot of feed back to provide an on demand version since not everyone can make it on the days we hold them.  Given that a fair amount of you are coming from over seas, it’s even more difficult to make the time slots.  One person was taking the class at 1am in the morning 😉  So I think this will help!

This course covers the Winter Wonder Land animation and engine.  You get all the source files for the application along with alot of other demo files that I typically hand out when I teach.  It covers:

  • Materials preparation and best usage with animation
  • BitmapData concepts to replace traditional MovieClip animations at runtime
  • SWF settings that can cause better performance (or worse)
  • Using multiple viewports and BitmapViewport3D
  • Simple tricks for getting decent effects (cheaply on the cpu)
  • Shaders ( bonus material )

Title: Papervision3D 2.0 Optimization

Duration:~200 minutes

Description: We’re going to take the Winter Wonderland demo from Zero fps to the 20’s by practicing a few some less known and some well known tips and tricks concerning both the Flash Player and Papervision3D. We’ll cover image preparation and rules, the Flash Player’s idiosyncrasies and what makes Papervision3D really sing. The Winter Wonderland animation started out as slow as 2fps and ended up in the mid 20’s after all of these techniques were applied. That leaves plenty of room for additional animations and bells and whistles later on! We’ll take the source for Winter Wonderland and crawl through it together to squeeze every last FPS out possible.

Who this course is for: Flash designers / developers with Papervision3D experience.

Check it out here

Xray short walk-through video

After seeing some of the replies on my last post, I thought doing a little video on what the AS3 version is capable would be a good idea.  So here’s a little walk through:

http://dl-client.getdropbox.com/u/36547/videos/xray/XrayWalkthrough_7Min.mov

Xray – Yes it does AS3 :)

Well, for a while now, people have been asking me about using Xray with ActionScript3, so I thought I’d clear up the confusion with one post about it.

Yes – there is a version for AS3.  That’s the good news.  The bad news is, it doesn’t have all the bells and whistles that AS2 version had.  It DOES do introspection of your objects at runtime with a snapshot, and the logger is as strong as ever.  There’s also a Flex specific Xray class that works rather well.

The nice thing is, the logger and Xray work the same in either the Flash IDE, pure ActionScript project, Flex application or Air application.  It doesn’t have an AS3 component yet, but it works very easily with a couple lines of code just the same way.

Let’s take a look at doing 2 things: 1)  setting up an Xray instance for introspection and 2) just using the logger.

Xray Instance

To create an instance of Xray, you simply add the import to your class, then create an instance:

import com.blitzagency.xray.inspector.Xray;

// later in your property declarations:

public var xray:Xray = new Xray();

addChild(Xray);  // you have to add it to the stage in a pure ActionScript application or Flash IDE app – thanks Dave!

// for you Flex users – it works for Flex2 or Flex3 or Air

import com.blitzagency.xray.inspector.flex.Flex2Xray;

public var xray:Flex2Xray = new Flex2Xray();

Yay me!  we’re done and you can use the Flex Xray interface to take a look at your application.

Xray’s Logger

Xray’s logger has the same log levels that most do these days: debug, info, warn, error and fatal.  To create an instance of the Xray logger, you simply add the import, then create an instance like so:

import com.blitzagency.xray.logger.XrayLog;

// later in your property declarations:

public var log:XrayLog = new XrayLog();

// later, when you want to log something:

log.debug(“StringMessage”, object [, object, object…]);

log.info(“StringMessage”, object [, object, object…]);

log.warn(“StringMessage”, object [, object, object…]);

log.error(“StringMessage”, object [, object, object…]);

log.fatal(“StringMessage”, object [, object, object…]);

You pass a string message as the first argument, then send as many objects as you like after that.  The output is nice in that it includes a time stamp as well as the class and line number that made the log call:

(2793) com.electricsheepcompany.aspen.spaces::SpaceCreator/handleGroupLoaded()[/Users/NeoRiley/Documents/Infrared5/clients/clientName/source/johnBranch/src/1.0_jgrden/src/main/flex/com/clientName/clientAppName/spaces/SpaceCreator.as:102
GroupTest: group load complete

As you can see, you get the calling Class fine and line number. Nice huh?

Where do I get the code?!?

Glad you asked!  It’s hosted on Google code and you can check it out with any SVN client at this URL:

http://osflash-xray.googlecode.com/svn/trunk/

And the snazy Xray Interface app??

You can download the SWF based Xray app here

The future of Xray?

As usual, I’m sure Xray’s development will be driven by need on projects and by people who request features.  If anyone cries loud enough, I’m sure I’ll do what I can.  As I come to need more features that AS2 used to support, I’ll get around to implementing them.  But for now, it works well in AS3, and does what I need it to do, which is introspection and the ability to modify properties at runtime to see what’s going on with the application.  Much of my work these days is being a consultant on new gigs every couple of months and Xray really helps me cut through the felgercarb in mere sentons.

Also, there’s XrayViewer by Marc Hughes

Marc’s the one that did the work on the filter component for Xray’s log output, and came up with a really VERY cool AIR app that lets you load a SWF and inspect it 😉

http://rogue-development.com/xrayviewer.html

Scrolling automatically to the bottom of a textarea control in Flex

This is more for archive sake, but this did the trick 😉

http://butterfliesandbugs.wordpress.com/2007/08/20/scrolling-to-the-bottom-of-a-container-or-textarea-automatically/

The real trick is doing it in the valueCommit handler, not the change handler (which is where I tried originally)

microsoft: Did they have a hand in it? I’ll say…probably.

I was just heading over to Hank’s article on the situation with EcmaScript 4.0. The short of it is: it’s been drop kicked for good, leaving Adobe with decisions to make. As you read, Adobe had put alot into being standards compliant with AS3 and for obvious good reasons. The speculation is, however, that microsoft has had something to do with it’s death. As I read through Hank’s observations, I have to say, it seems pretty obvious, but I’m sure there are other factors. When you consider Silverfish (microsoft’s attempt at being a flash competitor), this makes almost too much sense.

One of the replies to the post suggested that Adobe seriously consider adopting haXe. I have to say, I see some real reason behind that at this point. Its already open source and has a great community behind it.

What’s interesting to note is that, when Nicolas emailed the open source flash list and introduced the concept of haXe (over updating MTASC to be AS3 compatible – thus creating his own language), I *got* the concept and even understood his reasoning, but didn’t necessarily feel like this would happen like it did (ie: es4 being tossed out). I literally thought it was a standard, but apparently, I wasn’t paying attention. Looks like Nicolas was a bit of a visionary I’d say, and now we’re actually living out what he suggested could happen.

And dood, that’s some serious apples right there – write your own language?? are you kidding me? And there’s only 2 people I’ve ever told on this blog who have big apples 🙂

Anyway, some interesting developments for sure are coming down the road – it’ll be very interesting to see what pans out. Personally, I’d love to see haXe adopted and basically hand microsoft their ass later on. Who am I kidding anyway, WHATEVER Adobe does to call microsoft’s move, I think i’ll be right there to support em’.

What’s even funnier is: it seems that both microsoft AND apple have it in for Adobe and Flash – what the hell gives with Apple and iPhone/iTouch not supporting Flash? The funny part is that Job’s used to be the leader of an underdog with ideals that matched his gear, and now he’s showing signs (and getting reactions btw) of the company he sought to dethrone (yes, that would be microsoft). Remember this ad? He might soon find himself as “the man behind the glasses”

PS> if you’ve been emailing me or im’ing me, and I haven’t replied, it’s because I finally contracted pneumonia – Dr says “you have a touch of it” – whatever that means. I feel like crap. But this got me mad enough to sit up in bed and say something