Archive for the ‘ AIR ’ Category

Xray short walk-through video

After seeing some of the replies on my last post, I thought doing a little video on what the AS3 version is capable would be a good idea.  So here’s a little walk through:

http://dl-client.getdropbox.com/u/36547/videos/xray/XrayWalkthrough_7Min.mov

Advertisements

How to detect when a TextArea is full: Paging

Well again, this is for archive and maybe it’ll save someone some time 😉 This is a screenshot of a test with the code below. It has 2 different TextArea components with differing fonts and font sizes that page the text perfectly between the 2 controls.

if you’ve ever tried to do paging or find out how many lines were being occupied in a TextArea’s TextField, this is one way to accomplish the task that seems to work every time. It’s pretty straight forward in that you just need to get to the TextField object that the TextArea uses. Simply test maxScrollV after calling validateNow on the TextArea and bam, you’re in business.


package
{
import flash.events.Event;
import flash.text.TextField;

import mx.controls.TextArea;
import mx.core.WindowedApplication;
import mx.core.mx_internal;
import mx.events.AIREvent;
//use namespace mx_internal;

public class BasicApplicationTestBase extends WindowedApplication
{
public var t0:TextArea;
public var t1:TextArea;
public var txt:String = “Well, it’s not secret that Papervision3D has taken the Flash world by storm, surprise and to the next era of Flash design and development. It’s become a regular word in the arsenal of any Flash designer and developer around the community and we’re really excited about being apart of that! One of the cool things about having an impact like this is the attention Adobe started to give the 3D API’s that were emerging.”;
public var words:Array = [];

public function BasicApplicationTestBase()
{
super();
addEventListener(AIREvent.WINDOW_COMPLETE, handleComplete, false, 0, true);
}

protected function handleComplete(e:Event):void
{
// split up the string at the spaces
words = txt.split(” “);
}

public function doIt(e:Event=null):void
{
// set the target textArea
var target:TextArea = t0;
// clear the current text
target.text = “”;
// set the target textArea’s textfield
var textField:TextField = t0.mx_internal::getTextField() as TextField;

for( var i:int=0; i 1 )
{
// set back to original before changing the target
target.text = originalText;
// set new target TextArea control
target = t1;
// set the word we’re on to the new target, or else we loose it
target.text = words[i] + ” “;
// set new TextField object
textField = t1.mx_internal::getTextField() as TextField;
}
}
}
}
}

Phillip Kerman: What’s he got against the beaver?!

Why FITC?

Ok, I’ve seen many attempts at humor by flash developers in my day, but Phillip puts them all to shame. I think Flash *might* be his side job in reality. The other “why” videos are hilarious, but this one had some added frosting with the intro and ending disclaimers.

He gets a 4 rock on rating for this one 😉

RockOn Rating:   RockOn voteRockOn voteRockOn voteRockOn vote

Creating NativeWindows in AIR and displaying Flex content in them

Thanks to Daniel Dura for event getting me on the right path to making this work!

In AIR, you can create new popup windows buy using the NativeWindow object. This gives you the ability to do something like a fullscreen projector from your application. The concept rocks, but in beta right now, it’s not fully implemented and there are some hacks you have to do to get your content to show up in the new NativeWindow.

When I first started trying to load my custom component, I couldn’t see a thing even after using Daniel’s suggestion of adding it to the main application’s display list. It seems that percentage values were being ignored and the size of the canvas being added was being set to 0x0 because of it. That made it invisible obviously.

So, I figured maybe if we wrapped it in another container, set that containers width/height, maybe that would light things up. That *did* help, but I was still tracing out the window size and it was showing up at 400×200, which was wrong since I’d called maximize() on the window. Naturally, I’m thinking there’s an event to let us know when it’s fullscreen, and there is of course:

[as]flash.events.NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE [/as]

You have to wait for that to fire, so you can get the correct window size. You use that to set the size of your container canvas, and then the children’s percentage settings work as you’d expect. At this point, I added my custom component (SlideShowViewer) to the container, but NOT to the NativeWindow’s stage just yet.

Now, adding it to the main application’s display list will initialize the component to work correctly (be careful not to add it to the main applications stage, use application.addChild())
[as]
mx.core.Application.application.addChild(container);
mx.core.Application.application.removeChild(container);[/as]

Daniel had added it first to a hiddenCanvas on stage, but I didnt’ want something just sitting around for this purpose and this works just fine.

Finally, add container to the NativeWindow’s stage and all should be good.

In the constructor:
[as]public function SlideShowWindow(initOptions:NativeWindowInitOptions)
{
super(initOptions);
addEventListener(NativeWindowDisplayStateEvent.DISPLAY_STATE_CHANGE, handleDisplayChange);
addEventListener(Event.ACTIVATE, init);
}[/as]

[as]protected function handleDisplayChange(e:NativeWindowDisplayStateEvent):void
{
container.width = width;
container.height = height;

slideShowViewer = new SlideShowViewer();
container.addChild(slideShowViewer);

mx.core.Application.application.addChild(container);
mx.core.Application.application.removeChild(container);
stage.addChild(container);

//trace(“DISPLAY CHANGE”, this.width, this.height, slideShowViewer.width, slideShowViewer.height);
}[/as]

Advertisements