Thursday, January 26, 2012

Reading A Zip File In ActionScript

import nochump.util.zip.ZipEntry;
import nochump.util.zip.ZipFile;

// use the embedded zip
[Embed(source="Archive.zip",mimeType="application/octet-stream")] private static var MyZip:Class;

// create the zip object from the byte array
var zipData:ByteArray = new MyZip() as ByteArray;
var zipFile:ZipFile = new ZipFile(zipData);

// reading the index file from the zip
var indexEntry:ZipEntry = zipFile.getEntry("index.xml");
var indexEntryByte:ByteArray = zipFile.getInput(indexEntry);
var files:XML = new XML(indexEntryByte.readUTFBytes(indexEntryByte.length));

Fully Qualified Class Name in ActionScript

To avoid naming conflicts, the fully qualified class name is used.  However, unlike Java, where you can simply use the fully qualified class name without doing an import, in ActionScript, you still have to do an import.

For example, say, you have two classes "playingtree.AwesomeClass" and "dancingtree.AwesomeClass"   Since the class name is the same, you have to use the fully qualified class name; otherwise, you would get a compiler error, because it doesn't know which class you refer to.  To solve this, you use the fully qualified name, meaning that you specify the class along with the package.  This is for those who are unfamiliar with it.

In summary, what's important to note here is that in ActionScript, you still have to do an import before you can use the fully qualified name.

E4X - Traversing XML With Namespace In ActionScript

Take this example:

var xml:XML =
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>;

To get the sequence XML, we first define the namespace and use it as follows:

var xs:Namespace = new Namespace("xs", "http://www.w3.org/2001/XMLSchema");

var sequenceXML:XMLList = xml.xs::element.xs::complexType.xs::sequence;


Friday, January 20, 2012

Armstrong Air Ultra V Tech 91 Furnace No Heat/No Flame

Problem:
Furnace seems to be working, but the fan simply blows out cold air.  There's no heat coming out whatsoever.  Can't even turn off heat using the thermostat. 

Solution:
Find out that the filter is dirty and that the burner is inflaming.  Replace the filter, and reset.

The furnace has two panels that can be taken off by lifting straight up to expose the inside.  You should see the handles with the word "lift."  Take off the top panel.  You should see several parts inside.  If you follow the gas pipe in, you should see the gas control which has a switch "on" and "off."  Next to the on/off switch, you should see a light.  That light is a diagnostic indicator.  On the backside of the panel that you take off, you should see the diagram and the information for the diagnostic light.  In my case, it flashes 4 times "Limit or Rollout Switch Open."  Above the gas control, you should see a rectangular box with a little circular plastic, look-through opening.  This is where you should see the flame.  In my case, I don't even see a flame. 

I need to reset.  To do this, you have to turn off the power to the furnace.  You should find a switch next to the furnace.  It should be very obvious.  It's just like a normal light switch.  Switching it off will turn off the furnace.  You should notice that the furnace is not running anymore.  After that, switch the gas control (described earlier) to off also. 

With those done, if you look beyond the gas control through to the back, you should see a brown rectangular circuit board with two wires running to it, with an arrow running in between.  The board is held up with two screws, one on top and one on the bottom.  Use a screwdriver, unscrew those and slowly pull out the board.  On the back of that board, you should see a big wire connecting the two connectors and a little black button with a silver cap.  Tap that silver cap a couple of times.  Put that board back where it was.  Turn the gas control to "on."  Turn the the power switch on.  If you look through the tiny circular opening, you should see the flame.  If you do, congratulations.  The furnace works again.

Disclaimer:  This solves my problem.  If it doesn't work for you, I'm sorry, but it may be something else.  If you don't feel comfortable troubleshooting yourself, call a professional.  When you work with electricity, fire and gas, it is dangerous, so be VERY, VERY CAREFUL.

Wednesday, January 11, 2012

Create A Zip File In Java

FileOutputStream destination = new FileOutputStream("Test.zip");
ZipOutputStream zip = new ZipOutputStream(destination);
zip.setMethod(ZipOutputStream.DEFLATED);
            
ZipEntry entry = new ZipEntry("test.txt");
zip.putNextEntry(entry);
zip.write(<file content>);
zip.closeEntry();

// write more entries
zip.close();
      

Tuesday, January 10, 2012

Java Copy and Download Files With Apache Commons Library

Take a look at org.apache.commons.io.FileUtils class.   It has methods that will make your life easier.

To download a remote file and save it to a local file:

FilesUtils.copyURLToFile(URL source, File destination)

Take a look at IOUtils class, too. 

Friday, January 6, 2012

Running XSLT in Visual Studio 2010

  • Open the XSL file
  • Open Properties window
  • Specify the XML file in the Input in the Properties window
  • Optionally, you can specify the Output also
  • From here, you have two options to run it:  Start XSLT Debugging or Start XSLT Without Debugging.  You can find these under the Debug menu or the XML menu.