ADOBE/ ActionScript

[AS] 플래시 액션 스크립트 stageWebView 에서 flash와 html간의 데이터 통신방법 관련(pc, 모바일)

AlrepondTech 2020. 9. 22. 01:24
반응형

 

 

 

=================================

=================================

=================================

 

 

 

 

 

 

출처: http://forums.adobe.com/message/5687066#5687066

load local html on iOS, width event handling

May 27, 2013 6:45 AM

Tags: #air #as3 #ios #ipad

Hi,

I need to donwload/update and load presentations on iPad. Working with external .swf resulted with uncontrolled crash of application. Im looking for rescue in HTML & JS build presentation.

I'm trying to find solution, that allow me to load .html file from applicationStorageDirectory, and capture events, like window.status in HTMLHost & HTMLLoader, but:

- HTMLloader is not supported on iOS (code that works for desktop, doesn't work for iOS distribution)

- WebStageView doesn't allow me to interact with app, only historyBack()/historyForward()

 

Does anybody try with success to load and interact html in AIR on iOS, and can shere the solution with others?

Translate

437 Views   1 Reply   Latest reply: simonschweizer, Sep 16, 2013 2:56 PM

Was this helpful? Yes   No

 

its not so easy. you can use webstageview. to call javscript from actionscript you have to do something like that  this.webview.loadURL("javascript:myfunction('value'));"); notice that you have to call functions.

 

if you want to call as3 function from javascript you have to use somthing like that    window.location.href = "myprotocoll:myfunction?parameter=test";

and in AS3 you need to catach this redirect:

this.webview.addEventListener(LocationChangeEvent.LOCATION_CHANGING,lo cationChanging);

 

public function locationChanging(evt:LocationChangeEvent):void

{

var currLocation : String = unescape( (evt as LocationChangeEvent).location );

 

switch( true )

{

// javascript calls actionscript

case currLocation.indexOf( 'myprotocoll') != -1:

 

parseCallBack( currLocation.split('myprotocoll' )[1] );

break;

}

 

evt.preventDefault();

}

 

this is small example I haven't testet it. I use my own JS-AS-Bridge to transfer images or paths, objects, usinge base64 encoding. You can also usehttp://code.google.com/p/stagewebviewbridge/

 

 

=================================

=================================

=================================

 

 

출처: https://code.google.com/p/stagewebviewbridge/

 

22/11/2011 New Version 1.0 Beta 3, Added Basic examples, Adobe Docs, fixed some bugs

StageWebViewBridge

StageWebViewBridge is an extended version of flash.media.StageWebView.

  • Extends Bitmap class, you can modify his x,y,alpha,rotation,visible, etc ( Version 1 Beta )
  • Communicates Actionscript with Javascript.
  • Communicates Javascript with Actionscript.
  • Load local files and resources in a easy way.
  • Extends loadString method with AS3 - JS communication.
  • Extends loadString method to load local resources.
  • Lets you take an SnapShot to use as the bitmapData of the bitmap.

By example you can call javascript from as3

// call javascript with callack function
webView
.call('someFunctionToCall', callBackFunction, ...arguments );

// reference local resources in a easy way
<img src="appfile:/image.png">

Downloads

Lattest swc swc

StageWebViewBridge27.zip is meant to be used with AIR 2.7 or LOWER.

StageWebViewBridge_svn ... .zip is meant to be used with AIR 3.0 or HIGHER.

Asdocs

Download the documentation here

Examples

You can download the examples here

Avaliable wiki pages

Manage local resources and cache: CacheFileSystem

Usage: Usage

Communication between as3 and javascript and vice versa: Communication

Load local files and reference resources: ContentLoading

The StageWebViewBridge Class: StageWebViewBridgeClass

The StageWebViewDisk Class: StageWebViewDiskClass

 

 

=================================

=================================

=================================

 

 

 

출처: http://blog.naver.com/brane7?Redirect=Log&logNo=70156837782

안드로이드 webview 에서 flash와 상호작용.zip
1.78MB

 

주의!  html은 파일에 포함이 되어야 하며 www경로 안에 들어가 있어야 한다

또한 뒤로 붙는 파라메터는 인식이 되지 않는다

import es.xperiments.media.StageWebViewDisk;
import es.xperiments.media.StageWebviewDiskEvent;
import es.xperiments.media.StageWebViewBridge;
import es.xperiments.media.StageWebViewBridgeEvent;
import flash.events.Event;
import flash.events.MouseEvent;





// 모바일 에서 작동 한다 
var view:StageWebViewBridge;

output.appendText('Init\n');

//디스크 파일시스템을 이용하여 데이터 전송
StageWebViewDisk.addEventListener(StageWebviewDiskEvent.END_DISK_PARSING, onInit );
StageWebViewDisk.setDebugMode( true );
StageWebViewDisk.initialize(stage);

/* Fired when StageWebviewDiskEvent cache process finish */
function onInit( e:StageWebviewDiskEvent ):void
{
 output.appendText( 'END_DISK_PARSING\n'); 
 
 // create the view
 view = new StageWebViewBridge( 0,0, 320,240 );
 
 //웹뷰를 스테이지에 등록 시킨다 
 addChild( view );
 
 //html페이지에서 클릭시 일정의 변수가 플레시로 넘어온다 
 view.addCallback('fnCalledFromJS', fnCalledFromJS );
 
 //첨부된 hhtml 을 열어준다 
 view.loadLocalURL('applink:/ExampleBasic.html');
 
 // 플레시에서 버튼클릭시 자바스크립트의 일정 함수를 호출한다 
 button.addEventListener(MouseEvent.CLICK, callJavascriptFunction );
}


 

//html에서 flash로 넘어올때 
function fnCalledFromJS( data:String ):void
{
 // append the text coming from JS to the textarea component
 output.appendText( data +'\n'); 
}





//flash에서 html로 넘어 갈때 
function callJavascriptFunction( e:Event ):void
{
 // call javascript fnCalledFromAs3 function from As3
 view.call('fnCalledFromAs3',null,'This String comes from AS3');
}

 

[출처] stageWebView 에서 flash와 html간의 데이터 통신방법|작성자 LET

 

 

=================================

=================================

=================================

 

 

반응형