12-15-2012 06:53 PM
I've got the code working from the following thread:
http://supportforums.blackberry.com/t5/Adobe-AIR-D
I understand RIM is moving away from AIR, but why have the functionality there for a new OS when there are no samples and What information out there is very scarce and basic?
I'm really just looking for any more docs on how I can use this feature to built a decent app.
How to use it would be a nice place to start. I've read the SDK reference over and over, but I just can't seem to figure out how to use this code effeciently, and what does what? I might just need a better explanation...
...what's the difference between Action and TabAction?
...How can I use the ActionBar with a multiple page app and have the "actions" in the ActionBar change the current page?
... How can I imlement an app Menu?
...Can I use SWIPE events like with the PlayBook to open the "IN_OVERFLOW" menu of the ActionBar?
Solved! Go to Solution.
12-15-2012 09:53 PM - edited 12-15-2012 09:55 PM
RIM is not moving away from AIR. Their focus is on Cascades, but that does not equate dropping AIR. AIR 3.4 will be coming this spring and they just release support for FlashBuilder 4.7.
As of documentation. All the environments are playing catch up. The API is there, but how to use is still a little weak.
To answer some of your questions:
I use a "Page" class and an "ActionPage" class that encapsulate some of the action bar features. This assumes that an action bar has been added as a child and the updateDisplayList updates its position and width.
Add actions to bar:
this.actionbar.showTabsFirstOnBar( false );
this.actionbar.backButton = new Action( 'Back', null, {id:'back'} );
this.actionbar.addAction( new TabAction( 'Search', null, {id:'search'} ) );
this.actionbar.addAction( new TabAction( 'POI', null, {id:'poi'} ) );
this.actionbar.addEventListener( ActionEvent.ACTION_SELECTED, ActionSelected );
The nulls can be replaced to show an image. Do not have to do that for the back button unless you want your own back image.
List for actions:
//////////////////////////////////////////////////////////////////////// private function ActionSelected( event : ActionEvent ) : void { switch( event.action.data.id ) { case 'back' : this.Back(); break; case 'options' : this.showSettings(); break; case 'poi' : this.shared_data.locateOnMap(); break; case 'details' : this.showDetails(); break; case 'directions' : this.showDirectionsTo( ); break; case 'clear' : this.DoClear( null ); break; case 'search' : this.DoSearch( null ); break; case 'share' : this.Share(); break; } }
You can use the same ActionSelected listener for context menu selections.
Hope this helps.
12-15-2012 11:37 PM
That was pretty great, as per usual for your posts.
Right now I have been looking at the idea of using Containers and Alphas to dynamically change content.
I was thinking I could use the top part of the screen (everything above the ActionBar) as a Container, everything that I need having Alpha = 1; and everything else (things on different "pages") with an alpha = 0;
You mentioned having a Page Class, would you use this to the same result as I described with the alphas? - Dynamically Add/remove content based on button presses? Is this the same Page class I recall seeing for the playbook? - PageViewStack?
I should be fine without code examples, I really just need the concepts to be explained a little more thoroughly, I definitely see what you mean about the catch-up game that non-Native SDKs are playing.
I've already submitted/had approved my first BB10 app (using coding styles I used for the PlayBook) - now I am most curious about developing apps with a Native Look/Feel.
12-16-2012 04:59 AM
Don't use alpha, it is not an efficient way of doing this. All your controls will be created, measured, rendered even if their alphas are 0. On mobile, keep the display list as simple as possible and create your controls on demand.
12-16-2012 05:20 AM
In looking at the API Ref for Action and TabAction they seem to be identical with the exception of name and intended purpose. Odd
I just don't see what adding an Action to do something is different then adding a TabAction to do something? Don't they both appear in the ActionBar/Overflow?
12-16-2012 09:58 AM
12-16-2012 10:03 AM
12-16-2012 10:13 AM
Page transition: If this helps someone and if any has ideas to improve it:
////////////////////////////////////////////////////////////////// public function setPageIndex( pg : int, direction : String ) : void { //trace( 'setPageIndex ' + pg + ' ' + this._current_index + ' ' + this._switching ); if( this._current_index == pg || this._switching )return; var page :UIComponent = this._pages[ pg ] as UIComponent; page.setActualSize( this._parent.stage.stageWidth, this._parent.stage.stageHeight ); this._switching = true; this._current_index = pg; if( direction == RIGHT_LEFT ) { page.setPosition( this._parent.stage.stageWidth, 0 ); this._parent.addChild( page ); } else if( direction == LEFT_RIGHT ) { page.setPosition( 0, 0 ); this._parent.addChildAt( page, this._parent.numChildren - 2 ); } else if( direction == TOP_BOTTOM ) { page.setPosition( 0, -this._parent.stage.stageHeight ); this._parent.addChild( page ); } else if( direction == BOTTOM_TOP ) { page.setPosition( 0, this._parent.stage.stageHeight ); this._parent.addChildAt( page, this._parent.numChildren - 2 ); } if( direction == RIGHT_LEFT ) { Tweener.addTween( page, {x:0,time:this.time,onComplete:DonePage,onComplete Params:[page],transition:'linear'} ); } else if( direction == LEFT_RIGHT ) { Tweener.addTween( this._current_page, {x:this._parent.stage.stageWidth,time:this.time,on Complete:DonePage,onCompleteParams:[page],transiti on:'linear'} ); } else if( direction == TOP_BOTTOM ) { Tweener.addTween( page, {y:0,time:this.time,onComplete:DonePage,onComplete Params:[page],transition:'linear'} ); } else if( direction == BOTTOM_TOP ) { Tweener.addTween( this._current_page, {y:-this._parent.stage.stageHeight,time:this.time, onComplete:DonePage,onCompleteParams:[page],transi tion:'linear'} ); } } ////////////////////////////////////////////////// ////////////////////// private function DonePage( page : Page ) : void { this._switching = false; this._parent.removeChild( this._current_page ); this._current_page = page; }
12-16-2012 08:21 PM
Thanks!
My understanding is much better now, and I've got some good ideas on how to build a nice looking/feeling BB10 app now!
I see in the Weather Guesser app, the extra options come out on the left side, whereas the normal "overflow" comes out on the right... Is there any reason to have one or the other in AIR?
I can see using the left for "peek" type options (tabs- usually, no?) and left for Actions Overflow.....MAN they are giving us a lot of options for menus....
12-17-2012 08:13 AM