Recent News

looping video in AS3

Posted by sortofme on April 30th, 2008
Actionscript:
  1. <pre>
  2. package {
  3.  
  4.     import com.onebyonedesign.extras.VideoLoop;
  5.     import flash.display.Sprite;
  6.     import flash.events.AsyncErrorEvent;
  7.     import flash.events.Event;
  8.     import flash.events.MouseEvent;
  9.     import flash.text.AntiAliasType;
  10.     import flash.text.TextField;
  11.     import flash.text.TextFieldAutoSize;
  12.     import flash.text.TextFormat;
  13.     import flash.text.TextFormatAlign;
  14.  
  15.     public class Main extends Sprite {
  16.  
  17.         private var isPlaying:Boolean = true;
  18.         private var videoLoop:VideoLoop;
  19.  
  20.         public function Main():void {
  21.             videoLoop = new VideoLoop("water.flv");
  22.             videoLoop.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError);
  23.             addChild(videoLoop);
  24.  
  25.             stage.addEventListener(MouseEvent.CLICK, adjustVideo);
  26.  
  27.             var info:TextField = new TextField();
  28.             info.selectable = false;
  29.             info.autoSize = TextFieldAutoSize.LEFT;
  30.             info.antiAliasType = AntiAliasType.ADVANCED;
  31.             var fmt:TextFormat = new TextFormat("_sans", 12, 0x939393);
  32.             fmt.align = TextFormatAlign.CENTER;
  33.             info.defaultTextFormat = fmt;
  34.             info.text = "Two second video looped.\nClick to pause/resume.";
  35.             info.x = 95;
  36.             info.y = 190;
  37.  
  38.             addChild(info);
  39.         }
  40.  
  41.         private function onAsyncError(aee:AsyncErrorEvent):void {
  42.             //  handle annoying async errors (such as the missing metadata property) here.
  43.         }
  44.  
  45.         private function adjustVideo(me:MouseEvent):void {
  46.             if (isPlaying) {
  47.                 videoLoop.pause();
  48.             } else {
  49.                 videoLoop.play();
  50.             }
  51.             isPlaying = !isPlaying;
  52.         }
  53.     }
  54. }</pre>

capture Jpeg live from webcam

Posted by sortofme on April 29th, 2008

For one of my projects that let's the user record a profile video through his webcam, I need to publish a JPEG from the recorded video to later display in an html video list.
After turning the web upside down, I found that byteArrays blog's approach seemed the most suitable one. But he works with AMFPHP, which I did not want to add to the other frameworks already involved with this project, and therefor reconstructed it using a simple PHP solution.
I will continue posting my progress here, and offer src files ASAP.

Another source I found, but haven't evaluated yet, because it is built in AS2, works with PHP's GD image library.

For more information on AMFPHP (aka flash remoting for PHP), which is a remoting service for flash applications, that basically allows flash movies to call remote server side applications. Here is an introduction, but I think that it deserves it's own topic in flashcrobat. I hopefully will soon have time to look deeper into it.

<update >

Ok I have come closer :

http://labs.findsubstance.com/2008/04/03/as3-upload-encode-images/

and :

http://www.hackszine.com/blog/archive/2008/04/encoding_jpegs_clientside_in_a.html

http://henryjones.us/articles/using-the-as3-jpeg-encoder

I am going to try to combine the infos found on several resources, and hope that as an outcome we will have a nice reusable application with which you can make a thumbnail of a clip recorded through your webcam. So let's spit in our hands:

AS3 clipboard functionality

Posted by sortofme on April 23rd, 2008

The System.setClipboard() method allows a SWF file to replace the contents of the clipboard with a plain-text string of characters. This poses no security risk. To protect against the risk posed by passwords and other sensitive data being cut or copied to clipboards, there is no corresponding "getClipboard" (read) method.

Flash and JavaScript

Posted by sortofme on April 21st, 2008

