Recently I built a .swf file which contained a DataGrid. The data was provided via xml, and everything appeared to be working as intended. However, when I loaded the swf into the parent swf, the content of the datagrid was no longer visible.
My first attempt was to try to immbed the font, however that didn't solve my problem either. After a considerable amount of time checking into this, I found that there was a simple solution to the problem.
The UILoader I was using to load the external swf was under mask in the Flash timeline. As you might know, there is often problems with viewing dynamic content under a mask. However, the solution ended up being one simple line of code. I simply set the datagrid to datagrid.cacheAsBitmap = true. Now all of the content appeared without a problem.
A simple solution to a simple problem.
Wednesday, July 1, 2009
Monday, March 2, 2009
Dynamic Gallery Class
Just finished my DynamicGallery class here's the source
___________
package
{
//DynamicGallery v.1 copright 2009 Master Track Productions
//devloper: Daniel Dorner
import flash.display.*;
import flash.net.*
import flash.media.Video;
import flash.geom.*;
import flash.display.Stage;
import gs.*;
import gs.plugins.*;
import fl.motion.easing.*;
import fl.video.VideoPlayer;
import fl.containers.UILoader;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.filters.*;
import flash.text.*;
public class DynamicGallery extends Sprite
{
var holder:MovieClip = new MovieClip;
var loader:UILoader = new UILoader();
var sp:Shape = new Shape;
var txt:TextField = new TextField
var format:TextFormat = new TextFormat()
var dsf:DropShadowFilter = new DropShadowFilter()
var bg:Shape = new Shape;
public function DynamicGallery()
{
trace("DynamicGallery v.1 copright 2009 Master Track Productions developer: Daniel Dorner \r DOCUMENTATION \r Set the image source - DynamicGallery.image(source:String, scaleContent:Boolean); \r Set the transparency - DynamicGallery.viewGallery(Alpha:Number) \r Make gallery viewable - DynamicGallery.openGallery() \r Hide gallery instance - DynamicGallery.closeGallery \r \r NOTE: DynamicGallery.viewGallery() Instantiates the DynamicGallery")
holder = new MovieClip
holder.x = 0
holder.y = 0
}
public function viewGallery(sAlpha:Number = 2):void
{
sp.graphics.beginFill(0x000000, sAlpha);
sp.graphics.drawRect(0, 0, this.parent.stage.stageWidth, this.parent.stage.stageHeight)
sp.x = 0
sp.y = 0
sp.graphics.endFill();
holder.alpha = 0
holder.addChild(sp);
}
public function image(src:String, scl:Boolean):void
{
//prompt textField
format.color = 0xFFFFFF
format.align = "center"
format.bold = true;
txt.defaultTextFormat = format
txt.text = "Loading..."
// txt.x = holder.width /2
// txt.y = holder.height / 2
holder.addChild(txt);
//crates the loader
//then add image
loader.source = src
loader.alpha = 0
loader.scaleContent = scl;
loader.width = holder.width
loader.height = holder.height
//creates loader bg
bg.graphics.beginFill(0xFFFFFF, 0);
bg.graphics.drawRect(holder.width/2, holder.height/2, 320, 240)
bg.graphics.endFill();
//dropShadow
dsf.blurX = 5
dsf.blurY = 5
dsf.alpha = .5
dsf.quality = 5
dsf.distance = 20
//blur
var blur:BlurFilter = new BlurFilter()
blur.blurX = 10
blur.blurY = 10
blur.quality = 3
loader.filters = [dsf]
holder.addChild(bg);
holder.addChild(loader);
//listen for load completion
loader.addEventListener(Event.COMPLETE, onLoaded);
//handles the load event
function onLoaded(e:Event):void
{
loader.alpha = 0;
loader.width = loader.content.width;
loader.height = loader.content.height;
loader.x = holder.width *.5 - loader.width / 2
loader.y = holder.height *.5 - loader.height / 2
TweenLite.to(loader, .5,{alpha:1, ease:Cubic.easeOut, delay:.5});
txt.text = ""
//
}
}
public function trackChange(e:Event):void
{
removeChild(holder);
trace("I changed");
}
public function closeGallery():void
{
TweenLite.to(loader, .5,{alpha:0, ease:Cubic.easeOut, delay:.0});
TweenLite.to(holder, .5,{alpha:0, visible:false , ease:Cubic.easeOut, delay:.5});
}
public function openGallery():void
{
addChild(holder);
TweenLite.to(loader, .5,{alpha:1, ease:Cubic.easeOut, delay:.5});
TweenLite.to(holder, .5,{alpha:1, visible:true , ease:Cubic.easeOut, delay:0});
}
}
}
___________
package
{
//DynamicGallery v.1 copright 2009 Master Track Productions
//devloper: Daniel Dorner
import flash.display.*;
import flash.net.*
import flash.media.Video;
import flash.geom.*;
import flash.display.Stage;
import gs.*;
import gs.plugins.*;
import fl.motion.easing.*;
import fl.video.VideoPlayer;
import fl.containers.UILoader;
import flash.events.*;
import flash.filters.BlurFilter;
import flash.filters.*;
import flash.text.*;
public class DynamicGallery extends Sprite
{
var holder:MovieClip = new MovieClip;
var loader:UILoader = new UILoader();
var sp:Shape = new Shape;
var txt:TextField = new TextField
var format:TextFormat = new TextFormat()
var dsf:DropShadowFilter = new DropShadowFilter()
var bg:Shape = new Shape;
public function DynamicGallery()
{
trace("DynamicGallery v.1 copright 2009 Master Track Productions developer: Daniel Dorner \r DOCUMENTATION \r Set the image source - DynamicGallery.image(source:String, scaleContent:Boolean); \r Set the transparency - DynamicGallery.viewGallery(Alpha:Number) \r Make gallery viewable - DynamicGallery.openGallery() \r Hide gallery instance - DynamicGallery.closeGallery \r \r NOTE: DynamicGallery.viewGallery() Instantiates the DynamicGallery")
holder = new MovieClip
holder.x = 0
holder.y = 0
}
public function viewGallery(sAlpha:Number = 2):void
{
sp.graphics.beginFill(0x000000, sAlpha);
sp.graphics.drawRect(0, 0, this.parent.stage.stageWidth, this.parent.stage.stageHeight)
sp.x = 0
sp.y = 0
sp.graphics.endFill();
holder.alpha = 0
holder.addChild(sp);
}
public function image(src:String, scl:Boolean):void
{
//prompt textField
format.color = 0xFFFFFF
format.align = "center"
format.bold = true;
txt.defaultTextFormat = format
txt.text = "Loading..."
// txt.x = holder.width /2
// txt.y = holder.height / 2
holder.addChild(txt);
//crates the loader
//then add image
loader.source = src
loader.alpha = 0
loader.scaleContent = scl;
loader.width = holder.width
loader.height = holder.height
//creates loader bg
bg.graphics.beginFill(0xFFFFFF, 0);
bg.graphics.drawRect(holder.width/2, holder.height/2, 320, 240)
bg.graphics.endFill();
//dropShadow
dsf.blurX = 5
dsf.blurY = 5
dsf.alpha = .5
dsf.quality = 5
dsf.distance = 20
//blur
var blur:BlurFilter = new BlurFilter()
blur.blurX = 10
blur.blurY = 10
blur.quality = 3
loader.filters = [dsf]
holder.addChild(bg);
holder.addChild(loader);
//listen for load completion
loader.addEventListener(Event.COMPLETE, onLoaded);
//handles the load event
function onLoaded(e:Event):void
{
loader.alpha = 0;
loader.width = loader.content.width;
loader.height = loader.content.height;
loader.x = holder.width *.5 - loader.width / 2
loader.y = holder.height *.5 - loader.height / 2
TweenLite.to(loader, .5,{alpha:1, ease:Cubic.easeOut, delay:.5});
txt.text = ""
//
}
}
public function trackChange(e:Event):void
{
removeChild(holder);
trace("I changed");
}
public function closeGallery():void
{
TweenLite.to(loader, .5,{alpha:0, ease:Cubic.easeOut, delay:.0});
TweenLite.to(holder, .5,{alpha:0, visible:false , ease:Cubic.easeOut, delay:.5});
}
public function openGallery():void
{
addChild(holder);
TweenLite.to(loader, .5,{alpha:1, ease:Cubic.easeOut, delay:.5});
TweenLite.to(holder, .5,{alpha:1, visible:true , ease:Cubic.easeOut, delay:0});
}
}
}
Friday, February 20, 2009
Adobe AIR application - File System

