Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Contributor
specific
Posts: 31
Registered: ‎01-27-2011
My Device: Tablet
Accepted Solution

how to go next and and previous page

Hi Friends

i m new for forum and also for action script

i need help for how to go next page and return to previous page.

i hope issue would resolve soon.....

 

Thanks in advance

Please use plain text.
Developer
T55555
Posts: 117
Registered: ‎12-03-2010
My Device: Not Specified

Re: how to go next and and previous page

Hi Friend,

 

Search ! Search First ! Please...


http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/in-playbook-how-to-handle-navigat...

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Going-back-to-main-page/m-p/71240...

 

And many more thread existed already ( viewStack,... etc etc )

 

---------------------
a) If you like my response/post, please provide a Kudo (white star to the left).
b) If my post solved your problem please click on the Accept as Solution button.

Please use plain text.
Contributor
specific
Posts: 31
Registered: ‎01-27-2011
My Device: Tablet

Re: how to go next and and previous page

Thanx for reply

 

but this post i have seen earlier but i m unable to use it.

can u give me code to use pageviewstack .

 

Thanx 

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: how to go next and and previous page

There is a library that includes PageViewStack that encapsulates pages that can be transitioned from one to another.  See thread at:

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Community-Library-Released-for-cl...

 

In your main sprite add an attribute:

 

private var stack : PageViewStack;

 

In the main constructor:

 

this.stack = new PageViewTack( this );

this.stack.time = 1.0; // duration of transitions

 

For each "page" make it it's own class inherited from UIComponent.

In the main/root Sprite, add attributes for each page.

 

private var page1 : MyPage1;

private var page2 : MyPage2;

 

In the constructor, allocate these pages

 

this.page1 = new MyPage1();

this.page2 = new MyPage2();

 

Add the page to the page viewer.  The first page added will be the default and will be shown automatically.

 

this.stack.addChild( this.page1 );

this.stack.addChild( this.page2 );

 

To move from one page to another, listen to an event from a swipe, button, list, etc.  Just some user interaction.

 

For example, to move to page 1 ( from page 0 ) and have the page come in from the right (to left):

 

private function ShowPage2( event : Event ) : void

{

  this.stack.setPageIndex( 1, PageViewStack.RIGHT_LEFT );

}

 

Remember, array index starts at 0, so "page1" is at 0 index and "page 2" is at 1 index.

 

To go back to page 1 (index 0):

 

private function ShowPage1( event : Event ) : void

{

  this.stack.setPageIndex( 0, PageViewStack.LEFT_RIGHT );

}

 

You can also transition from top to bottom or bottom to top.

If you have a navigation/application bar along the top or bottom that is persistent no matter what page you are seeing, the class allows for "padding" on any side.

 

Hope that helps.

 

 

 

 

 

 

 

Please use plain text.
Contributor
specific
Posts: 31
Registered: ‎01-27-2011
My Device: Tablet

Re: how to go next and and previous page

thanx a lot

but please have a look my code

my Main Sprite

when it runs it give only blank simulator

package
{
 import flash.display.Sprite;
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 import qnx.ui.core.UIComponent;
 public class MyApp extends Sprite
 {
 private var stack : PageViewStack;
 private var page1 : Page1;
 private var page2 : Page2;
 public function MyApp()
 {
 super();
 this.page1=new Page1();
 this.page2=new Page2();
 this.stack = new PageViewStack( this );
 this.stack.time = 1.0; // duration of transitions
 this.stack.addChild( this.page1 );
 this.stack.addChild( this.page2 );
 this.stage.nativeWindow.visible = true;
 // support autoOrients
 stage.align = StageAlign.TOP_LEFT;
 stage.scaleMode = StageScaleMode.NO_SCALE;
 }
 }
}
----------------------------------------------------------------------
page 1 code
package
{
 import flash.display.Sprite;
 import flash.events.Event;
 import flash.events.MouseEvent;
 
 import qnx.ui.buttons.LabelButton;
 import qnx.ui.core.UIComponent;
 import qnx.ui.text.Label;
 public class Page1 extends UIComponent
 {
 public var label:Label;
 public var labelB:LabelButton;
 public var stack:smileytongue:ageViewStack;
 public function Page1()
 {
 label=new Label();
 labelB=new LabelButton();
 
 label.name="Welcome To 2nd Page";
 addChild(label);
 
 labelB.name="PreviousPage";
 labelB.addEventListener(MouseEvent.CLICK,showpage2);
 addChild(labelB);
 this.stage.nativeWindow.visible = true;
 }
 public function showpage2(e:Event):void
 {
 this.stack.setPageIndex( 1, PageViewStack.RIGHT_LEFT );
 
 }
}
}
------------------------------------------------------------------------------
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.MouseEvent;
import qnx.ui.buttons.LabelButton;
import qnx.ui.core.UIComponent;
import qnx.ui.text.Label;
public class Page2 extends UIComponent
{
public var label:Label;
public var labelB:LabelButton;
public var stack:smileytongue:ageViewStack;
//private var shared_data:smileyfrustrated:haredData = SharedData.instance;
public function Page2()
{
label=new Label();
labelB=new LabelButton();
label.name="Welcome To 2nd Page";
addChild(label);
labelB.name="PreviousPage";
labelB.addEventListener(MouseEvent.CLICK,Showpage1);
addChild(labelB);
this.stage.nativeWindow.visible = true;
}
public function Showpage1(e:Event):void
{
this.stack.setPageIndex( 0, PageViewStack.LEFT_RIGHT );
}
}
}

 

