[flexcoders] Creating keyboard shortcuts @ runtime

2010-06-23 Thread thedauntless_ff
Hi,

I'm the developer of Doc? (http://www.airdoc.be) and I'm currently looking into 
adding the ability to let the user define his own keyboard shortcuts.

I've tried a few solutions (keymanagers I've downloaded + one I made myself) 
but none of them really delivered an intuitive way of adding keyboard shortcuts.

Specific problem is fe. that I need to start listening for a keyboard shortcut 
when a TextInput is focused. But since it's focused, key presses are also added 
to the TextInput itself. (I only want to show the shortcut string in the 
textfield, like "Ctrl + alt + D")

Another problem is finding a reliable way of handling all the keyups and 
keydowns. I actually haven't found a keymanager that's not buggy. Any 
suggestions on that part?

Or if anyone knows an existing Flex/AIR app that lets the user define its own 
shortcuts, please let me know and I'll try to contact the developer.

All help is greatly appreciated!

Greets,
Jeroen



[flexcoders] Creating a settings class (Air, synchronous)

2010-02-22 Thread thedauntless_ff
Hi,

I've restarted writing my Settings class for over a dozen times now; I never 
like the result. The responsibilities for the Settings class are very easy:
- Be able to set (new/existing) settings
- Be able to get settings
- Has to sync with an xml file

I'm using it in an AIR app and I'm loading the data synchronously, so no events 
are involved (thank god for that, although I'm curious how to handle this if 
the xml file is loaded asynchronous) .

What I'm having trouble with, is finding a method that's easy to use and will 
notify me of typo's. Hence, something like 
'Settings.getInstance().g("mySettingName")' won't be possible.

I bet you're thinking: "you can't have it both ways! Either you make it dynamic 
(/Proxy class) or you predefine every setting you will need in some sort of 
static var and end up with Settings.getInstance().g(Settings.MY_SETTINGS_NAME). 
Well, I'm hoping that there's a way to have the best of both worlds.

Since the class needs to be dynamic, compile-time errors probably won't be 
possible, but runtime errors surely should be?

Are there any popular classes out there, or is there a certain design pattern / 
architectural pattern that I can use? I've already tried a bunch of 
implementations that I wrote myself, but I'm curious what the Flash community 
has come up with so far.

Thanks for reading and if something's not clear, please let me know and I'll 
elaborate some more.

Cheers!



[flexcoders] Selecting xml nodes in a tree

2009-12-30 Thread thedauntless_ff
Hi,

My situation:
- 1 Tree component (id=tree)
- 1 XMLListCollection as a dataprovider for the tree (id=treeData)
- 1 String, a url, that has to be found & selected.

My XMLListCollection looks like this:











Etc. All nodes are named 'page' and have a href property.

What I need now, is a way to select the node in the tree for the given url. For 
example, all nodes are collapsed and I want to select the node with href=url4. 
How can I do this?

This is what I tried:

var t:XMLListCollection = this.treeData;
var url:String = "myURL";
for(var i:Number = 0; i 0)
{
//I only want to select the first occurence
tree.selectedItem = nodes[0];
break;
}
}

This, however, gives me a weird error (probably not that helpfull):

TypeError: Error #1010: A term is undefined and has no properties.
at 
mx.controls.listClasses::ListBase/setSelectionDataLoop()[E:\dev\beta1\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:7360]
at 
mx.controls.listClasses::ListBase/commitSelectedItems()[E:\dev\beta1\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:7251]
at 
mx.controls.listClasses::ListBase/commitSelectedItem()[E:\dev\beta1\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:7216]
at mx.controls.listClasses::ListBase/set 
selectedItem()[E:\dev\beta1\frameworks\projects\framework\src\mx\controls\listClasses\ListBase.as:3474]
at classes::Logic/onBrowserLocationChange()[C:\Users\ser\Documents\Flex 
Builder 3\application\src\classes\Logic.as:346]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.core::UIComponent/dispatchEvent()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\UIComponent.as:11260]
at 
Classes::Logic/onBrowserLocationChange()[C:\Users\user\Documents\Flex Builder 
3\application\src\classes\Logic.as:73]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at 
mx.core::UIComponent/dispatchEvent()[E:\dev\beta1\frameworks\projects\framework\src\mx\core\UIComponent.as:11260]
at 
mx.controls::HTML/htmlLoader_locationChangeHandler()[E:\dev\beta1\frameworks\projects\airframework\src\mx\controls\HTML.as:1438]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at flash.html::HTMLLoader/onLocationChangeTimer()
at flash.utils::Timer/_timerDispatch()
at flash.utils::Timer/tick()



Greets,
Dauntless





[flexcoders] AIR - Ascynchronous file deletion - fixed order ?

