Skip to content

Instantly share code, notes, and snippets.

@davisford
Created August 8, 2011 22:59
Show Gist options
  • Save davisford/1132974 to your computer and use it in GitHub Desktop.
Save davisford/1132974 to your computer and use it in GitHub Desktop.
Transmit and Receive
<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:swiz="http://swiz.swizframework.org"
backgroundColor="#bdcdf4"
width="100%" height="100%" >
<fx:Script>
<![CDATA[
import daisyworks.event.BluetoothTxRxEvent;
[Bindable] private var message:String;
private function checkbox_changeHandler(event:Event):void {
if(checkbox.selected) {
// turn it off
dispatchEvent(new BluetoothTxRxEvent(BluetoothTxRxEvent.TX, "7;"));
} else {
// turn it on
dispatchEvent(new BluetoothTxRxEvent(BluetoothTxRxEvent.TX, "6;"));
}
}
[EventHandler(event="BluetoothTxRxEvent.RX", properties="data")]
public function receive(data:String):void {
// assign the string to the bindable message var
message = data;
}
]]>
</fx:Script>
<fx:Declarations>
<swiz:Swiz>
<swiz:config>
<swiz:SwizConfig eventPackages="daisyworks.event.*"
viewPackages="modules.*"/>
</swiz:config>
</swiz:Swiz>
</fx:Declarations>
<s:Group left="15" right="15" top="15" bottom="15">
<s:layout>
<s:VerticalLayout />
</s:layout>
<s:Label text="Daisy Blink / LED App" width="100%" height="85" paddingTop="44" textAlign="center" fontSize="24" fontWeight="bold" fontFamily="Verdana"/>
<s:HGroup width="100%" height="128" verticalAlign="middle" horizontalAlign="center">
<s:CheckBox id="checkbox" change="checkbox_changeHandler(event)" label="LED State" height="35" fontSize="15" width="150"/>
</s:HGroup>
<s:Label text="{message}" width="100%"/>
</s:Group>
</s:Module>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment