Axiis ColumnChart for Beginners (Spanish)

Hi there,

I just uploaded my first videotutorial on how to creat columncharts with axiis. I hope you like it.

The code will be uploaded in the next days.

Cheers,

Christian

New Artwork updated

I just updated some of a kind of artwork of mine. This is more a personal thing, because I always liked to draw the first thing that comes into my mind. This was created end of 2008 when I was taking my first clases of Administration. Feel free to comment.

This images are also in Flickr.

Christian

Classes must not be nested / An internal build error has occurred. Right-click for more information.

I have been getting in the past weeks this error everytime I use Flex Builder 4 alpha in Linux. It happens randomly. Error

My solution is to change the compiler in FlexBuilder. Just rightclick on the project Folder -> -> Propeties -> Flex Compiler -> Flex SDK Version . Change to another version. And then change it back.

post3

DataBinding and Model for Newby’s

After learning how to create a custom Event, I decided to try to make a DataBinding Model. Finally I did it.

Again, I decided to create the same application but with a Model as in my previous post.

This time I needed to show/hide a button in the main application when the user clicked on a button in the component. I extended the code, by trying to manipulate a second component.

This is the final file:

1. Step

First you have to create a Actioncript Class. In my case I created it in a Model Folder. I used a Singleton Template I found on the web. It basically creates an instance and checks that the instance is not repeated. First the template:

package model
{

  public class ButtonModel
  {
     
     // HERE YOU SHOULD CREATE THE GLOBAL VARIABLES

     
     private static var instance:ButtonModel;
 
     public function ButtonModel()
     {
 if( instance != null )
 {
    throw( new Error( "there can be only one instance of ChatModel" ) );
 }  
     }

     public static function getInstance():ButtonModel
     {
 if( instance == null )
 {
    instance = new ButtonModel();
 }
     return instance;
     }
  }
}

Now you can define new Variables. In this case I needed a Boolean, which I call ButtonVisible

[Bindable]
public var ButtonVisible:Boolean = true;

2. Step

Now that I defined a new Bindable Variable, I can access it everywhere I want, lets say the main application:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute" xmlns:components="components.*" viewSourceURL="srcview/index.html">
 
 <mx:Script>
  <![CDATA[
  <b>import model.ButtonModel;</b>
 ]]>
 </mx:Script>
 
 <mx:VBox>
 
  <components:Component1 />
  <mx:Button id="AppButton" label="AppButton"
  visible="<b>{model.ButtonModel.getInstance().ButtonVisible}</b>" />
  <components:component2 />
 
 </mx:VBox>
 
 
</mx:Application>

3. Step

Lastly I can manipulate it in a component.

<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" >
 <mx:Script>
  <![CDATA[
 
   import model.ButtonModel;
     
   public function clickHandler(e:MouseEvent):void {
    if(model.ButtonModel.getInstance().ButtonVisible == true) {
     model.ButtonModel.getInstance().ButtonVisible = false;
    } else {
     model.ButtonModel.getInstance().ButtonVisible = true;
    }
   }
  ]]>
 </mx:Script>
 
 <mx:Button id="compButton" label="ComponentButton" visible="true"
  click="clickHandler(event)"/>

</mx:Canvas>

Hope it helps.

ChristianDataBindingExample

What if phps mail() doesn't work: Yet another workaround.

A client needed a basic contact form, but the webhost didn’t allow mail() in their scripts. This is what I did:

1. Step

I created a form that sends the required info to this file: createxml.php.

function writeXML($name, $email, $text, $newsletter="true")
{
    if (getenv(HTTP_X_FORWARDED_FOR)) {
 $ip_address = getenv(HTTP_X_FORWARDED_FOR);
    } else {
 $ip_address = getenv(REMOTE_ADDR);
    }

    $myFile = "form.xml";
    $fh = fopen($myFile, 'a');

    if($fh)
    {
 $rvar = true;
    } else {
 $rvar = false;
    }

    $today = date("F j, Y, g:i a");
    $stringData = "&lt;form&gt;\n &lt;name&gt;$name&lt;/name&gt;\n &lt;email&gt;$email
       &lt;/email&gt;\n &lt;ttexto&gt;$text&lt;/ttexto&gt;\n &lt;newsletter &gt;
       $newsletter&lt;/newsletter&gt;\n &lt;ip&gt;$ip_address
       &lt;/ip&gt;\n &lt;date&gt;$today&lt;/date&gt;\n&lt;/form&gt;\n"
;
    fwrite($fh, $stringData);
    fclose($fh);

    return $rvar;

}