I will here collect a series of links of useful information on the interaction between flash and JavaScript, Until I have evaluated all relevant infos, to write a good summary on common practices.

  1. SWFObject has grown up! version 2.0
  2. The famous SWFObject to easily embed flash content in html, that was previously hosted on deconcept.com has now moved to google.code basically there are 2 ways to embed your swf into your HTML site:

    • static
    • dynamic

    more to come...
    her a basic code sample for the integration using swf object, including parameters, flashvars and attributes. (for many external interface interactions, you will need to give your swf an ID and a name)
    here the javascipt to embed:

    
    
    JavaScript:
    1. <script type="text/javascript" src="/js/swfobject.js"></script>
    2. <script type="text/javascript">
    3.     //vars and parameters for embedded swf
    4.     var flashvars = {   
    5.         UserID: "<?= $this->Member->username ?>"   
    6.     };
    7.     var params = { 
    8.         menu: "false",   
    9.         allowScriptAccess:"sameDomain",  
    10.         bgcolor:"0x151515" 
    11.     };
    12.     var attributes = { 
    13.         id: "myswf",       
    14.         name: "myswf"   
    15.         }
    16.  
    17.     swfobject.embedSWF("theSwf.swf", "swf-div", "333", "255", "9.0.0","expressInstall.swf", flashvars, params, attributes);
    18. </script>
    19. <!-- later in the html page comes the div tag where you want your swf to be embedded where you can put in your alternative text, in case someone has javascript disabled, or no flash plugin installed.-->
    20. <div id="swf-div">
    21.     You need Javascript activated and the flash player plugin installed to be able to view this content.<br/>The newest Flash Player can be downloaded here:<br/><br/>
    22.                 <a href="http://www.adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a>
    23. </div>
  3. external interface approach
  4. this seems to be till now the best and easiest reference I found on smooth communicatin between Javascript and the swf in both directions. unfortunatley this only seems to work in AS2. The old fscommand now has been replaced with the externalInterface class. more to read in the Adobe.liveDocs. found on: http://flexion.wordpress.com/ source files: onBoxNet

  5. AS3 Script Injection
  6. Complete and unmodified JavaScript and/or VBScript functions, class objects and applications are stored inside AS3 files using XML, and are then parsed, sent to the browser, and executed. This is an ideal solution for Flash/Flex developers who need JavaScript to interact with the user's browser, but might not have full access to the webpage or server that their SWF application is actually hosted on. Flash Ads, YouTube-style video players, and games that may be hosted across multiple (and possibly unforeseen) webpages are the first things that come to mind. on: actionscript.org

  7. Passing variable from JavaScript To AS3
  8. A brief and basic recollection about passing vars from JS to AS3. found on: metah.ch

  9. Local Connection Actionscript - Communicate between seperate Flash files
  10. Communication between two seperate flash files placed on the same page (or even running simultaneously on one machine) is a nice way to spread a project out. You can send variable, call functions, pretty much do anything in one swf from another. found on: blog.circlecube.com

  11. Flash and Google analytics
  12. This also fits in this cathegory, as most functionalities are handled by Javascript. I will update this entry after have=ing implemented the code on my current Project. found on: flashenabledblog.com

Instance Class or Superclass name: getQualifiedClassName()

Posted by sortofme on March 11th, 2008

sometimes, you want to know the instances class name or the superclass's name. AS3 offers a new function called getQualifiedClassName (flash.utils.getQualifiedClassName) to do just that:

Actionscript:
  1. var sprite:Sprite = new Sprite();
  2. trace(getQualifiedClassName(sprite)); // "flash.display::Sprite"
  3.  
  4. //or to retrieve the name of the super class, use:
  5. trace(getQualifiedSuperclassName(sprite)); // "flash.display::DisplayObjectContainer"

If you actually want to sieve through plenty of info about your instance, try describeType() (flash.utils.describeType).

Actionscript:
  1. var sprite:Sprite = new Sprite();
  2. var spriteDescription:XML = describeType(sprite);
  3. trace (spriteDescription);

try to see....(loads of data coming out here...)

what also fits in here is the use ofgetDefinitionByName()(flash.utils.getDefinitionByName).

collection of AIR resources

Posted by sortofme on March 11th, 2008

An attempt to gather all the information I tumble accross while researching for other things, that I will most probably need the next day or so and never find again, is to collect them herein this Post:

  1. AIRconditioning, a brilliant pdf summarising many of the most usefull and needed features of AIR.
  2. Encrypted Local Data. by Kevin Hoyt

encrypted Local Data - local login

Posted by sortofme on March 11th, 2008

One of the first big challenges in building an Air application, that is supposed to be functional on and off line, is the entry point into the application, the login. In this Post, I will explain how I built the Login for an application, including use of shared local objects, that logs the user also in, when he is offline. To give the user the minimum security, I will use for the Login the encrypted local store feature in Adobe AIR

derived from the article on Adobe.com from Kevin Hoyt.

avoid new window blocked by Firefox/IE

Posted by sortofme on March 6th, 2008

How annoying! You have your flash application, make a normal external link (a good old www basic), and then the browsers block your external link!, well there seems to be a work around:

Actionscript:
  1. function getURL(url:String,window:String="_blank"):void{
  2.     var broswer:String=ExternalInterface.call("function getBrowser(){return navigator.userAgent}") as String;
  3.     if(broswer.indexOf("Firefox")!=-1 || broswer.indexOf("MSIE 7.0")!=-1){
  4.         ExternalInterface.call('window.open("'+url+'","'+window+'")');
  5.     }else{
  6.         navigateToURL(new URLRequest(url),window);
  7.     }
  8. }

and the most important is set the wmode property is opaque or transparent.

courtesy of:
http://www.riaidea.com/article.asp?id=27(chinese Blog)

Somehow getURL() survived the AS3 code cull, an interesting approach to make it reusable can be found here on Steven Sacks blog. cheers for that one. Would be interesting to combine them to one. TODO:)

issues when installing the AIR 1 plugin for Flash CS3

Posted by sortofme on March 5th, 2008

If Beta 1 is installed, there are some orphan files that needed to be removed.

(Windows) HD:\Program Files\Adobe\Adobe Flash CS3\<lang>\First Run\Commands\
(Mac) HD:/Applications/Adobe Flash CS3/First Run/Commands
AIR - Application and Package Settings.jsfl
AIR - Package AIR File.jsfl

(Windows) HD:\Document and Settings\<username>\Local Settings\Application Data\Adobe\Flash CS3\<lang>\Configuration\Commands\ or
(Mac) HD:/Users/<username>/Library/Application Support/Adobe/Flash CS3/<lang>/Configuration/Commands/
AIR - Application and Package Settings.jsfl
AIR - Package AIR File.jsfl

Further, according to the Adobe website,  you first have to install plugin 9.0.2, then the AIR runtime, and at last plugin 9.0.3.

AS2 to AS3 migration of FMS2 Chat application

Posted by sortofme on March 3rd, 2008

While I was trying to migrate a textChat application written in AS2 to AS3, I encountered the problem, that I couldn't use

Actionscript:
  1. nc.msgFromSrvr = function (msg) {
  2. chatPrintDebug ("msgFromSrvr "+msg);

as because the reference nc.msgFromSrvr does not work this way anymore.
I found a way on the Adobe Forums suggesting this way:

Actionscript:
  1. var connection = new NetConnection();
  2. connection.client = this;
  3. connection.connect("rtmp://localhost/application", "userName");
  4.  
  5. var remoteUsers = new SharedObject();
  6. remoteUsers = SharedObject.getRemote("users_so",connection.uri,false);
  7. remoteUsers.connect(connection);
  8. remoteUsers.client=this;
  9.  
  10. function msgFromSrvr (msg:String) { trace(msg); };

In the server-side I wrote the next code:

Actionscript:
  1. application.onAppStart = function () { application.users_so = SharedObject.get("users_so",false); }
  2. application.onConnect = function (userName) { application.users_so.send("msgFromSrvr","message_txt"); }

It worked fine.

Recent Comments | Recent Posts


designed and coded by: noesi
bottom