• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Open html file inside the application

Explorer ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

I’m creating some application (Android and IPad) using Flash CS6 (AS3). Want to open some online html (http://www.delta-adv.com/roche/form.php) file inside the application according the specific size which we will set inside the code. For example my application layout size is 1024 x 768 and when I press the button, html file have to open inside the application layout with 800 x 600 size

Is there any possibility to do like this?

TOPICS
ActionScript

Views

6.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jan 15, 2013 Jan 15, 2013

this is copied from the adobe class files:

package {

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

    public class HTMLLoaderExample extends Sprite

    {

        public function HTMLLoaderExample()

        {

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

  

...

Votes

Translate

Translate
Community Expert ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

yes, use the HTMLLoader class.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

How?? if u dont main can you give me the code.

I hear about UI WEB VIEW.  I don’t know about this can you help me how and which one is the best solution for this

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

this is copied from the adobe class files:

package {

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

    public class HTMLLoaderExample extends Sprite

    {

        public function HTMLLoaderExample()

        {

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

            addChild(html);

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

can i set the size as wll? with required width and height

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

yes, just change html.width and html.height.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 15, 2013 Jan 15, 2013

Copy link to clipboard

Copied

i try this but got this error

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 16, 2013 Jan 16, 2013

Copy link to clipboard

Copied

Make sure to target AIR in your publishing options.

(Code works for me perfectly targeting AIR 3.4/Desktop.)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

yes boss im publishing in Air for Android

(using Flash CS5.5, i dont have Air 3.4/Destop)

i use this code

package {

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

    import flash.display.SimpleButton;

    public class bhtml extends SimpleButton

          {

        public function bhtml()

        {

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

            addChild(html);

        }

    }

}

got the erroer

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

SimpleButton can have no children.

it should say:

public class bhtml extends MovieClip

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

Now, I didn’t get any error but URL in not opening

package {

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

          import flash.display.MovieClip;

    public class bhtml extends MovieClip

          {

        public function bhtml()

        {

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

            addChild(html);

        }

    }

}

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

Where in your main application do you instantiate bhtml?

Is this green rectangle the Button?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

green rectangel is my movie clip (bhtml). i use my class on this movie clip. i need when i click on this green tectangel my URL have to open... but is not opaning

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

Make sure that your button is properly exported for Actionscript.

Manual how to do that is here

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

yes i did

01.jpg

02.jpg

03.jpg

if you dont mind you can also download my file

http://delta-adv.com/nav/02-htmlloader.rar

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

Base class in image 1 should say:

flash.display.MovieClip

click on the pencil besides class:bhtml to check if the bhtml.as class you wrote is actually linked to the fla (it should be in the same folder as the fla file)

if you click on the pencil and this comes up:

package  {

   

    import flash.display.MovieClip;

   

   

    public class bhtml extends MovieClip {

       

       

        public function bhtml() {

            // constructor code

        }

    }

   

}

then you can be sure that the code you wrote above never reaches your MovieClip.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

yes when I click on the pencil my bhtml class open (from same folder)

package {

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

          import flash.display.MovieClip;

    public class bhtml extends MovieClip

          {

        public function bhtml()

        {

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

            addChild(html);

        }

    }

}


04.jpg

02-b.jpg

My all files in the same directory (.fla and .as)

05.jpg


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

Good. Then now you have to program the actual behaviour of your button. Because at the moment, your html gets immediately loaded on stage without clicking the button. (at least it does that in my case)

rewrite your bhtml.as like so:

package {

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

          import flash.display.MovieClip;

    public class bhtml extends MovieClip

          {

        public function bhtml()

        {

           this.addEventListener(MouseEvent.CLICK, loadHtml);

        }

       public function loadHtml(e:MouseEvent):void{

            trace("CLICKED");

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

           //you don`t want to add the page to the button, but to the stage

            this.parent.addChild(html);

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

i got this error

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 17, 2013 Jan 17, 2013

Copy link to clipboard

Copied

Here we go:

package

{

    import flash.display.Sprite;

    import flash.html.HTMLLoader;

    import flash.net.URLRequest;

    import flash.display.MovieClip;

    public class bhtml extends MovieClip

    {

        public function bhtml()

        {

            this.addEventListener(MouseEvent.CLICK, loadHtml);

        }

        public function loadHtml(e:MouseEvent):void

        {

            trace("CLICKED");

            var html:HTMLLoader = new HTMLLoader();

            var urlReq:URLRequest = new URLRequest("http://www.adobe.com/");

            html.width = stage.stageWidth;

            html.height = stage.stageHeight;

            html.load(urlReq);

            //you don`t want to add the page to the button, but to the stage

            this.parent.addChild(html);

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2013 Jan 19, 2013

Copy link to clipboard

Copied

boss in this time i got this error

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 19, 2013 Jan 19, 2013

Copy link to clipboard

Copied

import flash.events.MouseEvent;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jan 19, 2013 Jan 19, 2013

Copy link to clipboard

Copied

now i got this output message, but still URL is not open

01.jpg

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Jan 21, 2013 Jan 21, 2013

Copy link to clipboard

Copied

For testing take a url like google.com that loads quickly. It takes a while depending on your connection.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 01, 2013 Jul 01, 2013

Copy link to clipboard

Copied

LATEST

thx boss, its work

package  {

    import flash.display.SimpleButton;

          import flash.media.StageWebView;

    import flash.geom.Rectangle;

    import flash.events.KeyboardEvent;

    import flash.ui.Keyboard;

    import flash.desktop.NativeApplication;

          import flash.events.MouseEvent;

               

    public class bclick extends SimpleButton{

        private var webView:StageWebView = new StageWebView();

 

                    public function bclick() {

                              this.addEventListener(MouseEvent.CLICK,clickF);

                              }

                               

        public function clickF(e:MouseEvent):void

        {

            webView.stage = this.stage;

            //webView.viewPort = new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight );

                              webView.viewPort = new Rectangle( 50, 50, 700, 400 );

            webView.loadURL( "http://delta-adv.com/roche/form.php" );

                                               

            stage.addEventListener( KeyboardEvent.KEY_DOWN, onKey );

        }

                               

        private function onKey( event:KeyboardEvent ):void

        {

            if( event.keyCode == Keyboard.BACK && webView.isHistoryBackEnabled )

            {

                trace("Back.");

                webView.historyBack();

                event.preventDefault();

            }

            if( event.keyCode == Keyboard.SEARCH && webView.isHistoryForwardEnabled )

            {

                trace("Forward.");

                webView.historyForward();

            }

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines