Minor updates to “Trace from the browser…” tutorialAdded Linux info and a few other small tweaks to keep the tutorial up-to-date.

Made a few minor updates to my “Trace from the browser, using standard trace()” tutorial.

Posted in Flash | Leave a comment
Metaliq Components and MTASCHow to tweak the classes provided with the latest version of the Metaliq component set to be compliant with mtasc.

In my last post I briefly mentioned that I would discuss how to tweak the classes that are shipped with the latest version of the Metaliq component set to be compliant with mtasc. The steps that I will take assume that you have purchased a license of the Metaliq component set and have the latest version with the source code. It also assumes you already have mtasc and swfmill setup. If you don’t know what these tools are, or how to set them up, you can go to their respective homepage or find numerous tutorials to help you get up to speed. I actually use FlashDevelop which comes pre setup with both of these tools. The following steps will create a project in FlashDevelop and allow you to start compiling the Metaliq components with mtasc. You should be able to easily translate this to Eclipse or other script editor of choice.

  1. Create a new Library Project and name it “Metaliq”. Make sure to check “Create directory for project”.
  2. In the Project Explorer, open up the properties panel for the project. Under “Test Movie”, change the pulldown option to “New Window”.
  3. Go to the Build tab and delete the Post-Build Command Line text and hit Apply.
  4. Go to the Compiler Options tab and click on IncludePackages. A button with a “…” will appear, click on that. Delete the text in that window and hit OK.
  5. Set UseMain to true.
  6. Set TraceMode to FlashOut. Hit OK and close out of the properties panel.
  7. Find where your Metaliq source code is and copy the “com” folder over to the “classes” directory of your new project. Make sure to copy it and not move it since we will be editing the source.
  8. From the Metaliq source, go to the “flas” directory and copy Button.fla to the “library” directory of your new project.
  9. Open Button.fla in Flash (there should be nothing on the stage). Go to the publish settings and add the following class path: “../classes/” (without the quotes). Save, compile and close.
  10. In the “classes” directory of your project, create a new class named “ButtonTest.as” and add the following code:

    			import com.metaliq.controls.Button;
    			import com.metaliq.skins.FocusRect;
    			import com.metaliq.skins.gskin1.ButtonBackground;
    
    			class ButtonTest {
    				// content holder
    				var content:MovieClip;
    
    				function ButtonTest() {
    					// create dummy variables to pull in required classes for mtasc
    					var fr:FocusRect;
    					delete fr;
    					var bb:ButtonBackground;
    					delete bb;
    
    					content = ButtonTest.parent.createEmptyMovieClip("content", 0);
    
    					var sample_btn:Button = content.createClassObject(Button, "sample_btn", content.getNextHighestDepth(), {
    						icon:"icon1",
    						label:"Hello world!",
    						labelPlacement:"right",
    						selected:false,
    						toggle:true,
    						enabled:true,
    						visible:true,
    						minWidth:15,
    						minHeight:15,
    						_x:10,
    						_y:10,
    						_width:150
    					});
    
    					configButton();
    				}
    
    				private function configButton():Void {
    					content.sample_btn.addEventListener("click", onButtonClick);
    				}
    
    				private function onButtonClick(evtObj:Object):Void {
    					if (evtObj.target._name == "sample_btn") {
    						trace("you clicked the button");
    					}
    				}
    
    				// APPLICATION INITIALIZATION
    
    				static var application:ButtonTest;
    				static var parent:MovieClip
    
    				/**
    				* Application entry point
    				*/
    				static function main(scope:MovieClip) {
    					parent = scope;
    
    					// create the content
    					application = new ButtonTest();
    				}
    			}
    			

    If you look at the class above, you will notice a main method that gets called by mtasc. This main method creates an instance of the ButtonTest class which in turn begins the setup for instantiating a Metaliq component through code. We are using the createClassObject method to instantiate the Button component. The parameters passed are className, instanceName, depth, and an initObject which sets the defaults for the component. Besides the Button class, two other classes are imported in for mtasc. Once you get through with the following steps, remove those imports and the instantiations of those classes to see the error that mtasc throws. It will clearly ask you to force compilation of those classes. The easiest way to do that is by adding in the import statement for each class and then creating a reference to the class by instantiating it. I immediately delete the instance so it doesn’t take up memory.

  11. In FlashDevelop’s Project Explorer, right-click on ButtonTest.as and select “Always Compile”. And right-click on Button.swf and select “Add to Library”.

