You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@flex.apache.org by Admin Billing App <ad...@billingapp.pw> on 2013/05/15 19:41:41 UTC

Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Hello all,

I am a newbie to using Flex, and I am now creating a simple Flex app-> this has a single screen having 2 StageWebViews –> both are used to display different web pages within them.
( I am trying to create simple mobile apps that do this).

For some reason, both StageWebViews are showing blank-

This is the code in the main mxml file--

These are the initial variables declared--

            import mx.events.FlexEvent;
            import spark.events.ViewNavigatorEvent;
            protected var adArea:StageWebView;
            protected var mainArea:StageWebView;
            protected var adFile:File;
            protected var mainFile:File;
            protected var actualurl:String= new String();

This is the content of the init function--

            protected function init(event:ViewNavigatorEvent):void {
                   addEventListener(Event.ADDED_TO_STAGE, createAd);
                    addEventListener(Event.ADDED_TO_STAGE, createMain);
            }

Now the “createAd” and “createMain” functions are nearly identical in functionality—> they basically open 2 different web pages in the 2 StageWebViews named “adArea” and “mainArea” respectively.

Now I am giving below the code for “createMain”--

protected function createMain(e:Event):void {
        removeEventListener(Event.ADDED_TO_STAGE, createMain);
        mainArea = new StageWebView();
        mainArea.stage = stage;
        mainArea.viewPort = new Rectangle(0, 160, stage.width, stage.height);
        mainArea = new StageWebView();
        mainArea.addEventListener(LocationChangeEvent.LOCATION_CHANGE, mainAreaLocationChange);
        mainArea.stage = stage;
        actualurl="http://www.msn.com/";
        mainArea.loadURL(actualurl);
}


And finally given below is the function “mainAreaLocationChage”--


protected function mainAreaLocationChange(event:LocationChangeEvent):void {
    if (mainArea.location != actualurl) {
        navigateToURL(new URLRequest(event.location));
        adArea.loadURL(actualurl);
    }
}

As I mentioned before, when I run the above program—both the web views simply show up as white blank areas. I am not sure what I am doing wrong here? I am using Flash Builder 4.6/4.7 Premium on Windows 8 (x64).

Any help would be appreciated.

Yours sincerely,
Arvind.


Re: Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Posted by Vikram Shityalkar <vi...@raykor.com>.
Link is not working. Need to remove /*especially*/
http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.html

Thanks,
Vikram Shityalkar

<http://www.ineditdemo.com:8080>
On 20/05/2013 1:53 PM, Martin Miko wrote:
> Hello Arvind,
>
> there are two things you need to know, unfortunately I'm not an expert on
> mobile app development and the question you are asking is quite tricky,
> because except different screen sizes you need to take into account
> different pixel densities. I would point you to this article
> http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.htmlespecially
> to the part about scaling bitmaps and detecting device's screen
> size and density.
>
> Anyway, if I had to solve this problem, I would create more versions of the
> bitmap and chose and scale the most fitting version based on the device
> info available during run time. One more thing I'd consider is the layout
> of the app on various screen sizes. As you have not mentioned purpose of
> the image it might not be relevant. The thing is that in some cases it
> makes sense to display an image because you have big enough display, but in
> some it might be bad for UX, because it would occupy too much space. So I'd
> take into account even this aspect.
>


Re: Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Posted by Martin Miko <ma...@gmail.com>.
Hello Arvind,

there are two things you need to know, unfortunately I'm not an expert on
mobile app development and the question you are asking is quite tricky,
because except different screen sizes you need to take into account
different pixel densities. I would point you to this article
http://www.adobe.com/devnet/air/articles/multiple-screen-sizes.htmlespecially
to the part about scaling bitmaps and detecting device's screen
size and density.

Anyway, if I had to solve this problem, I would create more versions of the
bitmap and chose and scale the most fitting version based on the device
info available during run time. One more thing I'd consider is the layout
of the app on various screen sizes. As you have not mentioned purpose of
the image it might not be relevant. The thing is that in some cases it
makes sense to display an image because you have big enough display, but in
some it might be bad for UX, because it would occupy too much space. So I'd
take into account even this aspect.