So I had a little down time today, so I started writing an AIR application. The idea was to allow our admin folk to go paperless with their work order information. Essentially the programs is simply a data entry solution. It saves out an xml file based on the fields entered. It can also open the files with the the same format. So you can create, open, and modify an existing work order. The cool thing about it, is that it creates a file directory based on the File# entered. It also exports a jpeg of the form, for easy printing, since we still like our paper copies. Granted, it's sort of a glorified excel spreadsheet, and it's not finished yet. But it was a good exercise in working with the Filesystem class for Adobe Air, as well as the com.adobe.images package.
Thursday, February 19, 2009
Flex Builder - exploring the IDE
Recently I've started doing a little more work in Adobe Flex. I managed to get the free academic license from Adobe. At $250 and with a free academic version and SDK, Adobe is clearly trying to increase the reach of Actionscript development. Flex obviously isn't new, in fact the latest version v4 (currently Gumbo) is due out later this year. When I initially heard of Flex Builder I was expecting Flash without the time line, but after downloading the trial version (60 day trial, btw) I realized it's indeed a far more complex IDE than I had thought. Built on the open source Eclipse IDE, Flex Builder functions very intuitively.

At first, I was a little lost in the whole mxml and AS3 cross-code stuff. But eventually I realized the benefit of this logic. Flex makes so many of the monotonous interface development tasks really enjoyable. I would strongly suggest downloading the trial version and giving it a look. If you're a Flash Developer it can only help to understand a little bit about Flex. I'm working on developing a couple of desktop AIR applications built in Flex Builder.
Wednesday, February 18, 2009
Follow up on 360 Rotation Project

