Nov
21
2008
0

Using the NumberBase class to format and parse Strings

So yesterday I found myself in need of taking calculated values and convert decimal numbers into something usable for filenames. In this case I needed to replace the decimal with something other than the standard period notation. I did this using the NumberBase class.

  1. <mx:Application
  2.     xmlns:mx        = "http://www.adobe.com/2006/mxml"
  3.     layout    = "vertical"
  4.     creationComplete= "createComplete()"
  5.     >
  6.     <mx:TextArea
  7.         id      = "txtArea1"
  8.         text        = "Click the button to format the number."
  9.         />
  10.     <mx:Button
  11.         id      = "btnFormatUL"
  12.         click      = "formatUL()"
  13.         label      = "Format decimal"
  14.         />
  15. </Application>

and the related actionscript

  1. import mx.formatters.NumberBase;
  2. import mx.formatters.NumberBaseRoundType;
  3.  
  4. private var num:Number = 123.4556789998;
  5. private var nb:NumberBase = new NumberBase(".","","_","");
  6.  
  7. private function createComplete():void
  8. {
  9.     txtArea1.text = num.toString();
  10. }
  11.  
  12. private function formatUL():void
  13. {
  14.     var numString:String = num.toString();
  15.     var nextString:String = nb.formatRoundingWithPrecision(numString,NumberBaseRoundType.DOWN,3);
  16.     nextString = nb.formatDecimal(nextString);
  17.     txtArea1.text = nextString;
  18. }

Where Input is 123.4556789998, Output is 123_455

Written by jedmtnman in: Uncategorized |
Nov
21
2008
0

Adobe’s Stellar Customer Support

So, I recently submitted a customer support request to Adobe, beyond the fact that it took a week for them to respond, when they did, they submitted a general request for the wrong product!!

I submitted a request for Flex Builder….

Hi, I have an academic license for Flex Builder, and am trying to get my
version working after a problem with Flash 10 last week. So
I am taking this time to do a re-install on a fresh OS image.
In doing so, I have found several vague and conflicting statements in the
documentation on adobe.com. Please clarify…
On the downloads page for flex builder 3.0.1 it says that the Flex Builder 3
Professional plug-in for Eclipse is supported by Eclips
e 3.3 or higher
http://www.adobe.com/cfusion/entitlement/index.cfm?e=flex3email#
but if you click on the system requirements link right next to the download
button on the page above, it says that the supported bui
ld of eclispe is “3.2.2 (for plugin configuration)”.
What does that “plugin configuration” mean, does it mean that you have to
install Eclipse 3.2.2, then install Flex Builder, then ins
tall Eclipse 3.4? And why is it different than what is listed on the downloads
page? And if so, how do you do install the plugin wit
h Eclipse 3.4? And is it Eclipse 3.4 or 3.4.1? Do you have a link to
instructions?
Also, I am on a Mac platform and the system req. says that “NOTE: Flex
Builder 3.0.1 does not run with Java for Mac OS X 10.5 Update
1 / 64 bit Java SE 6 version 1.6.0_05.”
If I am running build 1.6.0_07-b06-153 am I OK? Or does the sys. req mean
that it is 1.6.0_05 and LATER? The sys. Req. page does not
specify.
Please, this is really confusing…

And got this respose…

Hello Jed
Thank you for contacting Adobe Customer Service.
I apologize for the delay in responding to your case.
In regards to your issue we would like to inform you that eligibility
dates for cs3 upgrades are over long back so now you
need to purchase an upgrade for cs4.

Wow Thanks Adobe! I’m sure glad I need to upgrade my copy of Illustrator to get support for Flex Builder. Thanks for reading my email, or um is reading the customer support email an optional task when responding? Sorta like,

Dear Apple, my macbook pro isn’t booting, please help.

Dear Jed, I’m sorry we are no longer supporting version 6 of Quicktime Pro, please upgrade to quicktime pro 7.

Written by jedmtnman in: Uncategorized |
Oct
16
2008
0

Notes for Adobe Flex Presentation

I am giving a presentation on Flex Applications to Dr. Snyder’s Web Programming Class on Tuesday October 21. 

 I will post all my notes and sample code for the lecture here.

Flash Presentation

Below is the first example code to show the connection between the file system and an AIR application.

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Application
  3.     xmlns:mx="http://www.adobe.com/2006/mxml"
  4.     layout="vertical"
  5.     creationComplete="attentionScores.send()">
  6.    
  7.     <mx:HTTPService
  8.         id="attentionScores"
  9.         url="attention.xml"
  10.         result="serviceHandler(event)"
  11.         resultFormat="e4x"/>
  12.    
  13.     <mx:Script>
  14.         <![CDATA[
  15.             import mx.collections.ArrayCollection;
  16.             import mx.rpc.events.ResultEvent;
  17.            
  18.             [Bindable]
  19.             private var dataPoints:ArrayCollection;
  20.            
  21.             private function serviceHandler(event:ResultEvent):void
  22.             {
  23.                 trace(event.result..score);
  24.                 dataPoints = new ArrayCollection();
  25.                 for each (var d:XML in event.result..score)
  26.                 {
  27.                     dataPoints.addItem({
  28.                         x:(d.imagePosition),
  29.                         y:(d.atScore)
  30.                         });
  31.                 }//end for
  32.             }
  33.         ]]>
  34.     </mx:Script>
  35.  
  36.     <mx:SeriesSlide
  37.         id="slideIn"
  38.         duration="2000"
  39.         direction="down"/>
  40.  
  41. <mx:Panel
  42.     title="Line Chart Example">
  43.    
  44.     <mx:LineChart
  45.         id="lineChart1"
  46.         dataProvider="{dataPoints}">
  47.        
  48.         <mx:horizontalAxis>
  49.             <mx:CategoryAxis
  50.                 categoryField="x"/>
  51.         </mx:horizontalAxis>
  52.        
  53.         <mx:series>
  54.             <mx:LineSeries
  55.                 yField="y"
  56.                 displayName="Attention Score"
  57.                 showDataEffect="slideIn"/>
  58.         </mx:series>
  59.        
  60.     </mx:LineChart>
  61.    
  62.     <mx:Legend dataProvider="{lineChart1}"/>
  63.  
  64. </mx:Panel> 
  65.    
  66. </mx:Application>

And the AIR application

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:WindowedApplication
  3.     xmlns:mx="http://www.adobe.com/2006/mxml"
  4.     layout="vertical">
  5.    
  6.     <mx:Script>
  7.         <![CDATA[
  8.         import flash.filesystem.File;
  9.         import flash.filesystem.FileStream;
  10.         import mx.collections.ArrayCollection;
  11.                
  12.         /*
  13.         **  array to store the image files   
  14.         */   
  15.         private var images:Array = new Array();
  16.  
  17.         /*
  18.         **  array collection to create random ratings values 
  19.         */   
  20.         [Bindable]
  21.         private var imageAC: ArrayCollection;
  22.        
  23.         private var xml:String = "";
  24.         /**
  25.             Function: dirSelect
  26.            
  27.             Description:
  28.              * Chooses the directory containing images
  29.            
  30.            
  31.             Parameters:
  32.             event:Event
  33.            
  34.             Returns:
  35.             void
  36.            
  37.             See Also:
  38.             none
  39.            
  40.             Created:
  41.             Jed Schneider 2008/10/20
  42.            
  43.             Modified:
  44.             $Id:$
  45.         */   
  46.         private function selectDir(event:Event):void
  47.         {
  48.             var file:File = new File();
  49.             file.addEventListener(Event.SELECT, dirSelectHandler);
  50.             file.browseForDirectory("Select the Image Folder");
  51.         }
  52.        
  53.        
  54.         /**
  55.             Function: dirSelectHandler
  56.            
  57.             Description:
  58.              * Event fires when the selected directory containing images is returned.
  59.              * The directory structure is scanned for hidden files and hidden
  60.              * files are ingnored.
  61.              * For real image files (no file filtering here) a random number is generated
  62.              * between 25 and 100.
  63.              * The data is placed into the data grid and the graph is created with the values
  64.              * from the random number generation.
  65.            
  66.             Parameters:
  67.             event:Event
  68.            
  69.             Returns:
  70.             void
  71.            
  72.             See Also:
  73.             selectDir
  74.            
  75.             Created:
  76.             Jed Schneider 2008/10/20
  77.            
  78.             Modified:
  79.             $Id:$
  80.         */   
  81.         private function dirSelectHandler(event:Event):void
  82.         {
  83.             trace(event.toString());
  84.             var selectedDir:File = new File(event.currentTarget.nativePath);
  85.             images = selectedDir.getDirectoryListing();
  86.             imageAC = new ArrayCollection();
  87.            
  88.             for(var i:int=0; i<images.length; i++)
  89.             {
  90.                 /*
  91.                 **   check to see if file is hidden by the file system   
  92.                 */
  93.                 if(!images[i].isHidden)
  94.                 {
  95.                     /*
  96.                     **  create random number 
  97.                     */
  98.                     var rand:int = new int;
  99.                     rand = Math.random()*100;
  100.                         if (rand<=25)
  101.                         {
  102.                             rand+=25;
  103.                         }//end if
  104.                    
  105.                     /*
  106.                     **  creating the array collection
  107.                     **  with evaluated values.   
  108.                     */
  109.                     imageAC.addItem({thumbnail:(images[i].name),
  110.                                      location:(images[i].nativePath),
  111.                                      imagePosition: (i),
  112.                                      attentionScore: (rand)});
  113.                 }//end if
  114.             }//end for
  115.             imageAC.refresh();
  116.             barChart.dataProvider = imageAC;
  117.         }   
  118.         /**
  119.             Function: writeXML
  120.            
  121.             Description:
  122.              * creates a string that contains the output in XML.
  123.            
  124.             Parameters:
  125.             none
  126.            
  127.             Returns:
  128.             void
  129.            
  130.             See Also:
  131.             none
  132.            
  133.             Created:
  134.             Jed Schneider 2008/10/20
  135.            
  136.             Modified:
  137.             $Id:$
  138.         */   
  139.         private function writeXML():void
  140.         {
  141.            
  142.             //xml encoding
  143.             xml +=  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "\n" + "\n";
  144.            
  145.             //header comment section
  146.             xml +=   "<!--"  + "\n"
  147.                 +   "****************************************************************************************************" + "\n"
  148.                 +   "**"   + "\n"
  149.                 +   "**"   + "\n"
  150.                 +   "**"   + "\t" + "File Name: " + "attention.xml" + "\n"
  151.                 +   "**"   + "\t" + "Project Description" + " Project Settings XML file" + "\n"
  152.                 +   "**"   + "\n"
  153.                 +   "**"   + "\n"
  154.                 +   "****************************************************************************************************"
  155.                 +   "-->"
  156.                 +   "\n" + "\n" ;
  157.                        
  158.             //root open tag  
  159.             xml += "<attention>" + "\n";
  160.            
  161.             //individual tags
  162.             for (var i:int=0; i<imageAC.length; i++)
  163.             {
  164.                 xml += "\t"     + "<score>"                 + "\n";
  165.                 xml += "\t\t"   + "<imagePosition>"     + "\n";
  166.                 xml += "\t\t\t" + imageAC[i].imagePosition  + "\n";
  167.                 xml += "\t\t"   + "</imagePosition>"   + "\n";
  168.                 xml += "\t\t"   + "<atScore>"                 + "\n";
  169.                 xml += "\t\t\t" + imageAC[i].attentionScore + "\n";
  170.                 xml += "\t\t"   + "</atScore>"             + "\n";
  171.                 xml += "\t"     + "</score>"             + "\n";   
  172.             }//end for 
  173.            
  174.             //root close tag
  175.             xml += "</attention>";   
  176.         }
  177.        
  178.         /**
  179.             Function: saveToFile
  180.            
  181.             Description:
  182.              * Saves the xml string to an xml file named attention.xml on the desktop.
  183.            
  184.             Parameters:
  185.             none
  186.            
  187.             Returns:
  188.             void
  189.            
  190.             See Also:
  191.             none
  192.            
  193.             Created:
  194.             Jed Schneider 2008/10/20
  195.            
  196.             Modified:
  197.             $Id:$
  198.         */   
  199.         private function saveToFile():void
  200.         {
  201.             writeXML();
  202.             trace(xml);
  203.             var xmlFile:File = File.desktopDirectory.resolvePath("attention.xml");
  204.             var fs:FileStream = new FileStream();
  205.             fs.open(xmlFile, FileMode.WRITE);
  206.             fs.writeUTFBytes(xml);
  207.             fs.close();
  208.         }
  209.        
  210.        
  211.         ]]>
  212.     </mx:Script>
  213.    
  214.     <mx:HBox>
  215.         <mx:Button
  216.             id="btnGetFolder"
  217.             label="Select Folder"
  218.             click="selectDir(event)"
  219.         />
  220.         <mx:Button
  221.             id="btnSave"
  222.             label="Save to XML"
  223.             click="saveToFile()"
  224.         />
  225.     </mx:HBox>
  226.    
  227.     <mx:VDividedBox>
  228.         <mx:Panel
  229.             width="100%">
  230.             <mx:AdvancedDataGrid
  231.             id="grid"
  232.             dataProvider="{imageAC}"
  233.             width="100%"
  234.             height="100%">
  235.                 <mx:columns>
  236.                     <mx:AdvancedDataGridColumn
  237.                         dataField="thumbnail"/>
  238.                     <mx:AdvancedDataGridColumn
  239.                         dataField="location"/>
  240.                     <mx:AdvancedDataGridColumn
  241.                         dataField="attentionScore" />
  242.        
  243.                 </mx:columns>
  244.             </mx:AdvancedDataGrid>
  245.         </mx:Panel>
  246.            
  247.         <mx:Panel>
  248.             <mx:BarChart
  249.                 id="barChart">
  250.             <mx:verticalAxis>
  251.                 <mx:CategoryAxis categoryField="imagePosition"/>
  252.             </mx:verticalAxis> 
  253.        
  254.            
  255.             <mx:series>
  256.                 <mx:BarSeries
  257.                     yField="imagePosition"
  258.                     xField="attentionScore"
  259.                     displayName="Attention Score"
  260.                 />
  261.             </mx:series>
  262.             </mx:BarChart>
  263.         </mx:Panel> 
  264.     </mx:VDividedBox>
  265.    
  266. </mx:WindowedApplication>
Written by Jed Schneider in: Coding | Tags: , ,
Oct
16
2008
0

Flex.org RIA Student Rep

I have applied to be the Student Representative for Midlands Tech college. Please contact me if you would like to know more information about becoming involved in Rich Internet Application development. As soon as I am accepted as the rep, I will post information about our first meeting.

Written by Jed Schneider in: Coding |
Oct
09
2008
0

Saturday Cross Practice

Hey everybody. Follow the link at the top of my blog to learn more. We are racing bikes in Columbia these days.

Written by Jed Schneider in: cyclocross | Tags: ,
Oct
08
2008
1

This is a test of code highlighting

Well, let me try it out the code syntax highlighting.

 

  1. public class HelloWorld
  2. {
  3. public static void main(String [] args)
  4.    {
  5.     System.out.println( "Hello World");
  6.    }
  7. }
Written by Jed Schneider in: Coding | Tags:

Powered by WordPress | Aeros Theme | TheBuckmaker.com WordPress Themes