Re: Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Posted by Arvind Dievs Software <ar...@dievssoftware.com>.
Hi Martin

Thanks a lot-- I just have one more query-- suppose I want one window to 
display an image which normally has size 180 pixels*200 pixels.... Now since 
different devices have their own screen size/resolutions..Can you suggest a 
manner in which I can display that image across different devices- without 
having to consider each device's resolution on an individual basis?

Thanks,
Yours sincerely,
Arvind.


-----Original Message----- 
From: Martin Miko
Sent: Sunday, May 19, 2013 11:39 AM
To: users@flex.apache.org
Subject: Re: Flex Beginner-- Unable to display web page within 2 
StageWebViews on single screen app

Hope I'm not too late, but first of all have a look at this function:

#1 protected function createMain(e:Event):void {
#2        removeEventListener(Event.**ADDED_TO_STAGE, createMain);
#3        mainArea = new StageWebView();
#4        mainArea.stage = stage;
#5        mainArea.viewPort = new Rectangle(0, 160, stage.width,
stage.height);
#6        mainArea = new StageWebView();
#7        mainArea.addEventListener(**LocationChangeEvent.LOCATION_**CHANG
E, mainAreaLocationChange);
#8        mainArea.stage = stage;
#9        actualurl="http://www.msn.com/**";
#10      mainArea.loadURL(actualurl);
#11 }

>From lines 3 to 5 you set up the StageWebView object, this looks ok to me.
Then on line 6 you create a new object without any setup, nor attachment to
stage, reassign it to the mainArea variable and work with that. This won't
work. Another thing to mention is that you define stage.width and
stage.height as width and height parameters, if you want to have both views
visible
you need to divide one of these by two and adjust the x or y coordinate of
the adArea accordingly.

I created a very simple app doing roughly what you need, in terms of
loading the and displaying the web pages
https://gist.github.com/anonymous/5606857 I believe you can take it from
here.

On Thu, May 16, 2013 at 10:21 AM, Arvind Dievs Software <
arvind@dievssoftware.com> wrote:

> Hi
>
> I have seen Flex apps (created by others as tutorials) where 2 web views
> are used on single screen....I saw this post where a blogger showed a
> leadbolt/admob ad in the top portion of the screen, with a web page being
> shown in the bottom portion.
>
> So thats not the issue- and I cant figure out whats wrong with my app ....
>
> Arvind.
>
>
> -----Original Message----- From: Elena Geller
> Sent: Wednesday, May 15, 2013 11:44 PM
> To: users@flex.apache.org
> Subject: Re: Flex Beginner-- Unable to display web page within 2
> StageWebViews on single screen app
>
>
> I guess two StageWebView on single screen may be impossible.
> Am 15.05.2013 20:11 schrieb "Admin Billing App" <ad...@billingapp.pw>:
>
>  Hello all,
>>
>> I am a newbie to using Flex, and I am now creating a simple Flex app->
>> this has a single screen having 2 StageWebViews –> both are used to
>> display
>> different web pages within them.
>> ( I am trying to create simple mobile apps that do this).
>>
>> For some reason, both StageWebViews are showing blank-
>>
>> This is the code in the main mxml file--
>>
>> These are the initial variables declared--
>>
>>             import mx.events.FlexEvent;
>>             import spark.events.**ViewNavigatorEvent;
>>             protected var adArea:StageWebView;
>>             protected var mainArea:StageWebView;
>>             protected var adFile:File;
>>             protected var mainFile:File;
>>             protected var actualurl:String= new String();
>>
>> This is the content of the init function--
>>
>>             protected function init(event:ViewNavigatorEvent)**:void {
>>                    addEventListener(Event.ADDED_**TO_STAGE, createAd);
>>                     addEventListener(Event.ADDED_**TO_STAGE, createMain);
>>             }
>>
>> Now the “createAd” and “createMain” functions are nearly identical in
>> functionality—> they basically open 2 different web pages in the 2
>> StageWebViews named “adArea” and “mainArea” respectively.
>>
>> Now I am giving below the code for “createMain”--
>>
>> protected function createMain(e:Event):void {
>>         removeEventListener(Event.**ADDED_TO_STAGE, createMain);
>>         mainArea = new StageWebView();
>>         mainArea.stage = stage;
>>         mainArea.viewPort = new Rectangle(0, 160, stage.width,
>> stage.height);
>>         mainArea = new StageWebView();
>>         mainArea.addEventListener(**LocationChangeEvent.LOCATION_**
>> CHANGE,
>> mainAreaLocationChange);
>>         mainArea.stage = stage;
>>         actualurl="http://www.msn.com/**";
>>         mainArea.loadURL(actualurl);
>> }
>>
>>
>> And finally given below is the function “mainAreaLocationChage”--
>>
>>
>> protected function 
>> mainAreaLocationChange(event:**LocationChangeEvent):void
>> {
>>     if (mainArea.location != actualurl) {
>>         navigateToURL(new URLRequest(event.location));
>>         adArea.loadURL(actualurl);
>>     }
>> }
>>
>> As I mentioned before, when I run the above program—both the web views
>> simply show up as white blank areas. I am not sure what I am doing wrong
>> here? I am using Flash Builder 4.6/4.7 Premium on Windows 8 (x64).
>>
>> Any help would be appreciated.
>>
>> Yours sincerely,
>> Arvind.
>>
>>
>>
>


-- 
Martin Miko 


Re: Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Posted by Martin Miko <ma...@gmail.com>.
Hope I'm not too late, but first of all have a look at this function:

#1 protected function createMain(e:Event):void {
#2        removeEventListener(Event.**ADDED_TO_STAGE, createMain);
#3        mainArea = new StageWebView();
#4        mainArea.stage = stage;
#5        mainArea.viewPort = new Rectangle(0, 160, stage.width,
stage.height);
#6        mainArea = new StageWebView();
#7        mainArea.addEventListener(**LocationChangeEvent.LOCATION_**CHANG
E, mainAreaLocationChange);
#8        mainArea.stage = stage;
#9        actualurl="http://www.msn.com/**";
#10      mainArea.loadURL(actualurl);
#11 }

>From lines 3 to 5 you set up the StageWebView object, this looks ok to me.
Then on line 6 you create a new object without any setup, nor attachment to
stage, reassign it to the mainArea variable and work with that. This won't
work. Another thing to mention is that you define stage.width and
stage.height as width and height parameters, if you want to have both views
visible
you need to divide one of these by two and adjust the x or y coordinate of
the adArea accordingly.

I created a very simple app doing roughly what you need, in terms of
loading the and displaying the web pages
https://gist.github.com/anonymous/5606857 I believe you can take it from
here.

On Thu, May 16, 2013 at 10:21 AM, Arvind Dievs Software <
arvind@dievssoftware.com> wrote:

> Hi
>
> I have seen Flex apps (created by others as tutorials) where 2 web views
> are used on single screen....I saw this post where a blogger showed a
> leadbolt/admob ad in the top portion of the screen, with a web page being
> shown in the bottom portion.
>
> So thats not the issue- and I cant figure out whats wrong with my app ....
>
> Arvind.
>
>
> -----Original Message----- From: Elena Geller
> Sent: Wednesday, May 15, 2013 11:44 PM
> To: users@flex.apache.org
> Subject: Re: Flex Beginner-- Unable to display web page within 2
> StageWebViews on single screen app
>
>
> I guess two StageWebView on single screen may be impossible.
> Am 15.05.2013 20:11 schrieb "Admin Billing App" <ad...@billingapp.pw>:
>
>  Hello all,
>>
>> I am a newbie to using Flex, and I am now creating a simple Flex app->
>> this has a single screen having 2 StageWebViews –> both are used to
>> display
>> different web pages within them.
>> ( I am trying to create simple mobile apps that do this).
>>
>> For some reason, both StageWebViews are showing blank-
>>
>> This is the code in the main mxml file--
>>
>> These are the initial variables declared--
>>
>>             import mx.events.FlexEvent;
>>             import spark.events.**ViewNavigatorEvent;
>>             protected var adArea:StageWebView;
>>             protected var mainArea:StageWebView;
>>             protected var adFile:File;
>>             protected var mainFile:File;
>>             protected var actualurl:String= new String();
>>
>> This is the content of the init function--
>>
>>             protected function init(event:ViewNavigatorEvent)**:void {
>>                    addEventListener(Event.ADDED_**TO_STAGE, createAd);
>>                     addEventListener(Event.ADDED_**TO_STAGE, createMain);
>>             }
>>
>> Now the “createAd” and “createMain” functions are nearly identical in
>> functionality—> they basically open 2 different web pages in the 2
>> StageWebViews named “adArea” and “mainArea” respectively.
>>
>> Now I am giving below the code for “createMain”--
>>
>> protected function createMain(e:Event):void {
>>         removeEventListener(Event.**ADDED_TO_STAGE, createMain);
>>         mainArea = new StageWebView();
>>         mainArea.stage = stage;
>>         mainArea.viewPort = new Rectangle(0, 160, stage.width,
>> stage.height);
>>         mainArea = new StageWebView();
>>         mainArea.addEventListener(**LocationChangeEvent.LOCATION_**
>> CHANGE,
>> mainAreaLocationChange);
>>         mainArea.stage = stage;
>>         actualurl="http://www.msn.com/**";
>>         mainArea.loadURL(actualurl);
>> }
>>
>>
>> And finally given below is the function “mainAreaLocationChage”--
>>
>>
>> protected function mainAreaLocationChange(event:**LocationChangeEvent):void
>> {
>>     if (mainArea.location != actualurl) {
>>         navigateToURL(new URLRequest(event.location));
>>         adArea.loadURL(actualurl);
>>     }
>> }
>>
>> As I mentioned before, when I run the above program—both the web views
>> simply show up as white blank areas. I am not sure what I am doing wrong
>> here? I am using Flash Builder 4.6/4.7 Premium on Windows 8 (x64).
>>
>> Any help would be appreciated.
>>
>> Yours sincerely,
>> Arvind.
>>
>>
>>
>


-- 
Martin Miko

Re: Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Posted by Arvind Dievs Software <ar...@dievssoftware.com>.
Hi

I have seen Flex apps (created by others as tutorials) where 2 web views are 
used on single screen....I saw this post where a blogger showed a 
leadbolt/admob ad in the top portion of the screen, with a web page being 
shown in the bottom portion.

So thats not the issue- and I cant figure out whats wrong with my app ....

Arvind.


-----Original Message----- 
From: Elena Geller
Sent: Wednesday, May 15, 2013 11:44 PM
To: users@flex.apache.org
Subject: Re: Flex Beginner-- Unable to display web page within 2 
StageWebViews on single screen app

I guess two StageWebView on single screen may be impossible.
Am 15.05.2013 20:11 schrieb "Admin Billing App" <ad...@billingapp.pw>:

> Hello all,
>
> I am a newbie to using Flex, and I am now creating a simple Flex app->
> this has a single screen having 2 StageWebViews –> both are used to 
> display
> different web pages within them.
> ( I am trying to create simple mobile apps that do this).
>
> For some reason, both StageWebViews are showing blank-
>
> This is the code in the main mxml file--
>
> These are the initial variables declared--
>
>             import mx.events.FlexEvent;
>             import spark.events.ViewNavigatorEvent;
>             protected var adArea:StageWebView;
>             protected var mainArea:StageWebView;
>             protected var adFile:File;
>             protected var mainFile:File;
>             protected var actualurl:String= new String();
>
> This is the content of the init function--
>
>             protected function init(event:ViewNavigatorEvent):void {
>                    addEventListener(Event.ADDED_TO_STAGE, createAd);
>                     addEventListener(Event.ADDED_TO_STAGE, createMain);
>             }
>
> Now the “createAd” and “createMain” functions are nearly identical in
> functionality—> they basically open 2 different web pages in the 2
> StageWebViews named “adArea” and “mainArea” respectively.
>
> Now I am giving below the code for “createMain”--
>
> protected function createMain(e:Event):void {
>         removeEventListener(Event.ADDED_TO_STAGE, createMain);
>         mainArea = new StageWebView();
>         mainArea.stage = stage;
>         mainArea.viewPort = new Rectangle(0, 160, stage.width,
> stage.height);
>         mainArea = new StageWebView();
>         mainArea.addEventListener(LocationChangeEvent.LOCATION_CHANGE,
> mainAreaLocationChange);
>         mainArea.stage = stage;
>         actualurl="http://www.msn.com/";
>         mainArea.loadURL(actualurl);
> }
>
>
> And finally given below is the function “mainAreaLocationChage”--
>
>
> protected function mainAreaLocationChange(event:LocationChangeEvent):void 
> {
>     if (mainArea.location != actualurl) {
>         navigateToURL(new URLRequest(event.location));
>         adArea.loadURL(actualurl);
>     }
> }
>
> As I mentioned before, when I run the above program—both the web views
> simply show up as white blank areas. I am not sure what I am doing wrong
> here? I am using Flash Builder 4.6/4.7 Premium on Windows 8 (x64).
>
> Any help would be appreciated.
>
> Yours sincerely,
> Arvind.
>
> 


Re: Flex Beginner-- Unable to display web page within 2 StageWebViews on single screen app

Posted by Elena Geller <el...@gmail.com>.
I guess two StageWebView on single screen may be impossible.
Am 15.05.2013 20:11 schrieb "Admin Billing App" <ad...@billingapp.pw>:

> Hello all,
>
> I am a newbie to using Flex, and I am now creating a simple Flex app->
> this has a single screen having 2 StageWebViews –> both are used to display
> different web pages within them.
> ( I am trying to create simple mobile apps that do this).
>
> For some reason, both StageWebViews are showing blank-
>
> This is the code in the main mxml file--
>
> These are the initial variables declared--
>
>             import mx.events.FlexEvent;
>             import spark.events.ViewNavigatorEvent;
>             protected var adArea:StageWebView;
>             protected var mainArea:StageWebView;
>             protected var adFile:File;
>             protected var mainFile:File;
>             protected var actualurl:String= new String();
>
> This is the content of the init function--
>
>             protected function init(event:ViewNavigatorEvent):void {
>                    addEventListener(Event.ADDED_TO_STAGE, createAd);
>                     addEventListener(Event.ADDED_TO_STAGE, createMain);
>             }
>
> Now the “createAd” and “createMain” functions are nearly identical in
> functionality—> they basically open 2 different web pages in the 2
> StageWebViews named “adArea” and “mainArea” respectively.
>
> Now I am giving below the code for “createMain”--
>
> protected function createMain(e:Event):void {
>         removeEventListener(Event.ADDED_TO_STAGE, createMain);
>         mainArea = new StageWebView();
>         mainArea.stage = stage;
>         mainArea.viewPort = new Rectangle(0, 160, stage.width,
> stage.height);
>         mainArea = new StageWebView();
>         mainArea.addEventListener(LocationChangeEvent.LOCATION_CHANGE,
> mainAreaLocationChange);
>         mainArea.stage = stage;
>         actualurl="http://www.msn.com/";
>         mainArea.loadURL(actualurl);
> }
>
>
> And finally given below is the function “mainAreaLocationChage”--
>
>
> protected function mainAreaLocationChange(event:LocationChangeEvent):void {
>     if (mainArea.location != actualurl) {
>         navigateToURL(new URLRequest(event.location));
>         adArea.loadURL(actualurl);
>     }
> }
>
> As I mentioned before, when I run the above program—both the web views
> simply show up as white blank areas. I am not sure what I am doing wrong
> here? I am using Flash Builder 4.6/4.7 Premium on Windows 8 (x64).
>
> Any help would be appreciated.
>
> Yours sincerely,
> Arvind.
>
>