×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Registered User
    Join Date
    Jun 2009
    Posts
    6

    Setting the default orientation for flash app

    Hi All,

    I have developed a simple accelerometer based game for Nokia 5800 using flash. I want to set the default orientation for my game as "landscape" and then disable auto rotation.

    I know i can disable auto rotation by using the DisableAutoRotation(true) method of deviceObject.

    But how do i set the default orientation.

    I want my app to switch to landscape even if launched in portrait.

    Is it possible?

  2. #2
    Nokia Developer Champion
    Join Date
    Jul 2008
    Location
    Pakistan
    Posts
    1,065

    Smile Re: Setting the default orientation for flash app

    Quote Originally Posted by vikvig View Post
    Hi All,

    I have developed a simple accelerometer based game for Nokia 5800 using flash. I want to set the default orientation for my game as "landscape" and then disable auto rotation.

    I know i can disable auto rotation by using the DisableAutoRotation(true) method of deviceObject.

    But how do i set the default orientation.

    I want my app to switch to landscape even if launched in portrait.

    Is it possible?
    I can give u 2 solutions :
    1 - If u r making a full screen Flash Lite game then just put all your objects into a main movie clip and rotate that movie clip to set it to landscape.
    2 - I see this method in many commercial j2me games like Sonic By GameLoft.Simply, create a movie clip on the top layer with black background and a text on it "This game wont work with portrait mode.Please! switch your phone to landscape mode" . Now, what u have to do is to detect the orientation of phone if it is portrait visible the clip otherwise hide it. To detect orientation , we have three methods :
    Detecting Device Orientation Using Sensor
    or
    How_to_make_Flash_Lite_aware_of_softkey_location_and_screen_orientation
    or just put a movie size listener , if height > width portrait else landscape.
    Choose the one which suits ur situation. Hope it helps...

    Best Regards,
    SajiSoft
    Last edited by sajisoft; 2009-12-02 at 22:20. Reason: Correction

  3. #3
    Registered User
    Join Date
    Jan 2007
    Location
    bucharest
    Posts
    222

    Re: Setting the default orientation for flash app

    I'll do like this:

    this code to disable autorotate:

    import com.nokia.lib.Device;
    var deviceObject:Object = new Device();
    deviceObject.DisableAutoRotation(true);


    and your app should rotate 90 degrees like _root._rotation=90 or _root._rotation=-90 depends on what angle you will like to view the landscape
    I guess it will have to be some of
    _root._x=360 or _root._y=360 or something like this (rotate will rotate your work-area with 0,0 as the center of the rotation)

  4. #4
    Registered User
    Join Date
    Jun 2009
    Posts
    6

    Re: Setting the default orientation for flash app

    Hi all,

    Thank you very much for your help.

    But the thing is I am using a callback funtion for rotation. That stops working when I rotate the entire content my self by 90 degrees from the code.

    So I planned to use the 2nd method given by saji(which in fact I had used earlier without success). What I am doing is something as follows:

    1. I have registered two callbacks from the Sensor service object, one for orientation and one for rotation.

    2. So what I did was to use to orientation callback to determine what the orientation is. Depending on this I show a message asking the user to rotate if he launches in portrait.

    3. Once he has rotated to the landscape mode I turn off auto rotation by DisableAutoRotation(true).

    But as soon as I do this the dislay goes for a toss. Everything becomes clattered. Intially I thought it is because I am disabling auto rotation before the rotation to the landscape mode has completed. So I increased the delay, that is, I disabled auto rotation after some 40 frames. What I observed was strange to say the least.

    Things worked fine for 40 frames. The display rotated to landscape without issues.

    But as soon as the 40th frame was reached, the display got clattered again. Is it because of the fact that I have registered for callback for orientation?? If yes, how do I unregister?

    Thanks in advance

  5. #5
    Nokia Developer Champion
    Join Date
    Jul 2008
    Location
    Pakistan
    Posts
    1,065

    Smile Re: Setting the default orientation for flash app

    I think using sensor is not a good idea to detect only potrait and landscape orientation as motion sensor drains battery . Why not give a try to use fscommand2("GetSoftKeyLocation"). Try something like this :
    On first frame , make a setInterval function followed by a stop :
    Code:
    function callb() { 
    loc =fscommand2("GetSoftKeyLocation")
    // loc is 2 if potrait and loc is 3 if landscape
    if (loc == 3)
    {
    	//Lanscape Mode lock the position
            //goto Next Frame
    }
    else 
    {
    //display the notification
    }
    }
    var intv::Number = setInterval( callb, 1000 );
    stop();
    On next frame remove the interval (unregister) , by using clearInterval function.. May be it helps u ..

    Best Regards,
    SajiSoft

  6. #6
    Registered User
    Join Date
    Jun 2009
    Posts
    6

    Re: Setting the default orientation for flash app

    Thanks saji,

    I have a similar kind of work around. I pause the game and show the user a message to change the orientation. But I really wanted to disable the auto rotation, couldn't do it.

    Anyways will keep trying to find solution. If I find it, I will post it.

    You too keep me posted.

    Thanks again.

  7. #7
    Registered User
    Join Date
    Oct 2009
    Posts
    126

    Re: Setting the default orientation for flash app

    Quote Originally Posted by vikvig View Post
    Thanks saji,

    I have a similar kind of work around. I pause the game and show the user a message to change the orientation. But I really wanted to disable the auto rotation, couldn't do it.

    Anyways will keep trying to find solution. If I find it, I will post it.

    You too keep me posted.

    Thanks again.
    Vikvig, did you manage to solve this problem? I'm struggling with the exact same phenomenon for two days now, and can't seem to figure it out. The screen keeps corrupting every time DisableAutoRotation() is called within a callback/timer.
    Thanks,
    Ranco

  8. #8
    Regular Contributor
    Join Date
    Feb 2005
    Location
    Karachi, Pakistan
    Posts
    277

    Re: Setting the default orientation for flash app

    Hi,

    Do not put any code to stop auto rotation. Just put a stage resize listener, and whenever the size changes, rotate accordingly.

    i.e.
    Code:
    Stage.onResize = function()
    {
        // landscape mode
        if(Stage.width > Stage.height)
        {
            // do rotation
            _root._rotation = 90;
        }
        // landscape mode
        if(Stage.width > Stage.height)
        {
            // do rotation
            _root._rotation = 90;
        }
        // portrait mode
        else
        {
            // do rotation
            _root._rotation = 0;
        }
    }
    Hope this helps,

    // chall3ng3r //
    Faisal Iqbal (skype: chall3ng3r)
    Flash Mobile Specialist | Orison Technologies
    _____________________________________
    blog: F·L·A·S·H·I·S·M
    swf2go: www.swf2go.com

  9. #9
    Registered User
    Join Date
    Oct 2009
    Posts
    126

    Re: Setting the default orientation for flash app

    Quote Originally Posted by chall3ng3r View Post
    Hi,

    Do not put any code to stop auto rotation. Just put a stage resize listener, and whenever the size changes, rotate accordingly.

    i.e.
    Code:
    Stage.onResize = function()
    {
        // landscape mode
        if(Stage.width > Stage.height)
        {
            // do rotation
            _root._rotation = 90;
        }
        // landscape mode
        if(Stage.width > Stage.height)
        {
            // do rotation
            _root._rotation = 90;
        }
        // portrait mode
        else
        {
            // do rotation
            _root._rotation = 0;
        }
    }
    Hope this helps,

    // chall3ng3r //
    Yes, I did that. But it is not the perfect solution, as rotation still occurs, detected and corrected. It results in jumpy application if you move the phone. I think the right solution should combine both capturing stage resize event and disabling Auto Rotate. Can't figure out exactly how...
    Ranco

  10. #10
    Regular Contributor
    Join Date
    Feb 2005
    Location
    Karachi, Pakistan
    Posts
    277

    Re: Setting the default orientation for flash app

    Yeah its a jumpy solution,

    You can put a small logic there. If user starts the app in when phone is in landscape mode, detect this on start-up and ask user to change orientation to portrait mode. Once he does this, detect it, and disable auto rotation. So it won't rotate anymore automatically.

    Same cane be done if you don't want to ask user any question. On app start-up, detect the orientation, and make the required rotation in app. and lock the autoration. so when user changes the orientation, it is already locked.

    Hope this helps,

    // chall3ng3r //
    Faisal Iqbal (skype: chall3ng3r)
    Flash Mobile Specialist | Orison Technologies
    _____________________________________
    blog: F·L·A·S·H·I·S·M
    swf2go: www.swf2go.com

  11. #11
    Nokia Developer Champion
    Join Date
    Jul 2008
    Location
    Pakistan
    Posts
    1,065

    Smile Re: Setting the default orientation for flash app

    Well ! i am able to write a non-jumpy workaround. Put this AS in first frame of ur landscape flash lite content :
    Code:
    fscommand2("DisableKeypadCompatibilityMode");
    fscommand2("FullScreen", true);
    Stage.scaleMode = "noScale";
    Stage.align = "TL";
    and this in AS in Second frame :
    Code:
    import com.nokia.lib.Device;
    
    var deviceObject:Object = new Device();
    
    deviceObject.DisableAutoRotation(true);  
    
    var i = fscommand2("GetSoftKeyLocation");
    
    if (i == 2)
     //2 means that the player is launched in portrait mode
    {
    _root._rotation = -270;
    
    _root._x = 360;
    
    _root._y = 0;
    
    }
    and now u see that ur content is locked in landscape mode.

    Best Regards,
    SajiSoft

  12. #12
    Registered User
    Join Date
    Oct 2009
    Posts
    126

    Re: Setting the default orientation for flash app

    Ok, I think I should be more specific. I've already tried this solution, then had a problem when the application starts in portrait mode. So I've put the rotation code either in Stage.onResize callback or in a simple timer code. both work fine.

    So what is my problem, you may ask? Ok, if you start up the application in portrait mode, rotate the phone to landscape, and later ask the user to enter some text into a InputText field (i.e., enter his name for top score),

    1. the mini QWERTY keyboard (Nokia 5800 XpressMusic) opens in portrait mode, which is annoying
    2. Once the text is copied into a different dynamic text (i.e., Top 10), this text field strangly rotates back to portrait mode(!), which is of course, unacceptable.

    I thought that adding some logic and force eviceObject.DisableAutoRotation(true) inside a simple timer callback, I get the distorted screen I've mentioned before.

    Maybe I should also mention that the application itself is designed horizontally (in landscape).
    Thanks for all your help,
    Ranco

  13. #13
    Nokia Developer Champion
    Join Date
    Jul 2008
    Location
    Pakistan
    Posts
    1,065

    Smile Re: Setting the default orientation for flash app

    The behaviour of DeviceObject.DisableAutoRotation(true) which i experienced is as under :
    1- If application is launched in portrait then calling it locks the screen in portrait even ur device is in landscape at the time of calling this device object function and vice versa .
    2- Using it inside the setInterval results a corrupt screen which follows point # 1 too.
    3- Putting it on a button doesnt corrupt the screen but it again follows point # 1.
    Therefore, there doesnt seems to be a a more accurate solution to me.
    1. the mini QWERTY keyboard (Nokia 5800 XpressMusic) opens in portrait mode, which is annoying
    2. Once the text is copied into a different dynamic text (i.e., Top 10), this text field strangly rotates back to portrait mode(!), which is of course, unacceptable.
    These points really makes ur app unacceptable but what if u create one of ur own keyboard for ur application as i see it in all offsreen apps (powered by Symbian C++ where it is not that easy as in flash lite) OR just create a multi orientation app which 1 is easy 4 u . Wish u luck .

    Best Regards,
    SajiSoft

  14. #14
    Registered User
    Join Date
    Oct 2009
    Posts
    126

    Re: Setting the default orientation for flash app

    ok, thanks. I'll keep trying. Have one more idea, will try it tomorrow.
    I missed the fact that no matter when you lock, it will lock on the application's launch orientation. That is strange. It all seems like flashlite bugs, so nothing we can do about it, right?
    Regards,
    Ranco

  15. #15
    Nokia Developer Champion
    Join Date
    Jul 2008
    Location
    Pakistan
    Posts
    1,065

    Smile Re: Setting the default orientation for flash app

    Quote Originally Posted by ranco View Post
    I missed the fact that no matter when you lock, it will lock on the application's launch orientation. That is strange. It all seems like flashlite bugs,
    Yeah it seems to b a bug.They have to develop a simple api which allows user to lock in landscape or portrait or unlock both as we have such api in Python, M-shell & Symbian C++ .
    so nothing we can do about it, right?
    If u r asking about the behaviour of device object then yes we cant do any thing to change its behaviour.

    Best Regards,
    SajiSoft

Similar Threads

  1. can my app override the default security setting
    By eugie17 in forum Mobile Java General
    Replies: 2
    Last Post: 2008-12-23, 17:51
  2. Replies: 3
    Last Post: 2008-10-10, 08:15
  3. Problem with Skin enabling - disabling and Setting List in S60
    By sauvikds in forum Symbian User Interface
    Replies: 1
    Last Post: 2008-08-22, 13:45
  4. Problem with py standalone app
    By darrarski in forum Symbian
    Replies: 0
    Last Post: 2007-11-23, 14:11
  5. Setting default APN for RealOne Player
    By soniatm in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2003-11-02, 21:10

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×