These previous steps are the basis for setting up a project in FlashDevelop to compile with mtasc and swfmill. The next steps will be getting the Metaliq classes to compile with mtasc.

  1. Hit F5 (Test Movie). You should see an error pop up. Double click on the error to bring up the class that is causing the error.
  2. The error is “unknown variable” in FocusRect.as. If you look in the constructor, there is an onEnterFrame function. Within this function, a call to the draw method is made. The simplest way to fix this is to add “this.” in front of “draw()” to scope the method properly.
  3. Hit F5 again and then do the same for the next error.
  4. The next error is “return type cannot be Void”. If you double click on this error, it will open up UIObject to around line 90 within the glicInit method. If you notice, the return type for glicInit is Boolean but the first line returns nothing. mtasc doesn’t like this. To fix it, change if (initted) to if (!initted) , delete the return and put the rest of the method within the brackets.
  5. Your next error will go back to “unknown variable”. You know how to fix these.
  6. Another error you will get is “Object should be MovieClip”. This is an easy one to fix. Wrap the object that is causing the error in MovieClip() to typecast it.
  7. The next error is “Object should be String”. Just add String() around the offending objects.
  8. The next error is “unknown variable m”. If you look above the error, you will see that m gets declared within an if statement. To fix the error, declare the m above the if statement and set m in the if statement.
  9. The next time you hit F5, mtasc should finally compile nicely. The button probably will just be text at this point (text acting as a button with no background). To see the background behind the button, you have to do something very random. I have gone through and converted all of the classes to be mtasc-friendly and this was the only part that still doesn’t make complete sense to me, but it works. In BaseButton.as, add the following code to around line 88:

    			public function set background(p_bg:String):Void { super.background = p_bg; };
    			

    For some reason, even though BaseButton extends UIObject, without the above statement the call to set background does not automatically go up the chain to UIObject without explicitly forcing it to. If you compile now, you should see the background behind the button. You now have a fully working example of a Metaliq component being compiled with mtasc.

  10. Continue along with these steps and slowly and surely you will start to make headway through the rest of the classes. Be forewarned there are a lot of errors to fix to make the entire component set mtasc compliant. But once you do, your life will be much simpler and your compiling will be MUCH faster.

Enjoy and feel free to comment with questions below.

Posted in AIR, Flash | 4 Comments
Metaliq Components (finally getting the love they need)Metaliq has decided to finally start supporting the Metaliq components and provide the source.

When the Metaliq components were first released, I quickly encouraged my company at the time to fork over the $400 so that we could FINALLY have some solid, light-weight Flash components. While, yes, they were light-weight and even pretty solid, I was extremely disappointed to find out that the source code was not included. What quickly became even more frustrating was that Metaliq, at the time, was not actively supporting the components. The documentation was sparse and, more importantly, Metaliq was not responding to any support questions or comments that quickly came up around the Flash community. Oh well… the purchase was already made and we needed to use the components so I made the best of it.

Close to a year later, I suddenly got an email in my inbox from someone at Metaliq. I quickly looked it over and found out that they were updating the documentation and asked if I wanted to review it. Nice…, a year late, but none-the-less nice. What’s more, I could send questions and comments and he was responding… wow actual customer service… unbelievable.

This at least renewed my interest in the Metaliq components. So, when I got to my new company and we needed to work on a Flash 8 project (how it hurts to move backwards), I again encouraged the purchase of the set since the project called for several existing components and there’s no need to use the bloated v2 set. And if nothing else, at least they’re simple to skin. Once the purchase was approved and the components were delivered, I quickly opened them up and noticed something different… a folder labeled source. Could it be? Yes, It was! The latest release of the components comes with all of the classes and all of the flash source files! How nice!

Once I started looking through the source, I wondered something…. could we now compile the mCOM set with MTASC? I quickly set a project up in my editor of choice, FlashDevelop, hit compile and, unfortunately, MTASC complained. I looked at the error, decided to make a fix to the source, and tried again… another error. Damn. Oh well.

A couple of days later, I was talking with my friend Mark Llobrera and lo and behold, he was having the same problem. We quickly started tearing through the code, passing tips back and forth over IM, and within a few minutes had Button compiling with MTASC. Once we realized the MTASC-related problems in the code, they were simple to fix.

This post will not go into the details of how to fix the code, I’ll cover that in my next post. I just wanted to let people know if they already own the component set, and have not done so yet, to request the latest from Metaliq. And, if you’ve been scared off in the past on purchasing the components and still have a lot of pre-Flash 9 work to do, I suggest giving them another try.

