月度存档: 6 月 2021

animate文本滚动条组件

import fl.controls.UIScrollBar;
import fl.controls.ScrollBarDirection;
var url2:String="https://amyflash.com";
var uLdr:URLLoader=new URLLoader(new URLRequest(url2));
uLdr.addEventListener(Event.COMPLETE, completeHandler);
var tf:TextField = new TextField();
tf.width=320;
tf.height=140;
tf.x=10;
tf.y=10;
tf.border=true;
tf.multiline=true;
tf.wordWrap=false;
addChild(tf);
/*
    如果只需要垂直方向滚动条,那么先设置tf.wordWrap=true,然后不要添加水平滚动条即可。
*/
//水平滚动条
var hScrollBar:UIScrollBar = new UIScrollBar();
hScrollBar.direction=ScrollBarDirection.HORIZONTAL;
hScrollBar.move(tf.x, tf.y + tf.height);
hScrollBar.width=tf.width;//一定要设置和文本框一样宽,不然不美观
hScrollBar.scrollTarget=tf;
addChild(hScrollBar);
//垂直滚动条
var vScrollBar:UIScrollBar = new UIScrollBar();
vScrollBar.direction=ScrollBarDirection.VERTICAL;
vScrollBar.move(tf.x + tf.width, tf.y);
vScrollBar.height=tf.height;//一定要设置和文本框一样高,不然不美观
vScrollBar.scrollTarget=tf;
addChild(vScrollBar);
function completeHandler(event:Event):void {
    tf.text=event.target.data;
    hScrollBar.update();
    vScrollBar.update();
}

Adobe Animate ReferenceError:错误#1069:在_上找不到属性loopMode,并且没有默认值

当我向Adobe Animate 2019中的MovieClip添加.as类时遇到以下错误:
Adobe Animate ReferenceError:错误#1069:在_上找不到属性loopMode,并且没有默认值
相同的项目适用于早期版本的Animate或flash而不会出错..as文件没什么特别之处.
solution:
打开”高级图层”时会发生此问题.您必须关闭”高级图层”才能在项目中使用某些代码.

1.转到stage的属性面板.

2.单击”高级设置”.

3.取消选中”使用高级图层”模式.

4.单击确定.

air创建一个新窗口

import flash.display.NativeWindowInitOptions;
import flash.display.NativeWindowSystemChrome;
import flash.display.NativeWindowType;
import flash.display.NativeWindow;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.geom.Rectangle;

var windowOptions:NativeWindowInitOptions = new NativeWindowInitOptions();
windowOptions.systemChrome = NativeWindowSystemChrome.STANDARD;
windowOptions.type = NativeWindowType.NORMAL;

var newWindow:NativeWindow = new NativeWindow(windowOptions);
newWindow.stage.scaleMode = StageScaleMode.NO_SCALE;
newWindow.stage.align = StageAlign.TOP_LEFT;
newWindow.bounds = new Rectangle(200, 200, 800, 800);

newWindow.activate();

参考:https://help.adobe.com/zh_CN/FlashPlatform/reference/actionscript/3/flash/display/NativeWindow.html#NativeWindow()

animatecc添加sdk

打开animatecc,在管理->帮助->管理adobesdk->+,添加sdk路径

adobe air runtime下载:https://airsdk.harman.com/runtime
adobe air sdk下载:https://airsdk.harman.com/

air添加和使用ane

1、用animate cc 新建一个air 项目;
2、打开文件—actionScript设置—库路径—点击(浏览到本机扩展(ANE)文件)—找到我们生成的那个ANE文件
3、愉快的引用该ane中的类即可
ane github:https://github.com/tuarua/WebViewANE
示例:

package {
import com.tuarua.FreSharp;
import com.tuarua.FreSwift;
import com.tuarua.WebView;
import com.tuarua.webview.Settings;

import flash.desktop.NativeApplication;

import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Rectangle;
import flash.net.URLRequest;
import flash.utils.setTimeout;

[SWF(width="1024", height="768", frameRate="60", backgroundColor="#F1F1F1")]
public class WebViewExampleAS3 extends Sprite {
    private var freSharpANE:FreSharp = new FreSharp(); // must create before all others
    private var freSwiftANE:FreSwift = new FreSwift(); // must create before all others
    private var webView:WebView;
    private var hasActivated:Boolean;

    public function WebViewExampleAS3() {
        this.addEventListener(Event.ACTIVATE, onActivated);
    }

    protected function onActivated(event:Event):void {
        if (hasActivated) return;
        setTimeout(init, 0); // this is handle the HARMAN splash screen
        hasActivated = true;
    }

    protected function init():void {
        NativeApplication.nativeApplication.addEventListener(Event.EXITING, onExiting);
        var viewport:Rectangle = new Rectangle(0, 0, 1024, 768);
        var settings:Settings = new Settings();
        webView = WebView.shared();
        webView.init(stage, viewport, new URLRequest("https://html5test.com"), settings, 1, 0xFFF1F1F1);
        webView.visible = true;
    }
    private function onExiting(event:Event):void {
        WebView.dispose();
        FreSwift.dispose();
        FreSharp.dispose();
    }
}
}