Please use plain text.
Developer
jtegen
Posts: 6,541
Registered: ‎10-27-2010
My Device: HTC One, PlayBook, LE Z10, DE Q10
My Carrier: Verizon

Re: how to go next and and previous page

At the head of your root sprite, I dont see:

 

[SWF(height="600", width="1024", frameRate="30", backgroundColor="#666666")}

public class MyApp extends Sprite

{

...

 

In ieach page you should not be calling the stage's native window to visible.  Just in the root class.

 

The "stack" class is only a member attribute in the root class and is not accessible to your other page classes and should not be added to the other pages too.  Just once in the root sprite.  Once the button is pressed in each page, dispatch an event to the singleton class that the main root class is also listening too, so that the root class is the only one managing the pages.  The other pages have no idea about the other pages or event the root sprite so its communication to the root sprite and/or other pages is via the singleton (SharedData) instance.  Typically, the event subject is a public static const variable in the singleton class definition so it is accessible to any view that has a reference to it.  For example, from a page you can:

 

this.shared_data.dispatchEvent( new Event( SharedData.GOTO_PAGE1 ) );

 

where GOTO_PAGE1 is defined in SharedData as

 

public static const GOTO_PAGE1 : String = 'goto.page1';

 

 

Please use plain text.
Contributor
specific
Posts: 31
Registered: ‎01-27-2011
My Device: Tablet

Re: how to go next and and previous page

Hi

sorry to ask easy problem.

i added 

[SWF(height="600", width="1024", frameRate="30", backgroundColor="#666666")}

and removed nativewindow.visible=true now root screen came but sorry to say i have no idea about further process code is same. its my request to please give me code help what i would have to write.
hope to see ur help
thanx
Please use plain text.
Developer
JRab
Posts: 2,462
Registered: ‎11-04-2010
My Device: Bold 9700

Re: how to go next and and previous page

hey specific,

 

i think you need to start out with something a little simpler and smaller to get a basic grasp on the concept of views. below is a link from a while back in the forums where a user needed to do what you are asking. the code is simple and has comments and should be easy to follow:

 

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/How-to-navigate-to-other-page/m-p...

 

after you've accomplished what is in that thread, you should be able to understand jtegen a little better. remember, no situation is ever complex - it is just a bunch of simple situations coupled together to look complex! good luck!

J. Rab (Blog) (Twitter)
--
1. If you liked my post or found it useful please click on the thumbs up and provide a Like!
2. If my post solved your problem please click on the Accept as Solution button. Much appreciated!

Approved Apps: OnTrack | ssShots | Hangman
Please use plain text.
Contributor
specific
Posts: 31
Registered: ‎01-27-2011
My Device: Tablet

Re: how to go next and and previous page

thanx  JRab

actually i have to develop multiscreen app.actully m used that.

but can u please help me by code how to use pageviewarray by just simple coding.

my app stucked here

 

Man

Please use plain text.
Super Contributor
Meghasanghvi
Posts: 306
Registered: ‎08-10-2010
My Device: Not Specified

Re: how to go next and and previous page

u try below code may be it help you 

 

replace UIComponent with Sprite in Page1 and Page2

 

i am not sure that this pic of code is work or not 

Please use plain text.