Posted in Flash | 7 Comments
Trace from the browser update for latest Flash Debug PlayerMade some updates to the tutorial to incorporate the latest changes that Adobe has made with Flash Player version 9,0,28,0.

As of Flash Player version 9,0,28,0, Adobe has stopped using the mm.cfg file and changed the location of flashlog.txt.
I’ve updated my “Trace from the browser, using standard trace()” tutorial to reflect this change.

Posted in Flash | 2 Comments
movin’ on up (to the schematic side)I am now working at Schematic.

Schematic
FYI …
As of yesterday, November 1st, I now work for Schematic in the New York office. Its exciting to be working with so many extremely talented people under not only one, but multiple roofs. Made it right under the 30 mark too… I officially get old on Sunday ;)

Posted in General | 3 Comments
Efficient Fuse (Keep Filesize Low in Multiple Files)A step-by-step guide explaining how to keep filesize to a minimum using Fuse.

As I’m sure most people know, Fuse is finally out of beta.
I’ve been using the beta Fuse for a while now and its a great way to create advanced Flash motion tweens in no time.

One comment that seems to come up regularly in the forum and mailing list is that Fuse is too heavy. If not checked, Fuse can quickly get hefty, but if you follow a few guidelines you can easily keep Fuse at quite a small size for its amount of features.

The first thing to note about Fuse is that it provides a modular mix & match format with its classes. What this means is that it allows you to only publish and use the classes that you need. You can test this out by creating a new Flash movie and adding a square MovieClip with an instance name of “box” to the stage. Then add the following code on a new layer:

import com.mosesSupposes.fuse.*;

ZigoEngine.doTween(box, '_scale', 20, 2, mx.transitions.easing.Elastic.easeOut);

By not registering any additional classes, you have just compiled your movie with the basic classes needed to get started animating with Fuse (well technically ZigoEngine). This file should come out around 13kb. 13kb is not too shabby for the amount of functionality that ZigoEngine provides.

According to Moses, the brains behind Fuse, you should be able to get this filesize even smaller (to around 10kb) by excluding the trace actions in your publish settings. I personally haven’t been able to successfully see a decrease, but if your under tight size constraints its a good tip to know about anyway.

In the example above, you should note that the easing function that I used is from the mx.transitions.easing set. By doing it this way, you only import the easing function that you will be using. This works with the com.robertpenner.easing classes as well. But if you think you will be using many different types of easing functions in your project, an easier way to import and use them is by registering all of the PennerEasing classes. Use the previous example and replace the code with the following:

import com.mosesSupposes.fuse.*;

ZigoEngine.register(PennerEasing);
ZigoEngine.doTween(box, '_scale', 20, 2, 'easeOutElastic');

This allows you to use a simpler syntax to call the easing methods, but does however add a bit more overhead to the swf. If you check the file now, it should be around 15kb. If you’re under a tight size constraint and only need a couple of easing functions, go the first route, otherwise use this way for simplicity.

Another nice thing to know about is that you can use the FuseFMP functionality without using Fuse at all. FuseFMP allows you to quickly setup filters on your clips. To try this, use the same file as above but replace the code with the following:

import com.mosesSupposes.fuse.*;

FuseFMP.writeFilter(box, 'Blur', {blurX:10, blurY:0});
FuseFMP.setFilterProps(box, 'DropShadow', {distance:20, alpha:.5});

If you check out your filesize now, you’ll be at around 6kb. If you only need to setup filters on your objects and not do any animation, this is a great way to go.

If you like the Fuse object syntax, but don’t need all of Fuse’s functionality you can register FuseItem much like you registered PennerEasing above. As a quick example, take the same file and replace the code with the following:

import com.mosesSupposes.fuse.*;

ZigoEngine.register(FuseItem);
ZigoEngine.doTween({ target:box, scale:20, ease:mx.transitions.easing.Elastic.easeOut, time:"02:00"});

This opens up some of Fuse’s power, but also begins to open up some of Fuse’s filesize as well. If you look at the file in finder or explorer now, the filesize should be around 22kb. Once you start getting up here though, you might as well start using the full functionality of Fuse. The next section is about that and how you can use Fuse in multiple swfs but only see the filesize hit once.

Once you decide to register Fuse and start using its full functionallity, you are instantly at 27k. This in itself wouldn’t be too big of a deal if you had a large animation in a single Flash movie, but what if you are like me and build your sites and Flash projects using multiple swfs… if you want to use Fuse in all of those swfs you are instantly dealing with 27k in each and every swf. This adds up very quickly.

What if I told you there’s a way to only get the 27k hit once but use Fuse in all of the swfs in your project? There is… using exclude xml files.