What the function does is to create a xml file (form.xml) with the following structure:

<form>
  <name>$name</name>
  <email>$email</email>
  <ttexto>$text</ttexto>
  <newsletter>$newsletter</newsletter>
  <ip>$ip_address</ip>
  <date>$today</date>
</form>

2. Step

In my Linux machine I created a script calling the form.xml file every 30 min. If there was a diference in the file he downloads with the file he downloaded 30 min ago, he would send an email to the person who needs to know if a new email arrived.

Here the script (checkmail.sh):

#!/bin/sh
cd ~/pr/
wget http://www.somedomain.com/form.xml
diff form.xml form.xml.old
if [ $? = 1 ];then
/usr/local/bin/email -s "New Web Mail" cwaidelich@emailme.com &lt;  mailtext.txt
fi
rm form.xml.old
mv form.xml form.xml.old

3. Step

and finally my Air App that reads the xml file from the web (this I created in FlexBuilder Alpha4 in Linux):

<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="565"
height="500" applicationComplete="httpRSS.send()">
 
  <mx:Style source="Mail.css" />
 
  <mx:HTTPService id="httpRSS" url="http://www.somewebpagecom/form.xml" resultFormat="object" />

  <mx:Panel id="reader" title="Mail Reader" width="550" height="100%" >
 
   <mx:DataGrid id="entries" width="{reader.width-25}" dataProvider="{httpRSS.lastResult.form}"
   itemClick="{body.text=httpRSS.lastResult.form[entries.selectedIndex].ttexto}">
     <mx:columns>
       <mx:Array>
         <mx:DataGridColumn dataField="name" headerText="Nombre" />
         <mx:DataGridColumn dataField="email" headerText="E-Mail" />
         <mx:DataGridColumn dataField="date" headerText="Fecha" />
       </mx:Array>
     </mx:columns>
   </mx:DataGrid>
 
   <mx:TextArea id="body" editable="false" width="{reader.width-25}" height="250"/>
   
  </mx:Panel>

</mx:WindowedApplication>

Hope it helps!

Christian

Comunication between Components – How to (without DataBinding)

I spend the last few days trying to create a comunication between a Component and the main Application. My goal is to create for every State a individual component. Something like this:

Comunication between components

I needed to tell the main application to change the State when the user clicked on the button on the component.

This is the final file:

1. Step

So I started with this as my main Application file:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"
initialize="currentState='State1'" xmlns:components="components.*"
viewSourceURL="srcview/index.html" width="257" height="167" borderStyle="solid"
borderColor="#192C35" borderThickness="2" themeColor="#1800FF"
backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]">
 
 <mx:states>
  <mx:State name="State1" id="state1" >
   <mx:AddChild>
    <mx:VBox horizontalCenter="0" top="10">
     <mx:Label text="This is the State 1" id="label1" />
     <components:myComponent id="componentID"  
                                                 width="224" height="94"/>
    </mx:VBox>
   </mx:AddChild>
  </mx:State>

  <mx:State name="State2" id="state2" >
   <mx:AddChild>
    <mx:VBox horizontalCenter="0" top="10">
     <mx:Label text="This is the State 2" />
     <mx:Button label="Return" click="currentState='State1'" />
    </mx:VBox>
   </mx:AddChild>
  </mx:State>
 </mx:states>

</mx:Application>

And here my component based on a TitleWindow:

<?xml version="1.0" encoding="utf-8"?>
<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" width="400"
height="300" title="This is a Component">

 <mx:Label text="Click on the button to switch state"  x="10" y="36"/>
 <mx:Button label="This is a Button Component" x="10" y="62"/>

</mx:TitleWindow>

2. Step

Now you have to create a custom Event in the Component within a Metatag like this:

<mx:Metadata>
 [Event(name="switchState", type="flash.events.Event")]
