Return to the homepage

Hey,.

I've seen a couple of posts related to navigate to new positions, and while I have the basic gist down, I'm having some trouble to go back to the homepage of my 2nd page.

The first page is called Unit and here is the code:

package
{
    import flash.display.Sprite;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.filesystem.File;
    import flash.text.TextField;
    import flash.text.TextFormat;

    import qnx.dialog.*;
    import qnx.display.IowWindow;
    import qnx.events.DialogEvent;
    import qnx.ui.buttons.Button;
    import qnx.ui.buttons.IconButton;
    import qnx.ui.data.DataProvider;
    import qnx.ui.display.Image;
    import qnx.ui.listClasses.DropDown;
    import qnx.ui.text.Label;

    [SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
    public class Unit extends Sprite
    {

                private var currentView:String = "mainWindow";
        private var backgroundBlack:Boolean = true;

        public function Unit()
        {
            drawMainWindow();
        }

        private function drawMainWindow():void {
            clearWindow();
            this.currentView = "mainWindow";

                        createBackground();

                        var distanceButton:IconButton = new IconButton();
            distanceButton.setSize(BUTTON_WIDTH,BUTTON_HEIGHT);
            distanceButton.addEventListener(MouseEvent.CLICK, clickDistanceButton);
            distanceButton.x = 47;
            distanceButton.y = 100;
            addChild(distanceButton);

            stage.nativeWindow.visible = true;
        }

        private function clickDistanceButton(event:MouseEvent):void {
            clearWindow();
            var distanceScreen:distance = new distance();
            addChild(distanceScreen);
        }

        private function clickHomeButton(event:MouseEvent):void {
            clearWindow();
            drawMainWindow();
        }

        public function createBackground():void {
            var appBackgroundImage:Image = new Image();
              if(backgroundBlack){
                appBackgroundImage.setImage(File.applicationDirectory.resolvePath('backgroundBlack.png').url);  

            appBackgroundImage.setPosition(0,0);
            addChild(appBackgroundImage);
        }

        //Clears the window
        private function clearWindow():void {
            while(numChildren > 0) {
                removeChildAt(0);
            }
        }

    }
}

Now my second page called 'distance.as' is:

package
{
    import flash.display.Sprite;
    import flash.events.MouseEvent;

    import qnx.ui.buttons.IconButton;

    //[SWF(width="1024", height="600", backgroundColor="#cccccc", frameRate="30")]
    public class distance extends Sprite
    {
        public function distance()
        {
            drawDistanceWindow();
        }

        public function drawDistanceWindow():void {

            //Home Button - take back to main app screen.
            var homeButton:IconButton = new IconButton();
            homeButton.addEventListener(MouseEvent.CLICK, clickHomeButton);
            homeButton.setSize(48,48);
            homeButton.setIcon("homeIcon.png");
            homeButton.x = 929;
            homeButton.y = 15;
            addChild(homeButton);
        }

        private function clickHomeButton(event:MouseEvent):void{
            clearWindow();
            var homeScreen:Unit = new Unit();
            addChild(homeScreen);
        }

        //Clears the window
        private function clearWindow():void {
            while(numChildren > 0) {
                removeChildAt(0);
            }
        }

    }
}

When I click on the "homeButton", the screen goes to gray and is not in fact add the new home screen.

Any clue?

In addition, at the same time, you will notice that my first page 'Unit' has a function called "createBackground".

I want to be able to access the function of my second page (title: distance.as). How can I do?

I don't want to rewrite the code again, and so it would be better if I just access my second page (createBackground) function.

If I do: Unit.createBackground ()... it gives me an error.

Any help would be great!

Thank you!

Here's a dispatcher singleton class where you were not sure if it was:

public class SharedData extends EventDispatcher
{
  private static var _instance          : SharedData = null;

  ///////////////////////////////////////////////////////////////////////
  public function SharedData(target:IEventDispatcher=null)
  {
    super(target);
  }

  ///////////////////////////////////////////////////////////////////////
  public static function get instance() : SharedData
  {
    if( _instance == null ) // first time
    {
        _instance = new SharedData();
    }
    return _instance;
  }

  // ...
}

The singleton is added to each class/page/EC that never needs to share information or communicate between pages:

private var shared_data : SharedData = SharedData.instance;

To send a message to a page:

this.shared_data.dispatchEvent( new Event( 'showpage1' ) );

// typically I define a public static const in the singleton class for the event id

In the main root Sprite, he listens to this event (no matter who's asking):

this.shared_data.addEventListener( 'showpage1', ShowPageOne );

// ....

private function ShowPageOne( event : Event ) : void
{
  // show page 1
}

Tags: BlackBerry Developers

Similar Questions

  • ActionScript 3 coding to return to the homepage of 10 secs after audio file stops

    Hello..

    I am having some problems with my Flash project.

    At the moment it all works, but I need now to do something I've never done before.

    Basically, the user selects a page and the project can run through actionscript 3.0, coding, an audio file and displays the page right in the timeline.

    I have a return button which once typed will return to the home page.

    I now need to return to home page 10 dry after the audio file as well as keeping the function of the back button.

    What should I do?

    I can provide the coding I use if necessary.

    I am currently using Flash Pro CS6 on a PC Win 7 Pro.

    Thank you for your help

    Michael

    If you need both something happening you have a few choice items from the timer to choose.

    The less complicated would probably use the setTimeout() function and call the same function as the button uses.  You just need to assign the function of the event argument to null (as in: buttonFunctionName (evt:MouseEvent = null) function).

    Another option is to use the Timer class.

    These two options are documented in the help files if you need to find how to use them.

  • The icon to return to the homepage has disappeared.

    Back to firefox icon has disappeared, that is when I read my gmail, there is no icon (House?) go to the home page. How can I get that back?

    This has happened

    Each time Firefox opened

    Is a few days ago

    Make sure that the toolbar button is on the toolbar.
    See the controls, buttons, and Toolbars Customize Firefox

  • How to return to the homepage of first after finishing the quiz?

    Hi, don't know if it's more a question of Captivate9, but I downloaded an evaluation module for captivate on bonus at the end of a course, it works as expected, but when I finish and then click on the "Continue" button nothing happens. How can I make it behave as learning modules of first failure where you are taken to the home page of the learner? At the moment the only way I can do that is to hit the cross at the top right (circled in red below):

    continue.PNG

    Best, James

    Hello

    You need to take steps to release the button continue in Quiz preferences while creating your Captivate 9 project.

    Steps to follow:

    1. go to preferences in Captivate 9 quiz game

    2. go in Quiz > success or failure

    3. choose 'Exit' action for transmission or quality defect

    Thank you

    Shikha

  • My iPad keeps returning to the home page

    MY iPad 5.01 keeps returning to the homepage when you use, how dp to stop this

    By 5.01 iPad do you mean a first generation iPad?

    It is very possible that what you're trying to do is simply beyond the capabilities of the iPad. If you do not have a first generation iPad then your device is 5-6 years, which is considered old in the world of technology.

    One thing you can try is to force your iPad to restart. Press the sleep and home for 20 seconds approximately. If you see a slider offering to put off, ignore that and hold the buttons until you see the Apple of money. Once you see that, let go of taken and let it reboot and see if that helps.

  • That became the symbol of the 'House '? How do you return to your homepage to another site?

    What happened to the 'House' symbol in the toolbar? I have to close firefox and re-open it to get back to my home page. This "SUCKS" the old version has been produced, what is your problem? Bookmarks have no way to organize more. How many more screwed things I find? You need to meet before you offer new versions.

    On the right side next to the search bar is a house shaped button, click here to return to the start page.

  • How to make the homepage to appear when opening new tab

    Under Firefox 40.x whenever I opened a new tab, my home page appeared. When I upgraded to 41.0, opening a new tab displays the suggested sites. How do I have my home page appear whenever I open a new tab?

    41 of Firefox is no longer uses the browser.newtab.url setting in about: config because he was constantly attacked by malware. From 41 of Firefox, you need an add-on to change the new tab page.

    Here are a few options (I'm learning more all the time):

    • If you are already using Classic theme restaurant: There is an option somewhere (!) in his dialogues of the parameters to select another page in the new tab.

    Setting up substitute again tab

    After installing this extension, you must use the Options page to set the new desired tab page (instead of use subject: config).

    Open the page modules using either:

    • CTRL + SHIFT + a (Mac: Cmd + shift + a)
    • "3-bar" menu button (or tools) > Add-ons

    In the left column, click Extensions. Then on the side right, find the new tab override and click the Options button. (See first screenshot attached).

    Depending on the size of your screen, you may need to scroll down to enter the address in the form. (See second screenshot attached). For example:

    • (Default) page thumbnails = > subject: newtab
    • Blank tab = > subject: empty
    • Built-in Firefox homepage = > topic: welcome
    • Any other page = > full URL of the page

    Then tab or click this form field and you can test using Ctrl + t.

    Success?

    Once you have set it as you wish, you can close the Add-ons page (or use the back button to return to the list of Extensions of this Options page).

  • How to get to the homepage on the tab 'for you '?

    12.4.2.4 iTunes

    With Apple's music subscription, I am browsing inside the tab "for you." There is no button to take me directly to the page by default "for you" main see you playlists and albums selected for your taste.

    The only way to get there is by using the ' back' button on the left and the high if iTunes, which is a real pain, because it works as a browser, to get to where you have just before, so if you've been suspended for different pages for half an hour, you may need to click on dozens of times to return to the home page.

    Please see the image as an attachment, I searched the last album of Daft Punk, chosen. I'm under the tab "for you", there is no button to go home. I have to click several times on the ' back' button on the left corner of the tab bar.

    Is there another way to go to Homepage?

    Hello

    Click on for you. This should bring you back to the default display. It works for me!

    Jim

  • Next button disappears on the homepage

    I asked this without result. If you use firefox, I can search, access a page, go to deep pages, click on the "back" button and forward button; but when I click on the button to return to the home page, the forward button disappears. I did by accident or by design many times. When I back up on the homepage, I have all over again, repeat the search, and it's extremely frustrating.
    It is NOT fixed by the "default restoration."
    It seems that if I return to my home page [generally Google Search] then Firefox guess I won't want to go forward again.
    I don't want an another add-on for it. I just want the next button in all the windows where there is one page forward.
    How can I get that?
    I hate to say it, but it happens enough that I use Chrome for research and just general surfing.
    In my opinion, the show button before being in all windows, grayed out if necessary, but there. But I can accept it endangered when there is NO front page. But not when there is a page to the front.
    Note: this NEVER happens in Chrome [and others.]
    See the photos
    1. Google search
    2. search for Yellowstone
    3. go to the Yellowstone site
    4. click the button back to search page of Yellowstone.
    5. click on back to the Google page.
    Where is the button to the front so that I can move forward looking for Yellowstone?

    Thanks for the follow-up, but to test, I cleaned the machine and new load of Mozilla. It always does the same thing.
    I will consider your reference to follow-up, however.
    ....................................
    Later:
    Yes, my home page was listed as https://www.google.com. But I deleted that and changed. Then deleted that and it changed to https://www.google.com. And now it seems to work. He could have this cache that does not clear properly.
    A note the same thing happened when I changed the homepage to https://192.168.1.20 www.bing.com. But after I deleted and it reinstated, Bing now works properly in the home page. [Although I've switched back to google].
    I have no idea why I have to enter the homepage, save, delete and tenant to operate correctly.
    ............................
    But your comment made me try things, so thank you.
    Don

  • Cannot get new url of the tab open with the homepage (Google).

    After the upgrade, I cannot get rid of 12 boxes (Facebook, Youtube, etc.) on the new tab or make open with my homepage (Google). I tried two different newtaburl add-on, uninstall and reinstall Firefox and the directives of the object: subject: config, browser.newtab.url, etc. I can't even scratch try this approach. I can't get the 12 bar blues.

    Well, I know I'm repeating something you've read before, but just for completeness (and also, I suspect this isn't built-in Firefox page):

    (1) in a new tab, type or paste Subject: config in the address bar and press ENTER. Click on the button promising to be careful.

    (2) in the search above the list box, type or paste newtab and make a pause so that the list is filtered

    (3) double-click the preference browser.newtab.url and enter your favorite page:

    • (Default) page thumbnails = > subject: newtab
    • Blank tab = > subject: empty
    • Built-in Firefox homepage = > topic: welcome
    • Any other page = > full URL of the page

    Press Ctrl + t to open a new tab and check that it worked. Fixed?

    Some traps:

    If Firefox will not let you change this setting: you can have what is called SearchProtect on your system.

    Firefox if allows you to save your changes, but he doesn't know: one of your extensions may be the substitution of her. You can consult, disable and/or remove extensions on page modules. Either:

    • CTRL + SHIFT + a
    • "3-bar" menu button (or tools) > Add-ons

    In the left column, click on Extensions

    If the modification works during your session, but during the next startup is return to the unwanted page: you could have a user.js file in your personal settings Firefox (your Firefox profile folder). This article describes how to track down and delete the file: How to fix preferences that will not save.

    A little luck?

  • I can only access my Inbox in how to return to the main menu?

    When I open Thunderbird, only the Inbox is available without the normal other elements on the left side as sent, trash etc. I can find no way to return to the normal homepage.

    Looks like you have disabled the files pane.
    Press the alt key to display the Menu bar if it is not already displayed.
    The Bar Menu select View-Layout and make sure the folders pane is checked.

    If it is checked and the pane is not displayed, move your mouse on the left margin of the window of Thunderbird. Watch the cursor to set up a double arrow head. When this is the case, left click, hold and drag to the right to drag the pane to records on where you can see.

  • ONCE YOU ARE LOOKING FOR SOMETHING HOW DO YOU RETURN TO THE HOME PAGE WITHOUT LEAVING

    I DO NOT SEE THE BACK ARROWS

    You can open a new tab to return the subject: newtab page with thumbnails of visited web pages.

    If you have set the homepage to this: newtab page then you can click on the home button on the side of the right end of the Navigation bar.

    You do not get a return enabled button to return the subject: newtab page if other pages are open from this page.

  • where is the home page button, how do I do to return to the start page?

    How can I return to the firefox splash screen, which is defined as my homepage? Cannot find a homepage button.

    More customization is coming in the near future (perhaps Firefox 16 or 17 of Firefox)

  • change the homepage

    Is it possible to 'lock' the homepage so apps can not change? Sometimes I install new programs to evaluate them and they change my homepage. I'm using Firefox 3.6.12. Thank you!

    The following method will not prevent the homepage change, but whenever you start Firefox, it starts again home page return to the one you want if it has been changed.

    1. First you have to open the profile folder, for details on how to do this see the article of profiles - where Firefox stores your bookmarks, passwords and other user data .
    2. Close Firefox and using a text editor create a file called user.js (this file may already exist)
    3. Add the following line to user.js, using the homepage you want.
    user_pref("browser.startup.homepage", "http://www.google.com/");
    

    For more information about this file, see http://kb.mozillazine.org/User.js_file

  • Use of blackBerry Smartphones left button practice to immediately go to the homepage of the storm

    Hello

    I found the options to change the left convenience button to open some applications. I'm doing the practical left button go directly to the homepage of the storm that has two or three rows of applications. I always catch myself stuck in the main menu page that contains all the icons for applications and I want to be able to go quickly to the front page. Is it possible to map the practical opening to this page left button. I see a lot of options to map the convenience key but not the one I want.

    Thank you, John

    Choose the option titled "Application list".  Who should be the one you're looking for!

    (And just in case you don't know where to change the settings (although it seems you know), go to Options > keyboard/screen, and then scroll to the bottom to the left side convenience key and select list of applications it.)

    Two other ways to access the home screen application list is to press the button end call (red) to return to the home screen showing the wallpaper, then press once the screen or press the BB menu key.

Maybe you are looking for

  • Tornado diagram

    Dear members, I want to create a Tornado diagram with Apple numbers. I did some research on google, but practically everything I got is linked to Excel. Any info or links in this regard would be helpful as to how I create a diagram of tornado with ap

  • How to disable the integrated graphics card? HP Pavilion a6400f

    I intend to install a new NVIDIA PCI-E x 16 video card, but my HP Pavilion a6400f comes with an Intel integrated graphics. I know that you need to disable the onboard graphics, but how? I checked the BIOS but couldn't find an option to turn it off. A

  • Desktop HP 110-243w very very slow

    Hello It seems that there is not of type 'cat' online that I can find to HP. I've recently upgraded to the new HP 110-243w desktop PC. Of a very old HP d530c, which was a fantastic machine, it just could not be upgraded to 8.1 windows... My question

  • HOW DO WE UNINSTALL STRONGVAULT? IT WILL BE SIMPLY NOT UNINSTALL F / MY COMPUTER & FRANKLY, I DON'T KNOW HOW IT GOT THERE... Help!

    I CAN'T GET RID OF THIS PROGRAM.  I USED THE UNINSTALL FEATURE, BUT IT WILL NOT UNINSTALL.

  • Partitioning & disk backup

    I read I have to 'repartition' disk hard if I want to install UbuntuStudio on a situation of dual boot with Windows. This sounds scarey & beyond my skills. In addition, as a precaution, to have the "backup/restore disk to hand, but my computer (on Vi