July 30, 2004

Class Lifecycle in AS2.0

I've read about several people having this problem in AS2.0. If a class is imported in Frame 1 of their movie, it's not accessible in Frame 10. The structure of the movie looks like the following:

Frame 1:
import com.db75.utils.ImageLoader;

Frame 10:
var myImageLoader:ImageLoader = new ImageLoader();
trace(myImageLoader);

This will trace "undefined" because the class doesn't exist. Therefore the class only exists for the life of the current frame. This could be considered a limitation if you're structuring your movie using frame states. One non-recommended workaround would be to import your class on every frame that makes reference to it. Another (better approach) would be to keep your movie as a single frame and handle any animation or state changes in components and child movieclips. This would all be controlled through your code so you would technically never need to leave frame 1 of your main (_root) movie.

There is a huge debate when it comes to the Flash developer community and whether to control your workflow through code or frame states. It's considered bad practice in the community to use frame states because you might be loading a bunch of unnecessary code and components. It could also become more difficult to manage in the long run. Since Flash started as a designers tool, we're all guilty of using frames to manage our workflow. In most cases it's quicker/easier to get your application up and running. As of now I take the code approach and try to be more object oriented about my Flash development.

Posted by dennis baldwin at 05:56 PM | Comments (0)

July 28, 2004

Typecasting and Movieclip Visibility in ActionScript 2.0

This is just something basic I learned today when typecasting variables as movieclip objects. Prior to AS2.0 I always made references to movieclip visiblity using the following statements:

my_mc._visible = 0;
my_mc._visible = 1;

If you typecast your variable like:

// Reference to a datagrid instance on the stage
var my_mc:MovieClip = my_dg;

and try to set the visibility of the component using:

my_mc._visible = 0;
my_mc._visible =1;

You'll get the following error:

"Type mismatch in assignment statement: found Number where Boolean is required."

The compiler sees these values as integers or numbers instead of booleans. You have one of two options, the first which makes more sense:

my_mc._visible = false;
my_mc._visible = true;

or cast your number to Boolean:

my_mc._visible = Boolean(0);
my_mc._visible = Boolean(1);

This obviously isn't a big issue but it's nice to see typecasting at work and there are many other places where this will come in handy.

Posted by dennis baldwin at 03:31 PM | Comments (0)

July 27, 2004

Flash MX 2004 Updater

The long awaited Flash MX 2004 updater is finally here! It's dubbed as Flash 7.2 and supposedly addresses over 100 bugs. I just finished installing it so I'll post my results here. The main things that I'm looking forward to are:

- IDE launches faster, more stable
- Fla's compile up to 50% faster
- More component documentation

I know a lot of my frustration have been large source files taking anywhere from 15-20 seconds to compile. Another bug that I've run into several times is switching between a source file after it's compiled to an ActionScript file. On several occasions this operation has crashed my entire IDE. Anyway, kudos to MM on this release and I'm looking forward to giving it a go. If you're interested in updating (as you well should be) then check out:

http://www.macromedia.com/software/flash/special/7_2updater/

Posted by dennis baldwin at 12:17 PM | Comments (0)

July 26, 2004

Flash Player 7 Web Services and Security

If you've done any Web Service programming in Flash MX Pro then you've most likely run into situations where you're accessing Web Services that don't reside on the same domain as your .swf file. Assuming you have administrative access to the server that hosts the Web Services, you'll need to deploy a crossdomain.xml file which gives access rights to certain specific Flash clients. This file needs to reside in your wwwroot so that the Flash player can check the access rights and determine whether or not the .swf file can access the services. For example, in our development environment at work we allow all clients to have access to the Web Services and the crossdomain.xml file looks like:

<cross-domain-policy>
<allow-access-from domain="*" />
</cross-domain-policy>

So if you're accessing a Web Service at
http://devserver:8080/axis/services/TestService?wsdl, then the crossdomain.xml file will need to exist at http://devserver:8080/crossdomain.xml.

Okay so that works great but the problem we ran into was accessing these services over SSL. It's not complicated at all once you know what to do, which generally takes the most time to figure out. In our quest for answers we found out the accessing Web Services over SSL is simple as long as you modify your crossdomain.xml file to look like:

<cross-domain-policy>
<allow-access-from domain="*" secure="true"/>
</cross-domain-policy>

The secure attribute needs to be set to true if the Flash client is being served over a secure connection, this is the default if the attribute isn't specified (as in the first snippet). If you want to access the secure services but aren't serving the client over a secure connection then you'll need to set secure="false". In most situations I would highly recommend serving the Flash client over SSL if you're accessing Web Services. If you don't, the nice security icon doesn't display in the browser and you might have users questioning whether or not their transactions are secure.

One last note, if the SSL cert is self-signed or not from a trusted authority then the WS call will fall. This holds true even when accessing the secure Web Service through the IDE, which was a huge suprise to me. I'll be doing more investigation of this issue but that's it for now.

Posted by dennis baldwin at 09:53 PM | Comments (0)

July 25, 2004

Welcome

Welcome to my blog. I just got movabletype running and it's a very robust content management system. I'm mainly going to ramble about different technologies such as M2M, Flash, Symbian OS, as well as other odds and ends. Oh yeah, if you're not familiar with M2M it's seriously a killer technology that you'll hear more and more about in the coming months. M2M stands for:

- Machine to Machine
- Man to Machine
- Mobile to Machine

and basically combine the above any way you like. M2M gives businesses/individuals the ability to remotely monitor and control assets out in the field. This can be wired/wireless and communicate over ethernet, GPRS, SMS, satellite and several other technologies. This is really the tip of the iceberg when it comes to M2M and if you'd like to learn more, check out www.sensorlogic.com.

SensorLogic is the company I work for and we're an M2M application service provider (ASP). I do an extensive amount of Flash, Java, and embedded programming for SensorLogic and let me say that it's the most rewarding and challenging jobs I've ever had. The development team is incredible and everyone brings something different to the table. We mainly focusing on the SensorLogic M2M Portal which allows users to login and monitor/control devices hooked up to their equipment.

For example, lets say that I'm a company that provides antennas for cellphone towers. There's a lot of overhead when it comes to sending someone out to the field, climb the tower, and tilt the antenna. There's risk, money, and time involved just to get one antenna tilted correctly. Antennas need to be tilted at certain angles depending on time of day, coverage, etc. With the SensorLogic M2M Portal the customer can login and remotely monitor and control their antennas. They can even add intelligence to their antennas by creating behaviors that say something like "Tilt these eight antennas to 45 degrees at 6:00PM today". Like I said, this is just the beginning and there's much more to come.

Speaking of Flash....right now we're working on converting the M2M portal to Flash. It currently exists in a JavaScript/DHTML implementation which is VERRRRY SLOW. I'm not going to mention the name of the company we're licensing the JS/DHTML from but let me say we're extremely excited about building it from the ground up in Flash. We're accessing Web Services that our team built and let me tell you it's already much faster and more stable than the current portal. We'll be utilizing quite a bit of Macromedia's V2 components but I can see us writing our own in the near future. Anyway, more to come on the M2M portal conversion!

Posted by dennis baldwin at 03:54 PM | Comments (0)