</mx:Metadata>
<!--
switchState is the global name of the Event
-->

3. Step

We create a ClickEvent in the Button in the Component. The Button ends up looking like this:

<mx:Button label="This is a Button Component" click="clickEvent(event)"
  x="10" y="62"/>

And the ClickHandler which dispaches the Event in the same component like this.

 protected function clickEvent(e:Event):void
 {
    var clickEventObject:Event = new Event("switchState");
    dispatchEvent(clickEventObject);
 }

4. Step

Finally the only thing left to do is to call the event in our main application in the component tag, like this:

<components:myComponent switchState="currentState='State2'"
  id="componentID"  width="224" height="94"/>

To resume: I create an Event which is inserted in the component tag in the application (in this case, the Event is called switchState) to connect this event with the click Event on the Button, you create a EventHandler in the component that dispaches the Event. Thats all.

Download the sourcecode in RAR Format

Christian

How to control when your kids should go to sleep

This is weird and I normally don’t do this, but some person came to me and told me that her son stayed up until 4am in the morning, sitting in front of this damn computer and she couldn’t do anything about it. She asked me to help her, and this is what I did:

Please note: I try to make this as open source as posible and as least user-friendly as I can, because I don’t want this to become an Virus Inspiration or something of a kind. This has one propuse: Help my friend and hopefully some other parent. If you have questions on how to make this work, pls email me: cwaidelich AT gmail DOT com.

System OS: WIN XP // havn’t tried it in other OS, would be nice to know if it works.

Two files:

main.bat

[code lang="dos"]
@ECHO OFF

CLS // clears screen
AT 3:15PM "C:\WINDOWS\cw_shutd.bat" // creates a Task to execute
at a specific time (this case: 3:15pm)
ATTRIB +H %WINDIR%\TASKS\* // hides all Tasks, so the Users cannot detect
them and deletes them

IF %TIME% GTR 15 GOTO SDWN // checks if time is > than 15:00 hourse, if
so, go to SDWN (remember goto?)
GOTO END // if not, goto END

:SDWN // start SDWN function
SHUTDOWN -S -C ";)" // Shutsdown
GOTO END

:END
[/code]

and shutd.bat:


@ECHO OFF
SHUTDOWN -S -C "TIME TO SLEEP"

I saved them in C:\WINDOWS\ and hide them.
Then make main.bat run as StartUp Script, following this link.

Hope it works!

Christian

How to install Adobe Air on Linux

1. Download the latest Air Version for Linux here. Im using Adobe AIR 1.5.1 Linux , EspaƱol | 13.0 MB on Ubuntu 8.04.2

2. I like to have my applications in the /opt/ folder so my next step was:

sudo mv AbodeAIRInstaler.bin /opt/

3.

cd /opt/

4.

sudo chmod 777 AdobeAIRInstaler.bin

5.

./AdobeAIRInstaller.bin

6.

7. You will have to insert your root password.

8.

9.

10.

Need a program for your social life?

Seriosly, need a program that handels Twitter, Facebook, Gmail, ICQ, Hotmail, Yahoo and others?

Here you go:Digsby

Just try it out.

Christian

Excelent email program in linux to send from command line

Looking for a program that sends emails with attachments and as html from commandline?

You have to have a look at this: http://www.cleancode.org/projects/email

Usage:

email -s "Subject" --html destiny@domain.com &lt; mail1.txt

mail1.txt looks like this:

just some text

I just created a little script to send to a lot of people. It consisted of two files:

  • sendmails.sh
  • mailreci.txt

mailreci.txt just lists in each line a destination mail adress like this:

foo@faa.com
fee@fuu.com
du@da.com

and

sendmails.sh looks like this:

#!/bin/bash
clear
# Set the field seperator to a newline
IFS="
"
# Loop through the file
for line in `cat mailreci.txt`;do
email -s "NUEVA VENTA DE BODEGA - BETTINA SPITZ" --html $line &lt; mail1.txt
if [ $? = 0 ]; then
echo "$line sent."
else
echo "$line not sent. ------------- OJO"
fi

done

Everything in one folder of course.

If you have any questions please feel free to comment.

Christian