RIAs 9 posts

28 March 2010

Posted by Frank Garofalo | Topic: RIAs

Find the min or max value for a specific XML node

Given the following XML:

<data_set>
<data_item>
<item_num>1
<item_text>Test 1
</data_item>
<data_item>
<item_num>2
<item_text>Test 2
</data_item>
<data_item>
<item_num>3
<item_text>Test 3
</data_item>
</data_set>

Now to find the maximum or minimum value for the node "item_num", below is a function to sort through the matching nodes of the specified element:

function findValue(xmlData:XMLList, nodeName:String, options:Object = null):String {
//XMLList of all the nodes with the specified name
//DATA_ITEM refers to the element name from our XML provided above
var col1:XMLList - new XMLList(xmlData.DATA_ITEMnodeName);
//Temporary Array
var temp:Array = new Array();

//Add all the relevant node values to a temporary array
for (var i:int = 0; i < col1.children().length(); i++) {
tmp.push(col1i);
}
//Sort the Array with the options provided as a parameter to the function
var sorted:Array = tmp.sort(options);
//Return the first value in the sorted array
return sorted0;
}

Now to use our function:

//xmlDataList is our incoming XML data from a file or source we have already parsed
trace ("Maximum Value: "+ findValue(xmlDataList, "ITEM_NUM", Array.DESCENDING|Array.NUMERIC));
trace("MIN Element1: " + findValue(xmlDataList, "ITEM_NUM", Array.NUMERIC));

Source: http://www.glodde.com/blog/default.aspx?id=25&t=AS3Flex-Find-the-minimum-or-maximum-v

24 March 2010

Posted by Frank Garofalo | Topic: RIAs

Saving over an existing XML file with AS 3 & Adobe AIR

After looking everywhere to try to figure out how to save data to an existing XML file, this is what I came up with:

//~~~~~~ IMPORT FLASH CLASSES
import flash.filesystem.*;

//~~~~~~ VARIABLE DECLARATION
var dataPathLocal:String = "com/frankgarofalo/data/"; //file path
var destinationFile:File = File.userDirectory; //Where to save the file on local computer
var sourceFile:File = File.createTempFile(); //Temporary File
var writeStream:FileStream = new FileStream(); //File Access
var xmlData:XML = new XML();

//~~~~~~ CODE
xmlData = 1; //XML Data
destinationFile = destinationFile.resolvePath(dataPathLocal);
//trace (destinationFile .exists);
//trace (destinationFile .nativePath);
//trace (destinationFile .url);

//Open File & Write to the File
writeStream.open(sourceFile, FileMode.WRITE);
writeStream.writeUTFBytes(xmlData);
writeStream.close();
sourceFile.copyToAsync(destinationFile, true);
sourceFile.addEventListener(Event.COMPLETE, dataSaved);

function dataSaved(e:Event):void {
trace ("~~~~~~ XML SAVED SUCCESSFULLY ~~~~~~");
}

Hopefully I didn't forget anything from copying over the code from my AS file. If I did or if you have any questions, please let me know. Here are some links for reference:

17 March 2010

Posted by Frank Garofalo | Topic: RIAs

Working with RotatableScalable ActionScript 3.0 Class

So I've been working with the ActionScript class RotatableScalable (which can be found on the NUI Group web site at: http://wiki.nuigroup.com/Building_Your_First_Multi-Touch_Application_in_Flash). However, I found a major flaw with that class that occurs when rotating an asset object that extends the RotatableScalable class. The object is rotated around its 0,0 coordinate (or in other words the top left corner of the asset). From preliminary testing, this proved to be very disorientating to users since the asset would spin away from the users' fingers.

Chris Yanc created a revised version of the RotatableScalable class called RotatableScalableRev which resolves that issue. For more details about his version, visit: http://www.cyancdesign.com/2009/05/understanding-rotatablescalable/

I'm so glad to get this working correctly now - thanks Chris! :D

15 March 2010

Posted by Frank Garofalo | Topic: RIAs

Actionscript 3 - EmbedFont text disappear solution

I've been working on some ActionScript 3.0 code within Adobe Flash CS4. I needed to rotate a dynamic textfield but I was running into problems with the embedFont = true; code. I finally found a solution on an Adobe Developer Connection post titled "Embedded Fonts" under the Quick Start section (http://www.adobe.com/devnet/flash/quickstart/embedding_fonts/):

// Create a new instance of the Font1 symbol from the document's library.
var myFont:Font = new Font1();

/* Create a new TextFormat object, and set the font property to the myFont
object's fontName property. */
var myFormat:TextFormat = new TextFormat();
myFormat.font = myFont.fontName;
myFormat.size = 24;

/* Create a new TextField object, assign the text format using the
defaultTextFormat property, and set the embedFonts property to true. */
var myTextField:TextField = new TextField();
myTextField.autoSize = TextFieldAutoSize.LEFT;
myTextField.defaultTextFormat = myFormat;
myTextField.embedFonts = true;
myTextField.text = "The quick brown fox jumped over the lazy dog.";
addChild(myTextField);
24 September 2009

Posted by Frank Garofalo | Topic: RIAs

Distributable Player Solution

