Archive for the 'Flash 10' Category

How to create and load fontSwf files and use the loaded swf’s embedded font at runtime.

I just made a video tutorial that shows you how to:

  1. Create a swf with an embedded font.
  2. Create an application and loads that swf and pulls the embedded font from the loaded swf.

This is really simple and really smart if you need to have multiple fonts in your application.

FYI: once again for best video quality use the fullscreen button.

Have a look at the new Flash CS4 with us at 6pm at kayak’s

Oct 8th at 6pm join the AS3 Apex group for a hands on look at the new version of flash.

kayak’s is located at:

276 North Skinker Blvd.
St. Louis, MO 63130

Flash Player 10 is here - Flash on!

http://www.adobe.com/products/flashplayer/

Have a look at the really cool promotion video adobe has on the Flash player 10 page.

By the way go update your player!

Flash 10’s BitmapData.histogram is really slow?

I have been playing with BitmapData type and getPixelAt to make histograms. When I seen that the flash 10's BitmapData has a new method called histogram I thought it was a new improvement on analyzing BitmapData. Boy was I wrong. it's really really slow and I don't have clue why. Bug maybe??

Here's the code for any one who thinks it maybe that. Whats your thoughts?

FYI: with a for loop and getPixelAt I could still get 25fps at 1ms cycles. Though I have yet to see the frame rate for histogram, I cant event get close to a 1fps.

Actionscript:
  1. package
  2. {
  3.     import flash.display.BitmapData;
  4.     import flash.display.MovieClip;
  5.     import flash.display.Shape;
  6.     import flash.display.Sprite;
  7.     import flash.events.AsyncErrorEvent;
  8.     import flash.events.Event;
  9.     import flash.events.TimerEvent;
  10.     import flash.geom.Rectangle;
  11.     import flash.media.Video;
  12.     import flash.net.NetConnection;
  13.     import flash.net.NetStream;
  14.     import flash.utils.getTimer;
  15.     import flash.display.BlendMode;
  16.     import flash.utils.Timer;
  17.    
  18.     public class Main extends Sprite
  19.     {
  20.        
  21.         private var graphic1:Shape;
  22.         private var graphic2:Shape;
  23.         private var graphic3:Shape;
  24.         private var vect:Vector.<Vector.<Number>> ;     
  25.         private var bmd:BitmapData;
  26.         private var video_mc:MovieClip;
  27.        
  28.         private var rect:Rectangle;
  29.        
  30.        
  31.         public function Main():void
  32.         {
  33.             graphic1 = new Shape();
  34.             graphic2 = new Shape();
  35.             graphic3 = new Shape();
  36.            
  37.             stage.scaleMode = "noScale";
  38.             perspectiveDemo();
  39.  
  40.             bmd = new BitmapData(video_mc.width, video_mc.height);
  41.            
  42.             addChild(graphic1);
  43.             addChild(graphic2);
  44.             addChild(graphic3);
  45.            
  46.             graphic1.blendMode = BlendMode.SCREEN;
  47.             graphic1.x = 30;
  48.             graphic1.y = 200;
  49.             //graphic1.scaleY = .15;       
  50.            
  51.             graphic2.blendMode =BlendMode.SCREEN;
  52.             graphic2.x = 30;
  53.             graphic2.y = 200;
  54.             //graphic2.scaleY = .15;       
  55.            
  56.             graphic3.blendMode = BlendMode.SCREEN;
  57.             graphic3.x = 30;
  58.             graphic3.y = 200;
  59.             ///graphic3.scaleY = .15;
  60.            
  61.         }
  62.  
  63.        
  64.         private function perspectiveDemo():void
  65.         {
  66.            
  67.             video_mc = new MovieClip();
  68.             addChild(video_mc);
  69.             video_mc.x = 30;
  70.             video_mc.y = 30;
  71.            
  72.             var video:Video = new Video(320, 140);
  73.             var nc:NetConnection = new NetConnection();
  74.             nc.connect(null);
  75.             var ns:NetStream = new NetStream(nc);
  76.             ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, handleFakeError);
  77.            
  78.            
  79.             video_mc.addChild(video);
  80.             video_mc.x = 400;
  81.             video.attachNetStream(ns);
  82.             ns.play("http://gfxcomplex.com/labs/wall-e-tlr3_h320.mov");
  83.            
  84.             rect = new Rectangle(0, 0, 140, 300)
  85.            
  86.             var timer:Timer = new Timer(100);
  87.             timer.addEventListener(TimerEvent.TIMER, checkColor3);
  88.             timer.start();
  89.    
  90.         }
  91.        
  92.         private function handleFakeError(e:AsyncErrorEvent):void
  93.         {
  94.                 //
  95.         }
  96.        
  97.        
  98.         private function checkColor3(e:TimerEvent):void {
  99.  
  100.             bmd.draw(video_mc);
  101.            
  102.             vect = bmd.histogram(rect);
  103.            
  104.            
  105.             for (var i:int = 0; i <256; i++)
  106.             {         
  107.                
  108.                
  109.                 graphic1.graphics.lineStyle(.25, 0xff0000);
  110.                 graphic1.graphics.moveTo(i, 0);
  111.                 graphic1.graphics.lineTo(i, -(vect[0][i]));
  112.                
  113.                 graphic2.graphics.lineStyle(.25, 0x00ff00);
  114.                 graphic2.graphics.moveTo(i, 0);
  115.                 graphic2.graphics.lineTo(i, -(vect[1][i]));
  116.                
  117.                 graphic3.graphics.lineStyle(.25, 0x0000ff);
  118.                 graphic3.graphics.moveTo(i, 0);
  119.                 graphic3.graphics.lineTo(i, -(vect[2][i]));
  120.  
  121.             }
  122.             graphic1.graphics.clear();
  123.             graphic1.graphics.clear();
  124.             graphic1.graphics.clear();
  125.         }
  126.     }
  127. }