Detecting Standalone or Plugin Flash Players – taterboy
January 26th, 2009 | Filed under: ActionScript 2, ActionScript 3, Flash, Flash AS2 to AS3, Flex, Tips
Maintaining version control on project files can easily get out of control when saving multiple versions of the same file. One tip is covered in an earlier post about swf based relative urls for flash/flex files. This tip works even if the host file is moved to a different locations. This way we do not need to save a live version and a local build version.
Why would I care which Flash Player type is used?
Some projects, like kiosks, will end up as a Flash Projector or AIR Application. Until the project is finalized and approved we may need to preview the project for our clients on the web. In AS3 some stage methods are only available to the standalone player. Instead of saving two versions of the same project, one to test the Projector functionality and another for online approvals; we can build one multi-purpose file.
Read More »
SWF Based Relative URLs in Flash or Flex – taterboy
January 17th, 2009 | Filed under: ActionScript 2, ActionScript 3, Flash, Flash AS2 to AS3, Flex, Tips
When a Flash/Flex app loads into a browser, all urls for the swf are now relative to the file that is hosting the swf and not the location of the swf file itself. This can create issues between testing the swf locally and viewing it on the live site.
Case Study:
When building a demo to display on this blog I have to create one version with relative urls to distribute as source and a separate sample for preview using absolute urls. This is because of the setup of the blog, some files like the index page display from the root of the blog while all the article files have unique urls based on title and date.
Read More »
Is AS3 Ready For Prime-Time? (part 3) – taterboy
September 27th, 2008 | Filed under: Flash, Flash AS2 to AS3, Tutorials
Targeting Loaded swfs and Streaming
As we move into the Object Oriented mindset, communication between a host and loaded swf can be a little controversial. Though using bubbling events is great for easy plug and play type communication, establishing a direct connection to pass information can be more efficient.
As a comparison, to load an swf into an AS2 project, all you have to do is tell a MovieClip to load an swf and then that MovieClip will take on all the attributes of the loading swf. To access the loaded timeline you use, MovieClip.gotoAndPlay(2);
In AS3 all loaded swfs are loaded into a loader object that is added to a container. To access the timeline of a loaded swf you would use an instance of the Loader Object’s content.
var loadedSwf:Object = Loader.loaderInfo.content; //or var loadedSwf:Object = Loader.contentLoaderInfo.content; //then: loadedSwf.gotoAndPlay(2); |
Here are a few things to keep in mind when communicating with loaded swfs with AS3.
Read More »
Try.. Try.. Try.. Error Supression – taterboy
August 27th, 2008 | Filed under: Flash, Flash AS2 to AS3, Tips
One of my favorite statements is try..catch..finally.
When building web applications, we as developers need to plan for the unexpected. We know the web does not always behave at the same level of consistency for all users. This does not take into account client systems which can compound minor glitches.
There are also times that you need to compile code that is reliant on external variables. If all the conditions are not returned in a valid format AS3, being very strict, will throw an error and not complete the remaining code sequences as intended.
Read More »
Simple Hex Color Changer w/ ColorTransform – taterboy
August 6th, 2008 | Filed under: Flash, Flash AS2 to AS3, Tips
I was first introduced to the ColorTransform class while reading the AS2 to AS3 migration documentation about setRGB(). I was immediately impressed with the features, but intimidated when I saw the constructor and all the offset, color and alpha arguments. I just needed to change the color of something, nothing special, no gradients, no alpha, no space shuttle landings, just a simple hex color change.
So here is a simple color change utility that is a lot closer to what I am used to.
function paint(obj:Object,color:Number):void{ var ct:ColorTransform = new ColorTransform(); ct.color = color; obj.transform.colorTransform = ct; } |
source here
Is AS3 Ready For Prime-Time? (part 2) – taterboy
July 30th, 2008 | Filed under: Flash, Flash AS2 to AS3, Flex, Tips
Is Flex AS3 and Flash AS3 The Same?
It is hard enough to learn a new language, but when you write code using logic based on a method that worked so well in Flex, but now in Flash you are getting errors telling you that the method does not exits. It can get a little frustrating.
In Flex I use the Canvas as a starting point for most components, it inherits properties and methods from Display Object, UIComponent, and Container classes. In Flash we use a MovieClip as our base, which inherits methods and properties from the DisplayObject and DisplayObjectContianer classes.
Read More »
Is AS3 Ready For Prime-Time? (part 1) – taterboy
July 8th, 2008 | Filed under: Flash, Flash AS2 to AS3, Tips
This is the first in a series of posts about some issues with Flash, ActionScript 3 and current work-arounds.
1. Timeline Animation and Scripting:
I could not believe this issue when I ran across it for the first time. I really hope it is a bug. If you have code on the first frame of a timeline, then advance the timeline, the objects on the next frame are not available to your code until the frame after.
This simple code does not work: (place code on frame 1 and place mc_clip on frame 2)
gotoAndStop(2);
mc_Clip.visible = false;
You get an error that says mc_Clip equals null if it did not exist on the first frame.
Read More »
SWF Files With Custom HTML Templates – taterboy
June 9th, 2008 | Filed under: Flash, Flash AS2 to AS3, Tutorials
AS3 Super Loader Part 2
This post is a continuation of the Action Script 3 Super Loader, though this tip could have many adaptations besides the example below.
Many may already know that when you go to the Publish Settings/ HTML window, there is a drop-down that allows for the choice of HTML templates to use with your .swf. When Flash publishes the HTML page along with the .swf, it dynamically creates the new HTML file that will host your Flash movie, with the correct width, height, file name, background color of the .swf in the source code. Many developers use this HTML page to copy the embed code into another file. Some people ignore this feature all together and use Dreamweaver to produce the code or have a custom HTML template that they modify manually.
Read More »
Flash Actionscript 3 (AS3) Super Loader – taterboy
May 17th, 2008 | Filed under: Flash, Flash AS2 to AS3, Free Components/Classes, Tutorials
I really enjoy coding in AS3, but one of the things I dislike the most is the fact that when building movieclips as Classes, you have to export to Action Script or place all your movieclips on the stage somewhere. I think the latter is not very flexible. I understand why it has to be done; I just don’t like it. The problem with exporting everything to the Action Script is that it loads that MovieClip on the first frame, and loaders that are normally placed on the first frame will not show up or function until the first frame is loaded. This first frame now contains all our content that we have exported to Action Script which really defeats the purpose of a loader. That is why you will see a blank white box for a few seconds or longer before the loader shows up. The best way to fix this is to build a loader swf to load our current project swf into.Â
Read More »
What Happened to _global? – taterboy
April 13th, 2008 | Filed under: Flash, Flash AS2 to AS3, Tutorials
What happened to _global, _root, _level?
I rarely used _root or _level just because some projects would end up getting loaded into other swfs. Sometimes I didn’t know this until halfway through or in the end. So I started using global instead. That way I could still target the main timeline, which is where I would try to keep all my code, without having to worry about root moving somewhere else later. When I built components I would also use global, from time to time, to target them from anywhere in the application being developed.