About 5.5 hours later the revised 360 Flash module is finally near completion. Thanks to the integration CS3 offers creating the .fla was pretty straightforward. In fact, it involved simply importing the .psd straight into Flash, making a few changes, and that was it. The file size is still a little large, but that has a lot to do with the 360 render. I ended up cutting the number of frames in half to cut down on size.
I’m using the AS3 preloader technique Lee Brimelow shows on www.gotoandlearn.com. Loading an external .swf into the loader.swf. Worked well, except that I noticed my reference to “stage” in the document class returned one of those obscure “null object reference” errors. Took me a while to debug it. Somehow the reference to the “stage” wasn’t registering as instantiated in the loader.swf.
(If anyone knows why, let me know)
Ultimately it was a smooth project start to finished.
http://www.mastertrackproductions.com/Licor/7700_loader.html
Monday, February 16, 2009
simulated 3D - 360 Rotation

The integration of 3D Graphics and Flash has come a long way over the past few months. With the advent of Papervision3D among other 3D engines, creating real-time 3D graphics in Flash is now a very tangible prospect. I intend to post more about Papervision3D and Collada file integration in the future.
However, the use of "simulated-3D" (for lack of a better term) is still very much in demand by clients. The process involves rendering an animated sequence (usually a 360 rotation of some sort) and then importing dozens (if not hundreds) of individual frames into a MovieClip in Flash.
Needless to say, it's not the most elegant means, but done sparingly and with efficiency in mind, it can produce stunning results.
I recently created a prototype for Licor Biosciences. I used a function that generated an integer based on the width of the stage - that integer was then used as the frame number of the corresponding MovieClip.
Here's the function I wrote
function giveDis(event:Event):void
{
var bX:Number = dragger.x
var bY:Number = dragger.y
var cX:Number = center.x
var cY:Number = center.y
distance = Math.round(Math.sqrt((bX) * (bX) + (cX) * (cX))/13.4);
trace(distance);
photon.gotoAndStop(distance);
}
In this case, the function is triggered by an ENTER_FRAME event. So it perpetually tracks the integer that the 'distance' variable produces.
[NOTE: 'dragger' here refers to the MovieClip used as the dragging mechanism
(i.e dragger.startDrag();) and 'center' is a second clip used at the edge of the stage.]
The distance formula shown is the Pythagorean Theorem rounded to the nearest integer and then devided by 13.4, which was a number I found by trial and error. It gave me a integer between 0 and 200 which was equal to the number of frames in my MovieClip.
(I'm sure a math genius out there could tell me why 13.4 it makes sense here.)
I'll be re-writing the code for this program shortly, and it'll be structured in the proper 'package' format.
The benefit of the code above is that it can be used for virtually any number of frames, on any stage, for any animation.
See the example here:http://www.mastertrackproductions.com/Licor/view360/Licor360.html
-Alchemist
Tuesday, February 10, 2009
e.target and MovieClip values
While working on a web project this week for IDSODISC I discovered an interesting way of handling events for movieclips in Actionscript. I set a value for each movieclip(as a button) I then used that value to store an additional movieclip, subsequently creating a single function which can be applied to what ever movieclip you click on. I've included a rough example below.
//code begins here----------------
img1.visible = false;
b1.value = img1
b1.addEventListener(MouseEvent.MOUSE_DOWN, callFunction);
function callFunction(e:MouseEvent):void
{
e.target.value.visible = true;
}
//------END-----
So essentially what this does is it makes the "value" of b1 visible. In this case, that would be img1. I'm not sure how this fits in with standard programming best practices. But the benefit here is, as long as a movieclip has a value - it can call that function.
to view the site visit: http://www.mastertrackproductions.com/ISODISC/ISODISC_loader.html
//code begins here----------------
img1.visible = false;
b1.value = img1
b1.addEventListener(MouseEvent.MOUSE_DOWN, callFunction);
function callFunction(e:MouseEvent):void
{
e.target.value.visible = true;
}
//------END-----
So essentially what this does is it makes the "value" of b1 visible. In this case, that would be img1. I'm not sure how this fits in with standard programming best practices. But the benefit here is, as long as a movieclip has a value - it can call that function.
to view the site visit: http://www.mastertrackproductions.com/ISODISC/ISODISC_loader.html
First Blog - Up and running.
Welcome to the Actionscriptology blog. This Blog is dedicated to pretty much anything RIA, Flex, Flash, Actionscript related. I hope to update this blog frequently with new discoveries, projects, tutorials and whatever else strikes me as relevant to the RIA movement. And I encourage anyone to submit ideas/corrections to anything I post. I myself am a novice to web programming, and my hope is that others will learn as I excavate Actionscriptology.
Subscribe to:
Comments (Atom)