2009-11-17 Thread thedauntless_ff
Hi,

Simple test:

private function init():void
{
var f:File = File.
applicationStorageDirectory.resolvePath("movie.avi");
f.addEventListener(Event.COMPLETE, com1);
f.deleteFileAsync();
var f2:File = 
File.applicationStorageDirectory.resolvePath("file.txt");
f2.addEventListener(Event.COMPLETE, com2);
f2.deleteFileAsync();
}
   
function com1(e:Event):void
{
trace("movie deleted");
}
function com2(e:Event):void
{
trace("file deleted");
}

Where 'movie.avi' is about 800mb and file.txt is an empty text file. In this 
simple test, the "movie deleted" is traced before the "file deleted". My 
question is: will this always be the case?

In general: Will multiple asynchronous commands be handles in the same order as 
they have been started?

I've spent enough hours googeling, but I couldn't find any documentation 
specific to this problem.

Thanks!



[flexcoders] Resize triggers reloading of Loader instance in UIComponent

2009-10-04 Thread thedauntless_ff
Hi, 

My situation:
- viewStack (creationPolicy=all)
- canvas
- canvas
- - hbox
- - canvas
- - customVideoPlayerComponent
- - - hbox
- - - canvas (id=holder)

I want to play youtube video's in a chromeless player. I'm using this Youtube 
AS3 wrapper:
http://www.ovidiudiac.ro/blog/2009/03/youtube-as3-wrapper/

My steps are as follows:
- Create loader
- Load the wrapper swf
- Create new UIComponent
- Add loader to UIComponent
- Add UIComponent to canvas (id=holder)

Everything's working except for one thing: When I re-size the browser, another 
instance of the player is loaded and shown above my current player. This only 
happens when the video is partly offscreen.

This is weird, since the traces from the method that loads the player aren't 
being called.

I've added the source below, but here's the entire project for your 
convenience: 
http://www.dauntless.be/Temp/Youtubetest.rar

Somewhere, somehow the Canvas/Viewstack/loader is redrawn (without removing the 
previous one ? :s) and I really don't understand why & how...

All help is appreciated! I've I'm not clear enough, please let me know.


Source:

http://www.adobe.com/2006/mxml"; layout="absolute" 
creationComplete="init()" xmlns:local="*">














http://www.adobe.com/2006/mxml"; creationComplete="init()">















[flexcoders] Add mxml component to NativeApplication instance

2009-08-25 Thread thedauntless_ff
Hi, 

Situation:
I've simplified my problem to just a few lines of AS & mxml (see below). What 
I'm trying to do is easy: Create a custom NativeWindow instance that has an 
mxml component as it's child.

Problem:
I can't get the component to show and it 'disappears' for some reason.

Code:

package
{
import flash.display.NativeWindow;
import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;

public class CanvasWindow extends NativeWindow
{
public function CanvasWindow()
{
var options:NativeWindowInitOptions = new 
NativeWindowInitOptions(); 
options.systemChrome = 
NativeWindowSystemChrome.STANDARD; 
options.transparent = false; 
super(options);

var ct:CanvasTest = new CanvasTest();
trace("ct = " + ct);
this.stage.addChild(ct);
trace("ct = "+ ct);
}

}
}




http://www.adobe.com/2006/mxml"; width="400" height="300">




http://www.adobe.com/2006/mxml"; 
layout="absolute" creationComplete="init()">








As you can see I've added two traces. The first traces my CanvasTest instance, 
while the second one traces null. The component is also not displayed.

I couldn't find a lot of information about this, and what I did find was about 
an alpha about Apollo (hacked together).

So, what's going wrong here? 

Thanks for reading!




[flexcoders] Get html source code of mx.controls.HTML control (AIR)

2009-01-10 Thread thedauntless_ff
Hi,

Situation: I've loaded a webpage into the  control and it
displays just fine. What I want now, is the sourcecode of the loaded
document, without loading the document again. Is this possible ?

I found this tutorial:
http://labs.adobe.com/wiki/index.php/Apollo:Articles:Using_HTML_in_Flex-based_Apollo_Applications

And it's talking about a JavaScriptObject class located in flash.html.
I am however unable to find this class... The examples in this
tutorial would be perfect, if only I would have suck a
JavaScriptObject class...

Any suggestions ?

Greetings,
Jeroen Beckers



[flexcoders] Force change event after manual edit

2008-06-17 Thread thedauntless_ff
Hi, 

Situation:

---

http://www.adobe.com/2006/mxml";
layout="absolute" creationComplete="init()">











You get a nice trace when the user clicks a radiobutton. However, I
would like the 'change event' to be dispatched after I set the
rb1.selected to true.

Rephrase: Can you make Flex think that, when you change a radiobutton
group by code, the group was edited by the user itself? 

Greets!