To test this, setup a new Flash movie and add a movieclip with a circle in it and name it “circle_mc”. Place the circle somewhere in the center of the flash movie. On a new layer add the following code:

import com.mosesSupposes.fuse.*;

ZigoEngine.register(Fuse);
ZigoEngine.register(PennerEasing);
var f:Fuse = new Fuse();
f.push({target:circle_mc, x:-100, y:-100, seconds:.5, ease:"easeOutQuad"});
//f.push({scope:this, func:"loadSection"});
f.start();

function loadSection ():Void {
	this.loadMovie("section.swf");
}

Ignore the commented line and the function for now and compile the movie. What you should see is a circle tweening off the stage to the top left. If you look at the swf in finder or explorer, you should see the filesize around 27 or 28k.

Please note, Fuse is a VERY advanced motion sequencer and the example I am showing you is VERY basic, for something this basic you would not even want to use Fuse.

Now, create another Flash movie and this time add a square in it and name it “square_mc”. Place the square somewhere in the center of the flash movie. On a new layer add the following code:

import com.mosesSupposes.fuse.*;

ZigoEngine.register(Fuse);
ZigoEngine.register(PennerEasing);
var f:Fuse = new Fuse();
f.push({target:square_mc, x:Stage.width, y:Stage.height, seconds:1, ease:"easeOutBounce"});
f.start();

Make sure to save this movie as “section.fla” and compile it. This time you should see a square tween off to the bottom right. Again if you look in finder or explorer you will see section.swf weighing in around 27 or 28k. Now go back to the first movie and uncomment the commented line and recompile the movie. Now you should see the circle go off to the top left and then you should see the square go off to the bottom right.

Everythings working great, right? One problem… we’re now dealing with Fuse in two seperate swfs but one project and the total weight is around 54 or 56k. Now imagine loading in 10 swfs all using Fuse… adds up pretty quick doesn’t it?

The solution is to use an exclude xml file. An exclude xml file allows you to compile a swf without specific classes knowing that it will be able to pull those classes in from a container movie.
To make the exclude xml file, create an xml file and add the following into it:

<excludeAssets>
	<asset name="com.mosesSupposes.fuse.Fuse"/>
	<asset name="com.mosesSupposes.fuse.FuseFMP"/>
	<asset name="com.mosesSupposes.fuse.FuseItem"/>
	<asset name="com.mosesSupposes.fuse.FuseKitCommon"/>
	<asset name="com.mosesSupposes.fuse.PennerEasing"/>
	<asset name="com.mosesSupposes.fuse.Shortcuts"/>
	<asset name="com.mosesSupposes.fuse.ZigoEngine"/>
	<asset name="com.mosesSupposes.fuse.ZManager"/>
</excludeAssets>

Save the xml file as “section_exclude.xml”. If you are going to use an exclude xml file it needs to be named exactly what the flash movie that you are trying to exclude classes from is named plus “_exclude.xml”. Inside of the file, each Fuse class is listed as an asset to exclude from section.swf. Now compile section.fla. It compiles but no longer works. Go back to the first circle Flash movie and compile it again. Everything should work now. Circle moves off top left and square moves off bottom right. The square movie is able to pull in the Fuse classes from the circle container movie. Now look at finder or explorer and check out the filesize. The first movie is still around 27 or 28k but check out section.swf… it should be around 2k!! Not too shabby. This is a much more efficient way of loading multiple swfs using Fuse then the first option.

To make working with exclude xml files easier, check out the commands from Martijn Devisser. These commands allow you to compile without using the exclude xml file for testing purposes and then allow you to compile with the exclude xml file when you’re ready to finalize the project. Makes life nice and easy :) .

Posted in Flash | 3 Comments
Penner AS2 ProFMX: Complete!!!I have completed converting Robert Penner's Programming Flash MX from AS1 to AS2.

Well, that’s it!
I’ve made my way through Robert Penner’s Programming Flash MX to the end and survived.
Every class from the book has now been converted from AS1 to AS2 and every example from the book has been shown working with these new classes.
It has taken me exactly 73 days (in my spare time) to complete since announcing the project on June 27th earlier this summer. A lot of times I thought about shelving it, but I really wanted to see it through to completion and I’m glad I did.
I hope that everyone out there gets some use out of these classes and I’ll try and post some of my personal examples using them in a little while.
Thanks to Robert Penner for writing the book and giving me the green light on the project and thanks to everyone out there that has emailed or commented with your support. It was quite an undertaking but well worth it in the end.