"The distributable player solution enables developers to create rich applications for the latest version of Adobe Flash Lite and directly distribute their content to millions of open OS smartphones, providing a better on-device user experience." (Source: Adobe Labs - Distributable Player; Link: http://labs.adobe.com/technologies/distributableplayer/ )

Very interesting work that Adobe is doing.

Video:
24 September 2009

Posted by Frank Garofalo | Topic: RIAs

Adobe Wave API for Broadcast Notifications with PHP

Adobe Wave is a new real-time notification system currently in Adobe Labs. Those who download the desktop application (which is an Adobe AIR app) can then subscribe to receive notifications from their favorite sites - more about Adobe Wave: http://labs.adobe.com/technologies/wave/

I was working on a web project and wanted to integrate the Adobe Wave service. After reviewing the REST API for Adobe Wave is was quite confused. Christian Grobmeier developed a WordPress plug-in for Adobe Wave (http://blog.grobmeier.de/2009/08/04/adobe-wave-wordpress-plugin-finished.html). After downloading and making some modifications to his PHP code I was able to get my web project to connect to the Adobe Wave services. Note: If you want to connect to the Adobe Wave services you must first apply/register for a publisher account: https://ps-wave.adobe.com/portal/PublisherAdmin.html

Here is a zip file to download: http://web.ics.purdue.edu/~fgarofal/examples/WaveIntegrationDemo.zip

In the below code example, you will need the PHP classes from the zip file in the link above. Also you will need to swap out "adobe_id" and "adobe_pass" with your Adobe account information once you have been approved as a publisher. Assuming you have an approved publisher account, then you can create a "feed" from the feed you will need to replace "URI" with the URI code you receive from the Wave Publisher Portal for that specific feed.

include('APIToken2.php');
include('WaveException.php');
include('BroadcastMessage.php');

//Prepare Post
$post_string = "Hello Adobe Wave";
$post_string = substr($post_string, 0, 140);
//Build Post
$post = array();
$post0->post_title = $post_string;
$post0->guid = "http://labs.adobe.com/technologies/wave/";

$result = waveIntegration_send('adobe_id','adobe_pass','URI', $post);

if ($result == true) {
echo 'Success';
} else {
echo 'Error';
}

//waveIntegration_send
//---------------------
//Input: string (username), string (password), array (post: string title, string url link)
//Output: bool (true - successful, false - error)
function waveIntegration_send($username, $password, $topic, $posts) {
if($username == '' || $password == '' || $topic == '') {
// no action - error would be nice
return;
}

$title = $posts0->post_title;
$link = $posts0->guid;

$token = APIToken::getInstance($username, $password);
$tokenValue = $token->getToken();

$message = new BroadcastMessage(
$tokenValue,
$topic,
$title, $link);
$code = $message->send();
if ($code >= 200 && $code < 300) {
return true;
} else {
return false;
}
}
If you have any questions, please let me know. For other resources check out the Adobe Wave section of the Adobe Forums: http://forums.adobe.com/community/labs/wave
12 December 2008

Posted by Frank Garofalo | Topic: RIAs

Preloader in ActionScript 3.0

This code snippet is based off an example from http://newmovieclip.wordpress.com/2007/03/14/preloader-in-fl ash-cs3-actionscript-30-way/


package {
import flash.system.Capabilities;
import flash.system.fscommand;
import flash.display.Loader;
import flash.display.LoaderInfo;
import flash.display.MovieClip;
import flash.net.URLRequest;
import flash.events.Event;
import flash.events.ProgressEvent;
import flash.text.TextField;


public class mast_2009_loader extends MovieClip {
//Variables
var myLoader:Loader = new Loader();
var myRequest:URLRequest = new URLRequest("mast_2009b.swf");
var loadProgress_txt:TextField = new TextField();

//Constructor
public function mast_2009_loader() {

//Listeners
myLoader.contentLoaderInfo.addEventListener(Event.OPEN,showPreloader);
myLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,showProgress);
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,showLoadResult);

//Load Request
myLoader.load(myRequest);
}
function showPreloader(evt:Event):void {
addChild(loadProgress_txt);
}
function showProgress(evt:ProgressEvent):void {
loadProgress_txt.text = "loaded:"evt.bytesLoaded" from "evt.bytesTotal;
}
function showLoadResult(evt:Event):void {
removeChild(loadProgress_txt);
addChild(myLoader);
}
}
}
25 September 2008

Posted by Frank Garofalo | Topic: RIAs

Adobe Integrated Runtime (AIR)

Adobe

The Adobe Integrated Runtime was launched by Adobe Systems in February 2008. Prior to the launch it was code-named Apollo. Adobe describes the AIR technology as a cross-operating system runtime that allows web application developers to use their existing web development skills (HTML, Javascript, Adobe Flash, Adobe Flex, Ajax) to build and deploy rich Internet applications to the desktop. Retreived on February 10 2008 from http://labs.adobe.com/downloads/air.html?promoid=ZMIZ

25 September 2008

Posted by Frank Garofalo | Topic: RIAs

Adobe Thermo

Thermo is a new technology ;still in the Adobe Labs. The goal is to help connect the design process with the developer process.

Adobe Labs - Thermo: http://labs.adobe.com/wiki/index.php/Thermo

Here is a video about it: http://www.adobe.com/newsletters/edge/december2007/video/index.html

Post to this topic


Search

Login | Register

Topics

Twitter (follow me)

  • after waiting 10 hrs today for the technician, finally got Time Warner Cable & Internet - not impressed; @jefftwc
  • I'm at The Foundry at McCoy's (4057 Pennsylvania Ave, on Westport Rd, Kansas City). link
  • Now I can get the FULL internet on my Android with Adobe Flash, can't say that about an iPhone
  • @not_for_humans OTA
  • Go flash 10.1 for my Droid

Follow me on Twitter: @fgarofalo

Download Adobe Wave now!

This application requires Adobe® AIR™ to be installed for
Mac OS or Windows.