Disabling ‘Back’ button for flex mobile View
Despite many articles over the network – it is very easy to disable the Back button for any mobile View.
You don’t have to override anything..all you have to do is to define backKeyPressed event in your View declaration and call event.preventDefault() method. Here is an example:
<s:View
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
title="My View" backKeyPressed="onBackPRessed(event)" >
And here is the method implementation:
event.preventDefault();
}
This is very useful when you want to disable back button for some view(s). Example you have loged in view which is after the register view..you don’t want your app users to go to register again after they press the back button.. (which is the automaticly popped view)
Flex 4.6 + Alternativa3D 8 spark problem
Recently I’ve been playing around with alternativa3D and I could not figure out why when I set up flex nativeproject using SDK 4.6 and Alternativaplatform 8 – notthing is displayed on the stage..
After A while I figured out what is going on. It turned out that the flex background is drew above the 3D stages. My fix is simple – just setting backgroundAlpha style to be 0 and the 3D appears.
Here you can see my test code:
<?xml version=”1.0″ encoding=”utf-8″?>
<s:Application xmlns:fx=”http://ns.adobe.com/mxml/2009″
xmlns:s=”library://ns.adobe.com/flex/spark” backgroundAlpha=”0″
xmlns:mx=”library://ns.adobe.com/flex/mx” xmlns:alternativaplatform=”http://alternativaplatform.com”
applicationComplete=”initApplication(event)” backgroundColor=”black”
minWidth=”950″ minHeight=”550″ xmlns:controller=”bg.lan.chess.controller.*” xmlns:local=”*”><fx:Declarations>
<controller:Controller id=”control” />
</fx:Declarations><fx:Style source=”css/styles.css” />
<fx:Script>
<![CDATA[
import alternativa.engine3d.controllers.SimpleObjectController;
import alternativa.engine3d.core.Camera3D;
import alternativa.engine3d.core.Object3D;
import alternativa.engine3d.core.Resource;
import alternativa.engine3d.core.View;
import alternativa.engine3d.materials.FillMaterial;
import alternativa.engine3d.primitives.Box;import bg.lan.chess.events.InitApplicationEvent;
import bg.lan.chess.init.ResourceLoader;
import bg.lan.chess.view.MainView;import flash.display3D.Context3D;
import flash.display3D.Context3DRenderMode;import mx.events.FlexEvent;
public var mainView:MainView;
protected var rootContainer:Object3D = new Object3D();
protected var camera:Camera3D;
protected var box:Box;
private var stage3D:Stage3D;private function initApplication(e:Event):void {
initEngine();
initScene();}
protected function initEngine():void
{
camera = new Camera3D(0.1, 50000);
camera.view = new View(800, 500);
alternativa3DSprite.addChild(camera.view);
alternativa3DSprite.addChild(camera.diagram);camera.z = -1000;
rootContainer.addChild(camera);
alternativa3DSprite.addEventListener(Event.ENTER_FRAME, onEnterFrame);
}protected function initScene():void
{
stage3D = alternativa3DSprite.stage.stage3Ds[0];
stage3D.addEventListener(Event.CONTEXT3D_CREATE, onContextCreate);
stage3D.requestContext3D();
box = new Box(500, 500, 500, 5, 5, 5);
var material:FillMaterial = new FillMaterial(0xFF7700, 1);
box.setMaterialToAllSurfaces(material);
rootContainer.addChild(box);}
private function onContextCreate(e:Event):void {
stage3D.removeEventListener(Event.CONTEXT3D_CREATE, onContextCreate);
for each (var resource:Resource in rootContainer.getResources(true)){ // all resources are loaded in context3D
resource.upload(stage3D.context3D);
}
}protected function onEnterFrame(e:Event):void
{
camera.view.width = stage.stageWidth;
camera.view.height = stage.stageHeight;
camera.render(stage3D);
}]]>
</fx:Script><s:SpriteVisualElement id=”alternativa3DSprite” width=”100%” height=”100%” />
<s:Label text=”Test Label above the 3D. Note that the box is visible. It is because of the backgroundAlpha=’0′ style” color=”white” horizontalCenter=”0″ verticalCenter=”0″ />
</s:Application>
Flex UncaughtErrorEvent in non-debug flashplayer
Flashplayer 10.1 and AIR 2.0 come with very nice feature enabled – global error handling.
Here is the official Adobe announce about this:
Update 2010-01-12: Global error handling is now supported in Flash 10.1 and AIR 2.0 (both in beta), and is achieved by subscribing the UNCAUGHT_ERROR event of LoaderInfo.uncaughtErrorEvents.
Anyway, this is very useful especially when you run debug version of flash player.
But what is happening if you are using the regular non-debug flash player ?
Then simply the stack trace does not appear. Here Is example of demo code which globally handles errors in flex application:
In Application.mxml applicationComplete event handler:
loaderInfo.uncaughtErrorEvents.addEventListener(UncaughtErrorEvent.UNCAUGHT_ERROR, uncaughtErrorHandler);
And here is the handle method:
private function uncaughtErrorHandler(event:UncaughtErrorEvent):void {
var error:* = event.error;
if (error is Error) {var errorObj:Error = error as Error;
LOG.error(“{0}. {1}\n {2}”, errorObj.errorID, errorObj.message, errorObj.getStackTrace());} else if (error is ErrorEvent) {
var errorObj2:ErrorEvent = error as ErrorEvent;
LOG.error(“{0}”, errorObj2.text);}
}
If you check out the result of this code ran in non-debug flashplayer version, you will notice that only “Error #1009″ is printed.
It would be nice if adobe store at least the target class in the ErrorEvent object, so we can see when regular users are having runtime errors and then can send the error to our support engineers.
RFID Destroyer
This is simple project that based on board of old camera.
The flash is removed and instead of it, there is a coil connected to the board, so the high voltage (~300V) is used to destroy the RFID chip, which is made to support low voltage. The schematics look something like this:
And here is the final result. Inside:
Outside:
The usage is very simple. The RFID card must be placed directly under the soap-box and then the button must be pressed.
Then the card is completely destroyed
RFID EM4100 Emulator
This is simple hobby project that will show you easy, simple and fast way of emulating the popular RFID access cards EM4100.
My implementation uses manchester encoding for thansmitting the emulated card ID. The MCU I’m using is PIC18F2550.
The Antenna design:
Diameter D 43mm
NUmber of turns N 48
Wire Diameter W 0.18mm
Turn spacing S 0mm
So the target inductance is 160uH. This is the schematics:
You can download the code from here. The final prototype is having 8 buttons which are used to switch between the currently emulated card.
The device supports 8 cards so far, which are programmed into the chip memory using standard Pic Kit 2 programmer.
This is how it looks:
The problem I’m having so far is that some readers are unable to read the card because they are expecing PSK coding.
Any help on modifying the code to support PSK coding will be aprischiated.
Recent Comments