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?
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);
...
Copy link to clipboard
Copied
yes, use the HTMLLoader class.
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
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);
}
}
}
Copy link to clipboard
Copied
can i set the size as wll? with required width and height
Copy link to clipboard
Copied
yes, just change html.width and html.height.
Copy link to clipboard
Copied
i try this but got this error
Copy link to clipboard
Copied
Make sure to target AIR in your publishing options.
(Code works for me perfectly targeting AIR 3.4/Desktop.)
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
Copy link to clipboard
Copied
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);
}
}
}
Copy link to clipboard
Copied
Where in your main application do you instantiate bhtml?
Is this green rectangle the Button?
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
Copy link to clipboard
Copied
Make sure that your button is properly exported for Actionscript.
Manual how to do that is here
Copy link to clipboard
Copied
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.
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);
}
}
}
My all files in the same directory (.fla and .as)
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);
}
}
Copy link to clipboard
Copied
i got this error
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);
}
}
Copy link to clipboard
Copied
boss in this time i got this error
Copy link to clipboard
Copied
import flash.events.MouseEvent;
Copy link to clipboard
Copied
now i got this output message, but still URL is not open
Copy link to clipboard
Copied
For testing take a url like google.com that loads quickly. It takes a while depending on your connection.
Copy link to clipboard
Copied
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();
}
}
}
}