Download:
Complete Penner AS2 ProFMX Classes and Documentation

Posted in AIR, Flash | 9 Comments
Penner AS2 ProFMX: Cyclone ExampleDemo of the AS2 classes for ProFMX chapter 14.

Cyclone

Click image to view demo


After the cyclone above builds out, click and drag the small rotating plus sign to direct the storm. The Cyclone example uses the classes from the Chapter 14 Penner AS2 post.

To replicate this example:

  1. Create a new Flash movie and then create a new Graphic named “particleGraphic”.
  2. Inside the Graphic, add a square 10px wide by 10px high. Rotate the square 45 degrees and then resize it to 3px wide by 11px high, x and y position at 0.
  3. Outside the Graphic, select it on the Stage, center it over the registration point, give it a tint of 153, 153, 153, and convert it to a MovieClip so that the Graphic is now within a MovieClip. Name this MovieClip “Particle” and give it an instance name of “particle”.
  4. Select this MovieClip on the stage and convert it to another MovieClip. Name this clip “CyclonePath” and add the class linkage of “com.robertpenner.profmx.cyclone.CyclonePath”. Also, give it an instance name of “path”.
  5. Within the CyclonePath MovieClip, add a layer above the particle named “actions” and put the following code:
    			this.init();
    			
  6. Back outside of the CyclonePath MovieClip, convert it to another MovieClip. Name this clip “CycloneOval” and add the class linkage of “com.robertpenner.profmx.cyclone.CycloneOval”.
  7. Within the CycloneOval MovieClip, add a layer above the path named “actions” and put the following code:
    			this.init();
    			
  8. Close all of these MovieClips and create a new MovieClip named “CycloneDragger” with a class linkage of “com.robertpenner.profmx.cyclone.CycloneDragger”.
  9. Within this MovieClip, add a 1px wide by 28px high line centered over the registration point. Duplicate this line and rotate it 90 degrees so you end up having crosshairs. Convert the crosshairs to a graphic named “crosshairs”.
  10. Outside of the crosshairs graphic, within the CycloneDragger MovieClip, give the crosshairs graphic an alpha of 65% and scale it to 70%. Add a new layer with a fully transparent oval centered over the registration point and crosshairs, 28px wide by 39px high. This will be used as the button for the dragger.
  11. Outside of the CycloneDragger MovieClip, scale the clip to 35%, centered over the registration point horizontally, and vertically placed at 106 with an instance name of “p0″.
  12. Convert the CycloneDragger MovieClip to a new MovieClip named “Cyclone” with a class linkage of “com.robertpenner.profmx.cyclone.Cyclone”.
  13. You will now convert this Cyclone MovieClip to a component. Right-click on it in the library and select “Component Definition”. In the window that pops up add the same class to the area that says “AS 2.0 Class:”.
  14. Give the Cyclone component that is currently on the stage an instance name of “cyclone” and scale it to 150% wide by 110% high and center it on the Stage so that both the registration point and dragger can be seen. Click on the Parameters tab to see the following component options: funnelHeight, maxParticles, speed, and stiffness. Play around with these options.
  15. On the root timeline add the following code and compile:
    			this.cyclone.init();
    			
Posted in Flash | 2 Comments
Penner AS2 ProFMX: Chapter 14: CycloneAS2 classes for ProFMX Chapter 14.

Chapter 14 of Robert Penner’s Programming Flash MX is the final chapter of the book. This chapter includes classes to develop a cyclone particle system that bends towards a user-controlled dragger.

This chapter contains four classes: CyclonePath, CycloneOval, Cyclone and CycloneDragger, which will be included in the com.robertpenner.profmx.cyclone namespace.

Documentation:
com.robertpenner.profmx.cyclone.CyclonePath
com.robertpenner.profmx.cyclone.CycloneOval
com.robertpenner.profmx.cyclone.Cyclone
com.robertpenner.profmx.cyclone.CycloneDragger

Source:
Penner AS2 ProFMX: Chapter 14 Classes

Posted in Flash | Leave a comment
Penner AS2 ProFMX: Fractal Dancer ExampleDemo of the AS2 classes for ProFMX chapter 13.

Fractal Tree

Click image to view demo


Click around above while the counter moves up to 150. Once it reaches 150, let go and the fractal tree will repeat the motions that you created as it recursively creates new branches. You can also change the 150 number to any other number that you would like. This is the Fractal Dancer example using the classes from the Chapter 13 Penner AS2 post.

You can download this example here.

Posted in Flash | 1 Comment
  • Pages

  • Categories

  • Archives