热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

将actionscript从时间轴移动到外部.as文件-Moveactionscriptfromtimelinetoexternal.asfile

Igotaseriusproblemcozidontknowsomuchaboutas3.我有一个严重的问题因为我不太了解as3。Ihaveanactionscri

I got a serius problem coz i dont know so much about as3.

我有一个严重的问题因为我不太了解as3。

I have an actionscript code in a project that in timeline Frame one and the code is:

我在一个项目中有一个actionscript代码,在时间轴第一帧和代码是:

stop();


    import flash.display.BitmapData;
    import flash.display.SimpleButton
    import flash.display.Bitmap;
    import flash.display.Loader;
    import flash.display.MovieClip;
    import flash.errors.IOError;
    import flash.events.ProgressEvent;
    import flash.net.FileFilter;
    import flash.net.FileReference;
    import flash.net.URLVariables;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.utils.ByteArray;

    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;


    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.net.URLRequestMethod;
    import flash.net.URLLoaderDataFormat;
    import flash.net.URLRequestHeader;
    import flash.geom.ColorTransform;

    import flash.geom.Matrix;
    import flash.display.LoaderInfo;
    import flash.events.IOErrorEvent;
    import flash.events.SecurityErrorEvent;


import com.drooza.*;
import caurina.transitions.Tweener;

const thumbWidth:int = 90;
const numThumbsShown:int = 5;

var thumb_array:Array = [];
var thumbContainer:Sprite = new Sprite(), 
    pictureContainer:Sprite = new Sprite();

var leftMostThumb:int = 0; //for sliding thumbs
var currentThumb:int = 0;
var thumbsXML:XMLReader = new XMLReader("gallery.xml");

var thumbcurrentThumbList:XMLList;
var pictureLoader:Loader;


//var _browseBtn: SimpleButton;


thumbsXML.init();
thumbsXML.addEventListener(Event.COMPLETE, thumbCompleteHandler);

pictureContainer.addEventListener(MouseEvent.CLICK, gotoLargePicture);
pictureContainer.buttOnMode= true;
pictureContainer.mouseChildren = false;
pictureContainer.x = 10;
pictureContainer.y = 10;

addChild(pictureContainer);
addChildAt(thumbContainer, getChildIndex(mask_mc) - 1);

with(thumbContainer)
{
    mask = mask_mc;
    x = mask_mc.x;
    y = mask_mc.y;
}

thumbsXML.parseXML = function() {
    clearContainer(thumbContainer);

    try {
//  
//  
//      
        trace(thumbsXML.xmlData..album.length() + " albums found.");

        for each(var album:XML in thumbsXML.xmlData..album)
        {
            trace("ALBUM: \n" + album);
            for each(var image:XML in album.image)
            {
                trace("THUMB\n" + image);
                //create client thumbs and add them to container
                var thumb:Thumb = new Thumb();
                thumb.imageLoader = new ImageLoader(thumb);
                thumb.x = (thumbContainer.numChildren * (thumbWidth + 10));

                thumb.imageLoader.loadImage(thumbsXML.xmlData.@albumDir + album.@dir + album.@galleryDir + album.@thumbDir + image.@url);
                thumb.addEventListener(MouseEvent.CLICK, thumbClickHandler);
                thumbContainer.addChild(thumb);
                thumb_array[thumb_array.length] = thumb;

                thumb.item = new Item({
                      image:thumbsXML.xmlData.@albumDir + album.@dir + album.@galleryDir + album.@largeDir + image.@url,
                      sized:thumbsXML.xmlData.@albumDir + album.@dir + album.@galleryDir + album.@sizedDir + image.@url,
                      thumb:thumbsXML.xmlData.@albumDir + album.@dir + album.@galleryDir + album.@thumbDir + image.@url, 
                      description:image.text()
                      });


            }
        }

        leftArrow.addEventListener(MouseEvent.CLICK, moveLeft);
        rightArrow.addEventListener(MouseEvent.CLICK, moveRight);

        showThumbContents();
    }
    catch(e:Error)
    { 
        trace(":: Error parsing XML.");
        trace("Caught: " + e.getStackTrace());
    }
}





function thumbClickHandler(e:MouseEvent):void {
    var thumb:Thumb = e.target as Thumb;
    currentThumb = thumbContainer.getChildIndex(thumb);
    showThumbContents();
}

function showThumbContents():void {
    var thumb:Thumb = thumbContainer.getChildAt(currentThumb) as Thumb;
    clearContainer(pictureContainer);
    try
    {
        pictureLoader = new Loader();

        pictureLoader.load(new URLRequest(thumb.item.sized));
        pictureLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, IOErrorHandler);
        pictureLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, onProgressHandler);
        pictureLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, pictureCompleteHandler);


        pictureContainer.addChild(pictureLoader);
    }
    catch(e:TypeError){
        trace("Error showing thumb contents.\n\t" + e.getStackTrace());
    }
}


function gotoLargePicture(e:MouseEvent = null):void {
    trace("GOTO LARGE PICTURE");
    var thumb:Thumb = thumbContainer.getChildAt(currentThumb) as Thumb; 
    navigateToURL(new URLRequest(thumb.item.image), "_blank");
}

function IOErrorHandler(e:IOErrorEvent):void {
    trace("IOErrorEvent!:" + e);
}

function onProgressHandler(e:ProgressEvent):void {
    trace("ProgressEvent: " + e);
    loading_mc.visible = true;
}

function pictureCompleteHandler(e:Event):void {
    //trace("Complete! " + e);
    //pictureContainer.x = 275 - (pictureContainer.width / 2)
    loading_mc.visible = false; 
}

function adjustThumbs():void {
    var temp:int = 0;
    while(temp <= currentThumb - numThumbsShown)
        temp += numThumbsShown;
    leftMostThumb = temp;

    slideThumbs();
}

function moveLeft(e:MouseEvent):void {
    if(leftMostThumb > 0)
        leftMostThumb -= numThumbsShown;
    slideThumbs();
}

function moveRight(e:MouseEvent):void {
    if(leftMostThumb = thumbContainer.numChildren)
        currentThumb = 0;
    //showDescription();
    showThumbContents();
}

function clearContainer(container:DisplayObjectContainer):void {
    while(container.numChildren > 0)
        container.removeChildAt(0);
}

function thumbCompleteHandler(e:Event){ 
    trace("thumbsXML loaded. ");
    thumbsXML.removeEventListener(Event.COMPLETE, thumbCompleteHandler);
}









//_browseBtn = browseBT;// new SimpleButton ( ) ;
//_browseBtn.useHandCursor = true;
browseBT.addEventListener ( MouseEvent.CLICK, _handleMouseEvent ) ;
//_fileFilter = new FileFilter ( "Image", "*.jpg;*.gif;*.png;" ) ;      


        function _handleMouseEvent ( evt : MouseEvent ) : void
        {

            //_fileRef = new FileReference ( ) ;
            //_fileRef.browse ( [_fileFilter] ) ;
            //_fileRef.addEventListener ( Event.SELECT, _onImageSelect ) ;

            blackmask.blackmastin.gotoAndPlay(2);

        }

Now i have another project that i want to put this code but this project loads the actionscript code from an external .as file.

现在我有另一个项目,我想放置此代码,但此项目从外部.as文件加载actionscript代码。

The Code is:

守则是:

package 
{
    import flash.display.Sprite;
    import fl.motion.AdjustColor;
    import flash.filters.ColorMatrixFilter;
    import fl.events.SliderEvent;
    import com.flashcube.Transformer;
    import flash.events.MouseEvent;


    public class Main extends Sprite
    {
        private var color:AdjustColor = new AdjustColor();
        private var filter:ColorMatrixFilter;
        private var faceTransform:Transformer;

        public function Main():void
        {
            /* Required to create initial Matrix */

            color.brightness = 0;
            color.cOntrast= 0;
            color.hue = 0;
            color.saturation = 0;

             var newZIndex = 10;

            /* Add Listeners function */

            addListeners();
            addListeners2();
            addListeners22();

        }

        private final function addListeners():void
        {
            faceTransform                       = new Transformer(image2);
            faceTransform.color                 = 0x000FFF;
            faceTransform.showCenterCircle      = true;
            faceTransform.selectedColor         = 0x000000;
            faceTransform.selectedAlpha         = 0.5;
            faceTransform.allowScaleProportion  = true;
            faceTransform.allowRotateProportion = false;

            colorPanel.brightSL.addEventListener(SliderEvent.CHANGE, adjustBrightness);
            colorPanel.contSL.addEventListener(SliderEvent.CHANGE, adjustContrast);
            colorPanel.hueSL.addEventListener(SliderEvent.CHANGE, adjustHue);
            colorPanel.satSL.addEventListener(SliderEvent.CHANGE, adjustSaturation);


        }

        private final function adjustBrightness(e:SliderEvent):void
        {
            color.brightness = e.target.value;
            update();
        }

        private final function adjustContrast(e:SliderEvent):void
        {
            color.cOntrast= e.target.value;
            update();
        }

        private final function adjustHue(e:SliderEvent):void
        {
            color.hue = e.target.value;
            update();
        }

        private final function adjustSaturation(e:SliderEvent):void
        {
            color.saturation = e.target.value;
            update();
        }

        private final function update():void
        {
            filter = new ColorMatrixFilter(color.CalculateFinalFlatArray());
            image.filters = [filter];
        }







        private final function addListeners2():void
        {
            colorPanel2.brightSL.addEventListener(SliderEvent.CHANGE, adjustBrightness2);
            colorPanel2.contSL.addEventListener(SliderEvent.CHANGE, adjustContrast2);
            colorPanel2.hueSL.addEventListener(SliderEvent.CHANGE, adjustHue2);
            colorPanel2.satSL.addEventListener(SliderEvent.CHANGE, adjustSaturation2);
        }

        private final function adjustBrightness2(e:SliderEvent):void
        {
            color.brightness = e.target.value;
            update2();
        }

        private final function adjustContrast2(e:SliderEvent):void
        {
            color.cOntrast= e.target.value;
            update2();
        }

        private final function adjustHue2(e:SliderEvent):void
        {
            color.hue = e.target.value;
            update2();
        }

        private final function adjustSaturation2(e:SliderEvent):void
        {
            color.saturation = e.target.value;
            update2();
        }

        private final function update2():void
        {
            filter = new ColorMatrixFilter(color.CalculateFinalFlatArray());
            image2.filters = [filter];
        }


    //-------------------------------------------------

private final function addListeners22():void
        {
image.addEventListener(MouseEvent.CLICK, friendMaker);
        }

private final function friendMaker(evt:MouseEvent):void {
 //setChildIndex(image2,stage.numChildren-1);
   setChildIndex(image,numChildren+1);
}





    }

}

Please is it possible someone to help me to mix the first code int second .as file?

请问有人可以帮我混合第二个.as文件中的第一个代码吗?

I am attaching a download link with all source files.

我附上了所有源文件的下载链接。

In the file AdgustColor in frame on there is the actionscript code that i want to transfare to Main.as File.

在框架中的AdgustColor文件中有动作脚本代码我要转发到Main.as文件。

In the filescroller.fla there is the original Scroller.

在filescroller.fla中有原始的Scroller。

Ofcourse the AdgustColor.fla doesnt work until i remove the actionscript code from the timeline Frame 1.

当然,在我从时间轴第1帧中删除动作脚本代码之前,AdgustColor.fla不起作用。

DOWNLOAD: myfiles

2 个解决方案

#1


1  

I'm going to be honest with you here. You should start small and read some tutorials on how classes work before you attempt something like this. Although the migration is very easy, when it comes time to revise your code in any way, you will run into issues.

我在这里要对你说实话。在尝试这样的事情之前,你应该从小做起并阅读关于类如何工作的一些教程。虽然迁移非常简单,但是当需要以任何方式修改代码时,您将遇到问题。

#2


0  

"Mixing" code especially from a class file isn't a very good idea if you don't know what you are doing. I don't think anyone here will be able to answer this question the way you want it answered, which appears to be "Just do it for me". Maybe if you provide what the end result will be someone might just do it for you. There's a lot of code there however so still I doubt you will get a perfect answer. I think the best answer you are going to get is to dig into the code and learn how it functions. In the end you will get a better result because you will know everything about the code and you will have learned something from it that you can apply to other problems. Hope that helps!

如果您不知道自己在做什么,那么“混合”代码尤其是来自类文件的代码并不是一个好主意。我认为这里的任何人都不会以你希望它回答的方式回答这个问题,这似乎就是“为我做这件事”。也许如果你提供最终结果将是某人可能会为你做的。那里有很多代码但是我仍然怀疑你会得到一个完美的答案。我认为您将获得的最佳答案是深入研究代码并了解其功能。最后,您将获得更好的结果,因为您将了解有关代码的所有内容,并且您将从中学到一些可以应用于其他问题的内容。希望有所帮助!


推荐阅读
  • 本文主要解析了Open judge C16H问题中涉及到的Magical Balls的快速幂和逆元算法,并给出了问题的解析和解决方法。详细介绍了问题的背景和规则,并给出了相应的算法解析和实现步骤。通过本文的解析,读者可以更好地理解和解决Open judge C16H问题中的Magical Balls部分。 ... [详细]
  • 本文介绍了作者在开发过程中遇到的问题,即播放框架内容安全策略设置不起作用的错误。作者通过使用编译时依赖注入的方式解决了这个问题,并分享了解决方案。文章详细描述了问题的出现情况、错误输出内容以及解决方案的具体步骤。如果你也遇到了类似的问题,本文可能对你有一定的参考价值。 ... [详细]
  • 在重复造轮子的情况下用ProxyServlet反向代理来减少工作量
    像不少公司内部不同团队都会自己研发自己工具产品,当各个产品逐渐成熟,到达了一定的发展瓶颈,同时每个产品都有着自己的入口,用户 ... [详细]
  • 也就是|小窗_卷积的特征提取与参数计算
    篇首语:本文由编程笔记#小编为大家整理,主要介绍了卷积的特征提取与参数计算相关的知识,希望对你有一定的参考价值。Dense和Conv2D根本区别在于,Den ... [详细]
  • FeatureRequestIsyourfeaturerequestrelatedtoaproblem?Please ... [详细]
  • Android开发实现的计时器功能示例
    本文分享了Android开发实现的计时器功能示例,包括效果图、布局和按钮的使用。通过使用Chronometer控件,可以实现计时器功能。该示例适用于Android平台,供开发者参考。 ... [详细]
  • Go GUIlxn/walk 学习3.菜单栏和工具栏的具体实现
    本文介绍了使用Go语言的GUI库lxn/walk实现菜单栏和工具栏的具体方法,包括消息窗口的产生、文件放置动作响应和提示框的应用。部分代码来自上一篇博客和lxn/walk官方示例。文章提供了学习GUI开发的实际案例和代码示例。 ... [详细]
  • Webpack5内置处理图片资源的配置方法
    本文介绍了在Webpack5中处理图片资源的配置方法。在Webpack4中,我们需要使用file-loader和url-loader来处理图片资源,但是在Webpack5中,这两个Loader的功能已经被内置到Webpack中,我们只需要简单配置即可实现图片资源的处理。本文还介绍了一些常用的配置方法,如匹配不同类型的图片文件、设置输出路径等。通过本文的学习,读者可以快速掌握Webpack5处理图片资源的方法。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • 本文介绍了Perl的测试框架Test::Base,它是一个数据驱动的测试框架,可以自动进行单元测试,省去手工编写测试程序的麻烦。与Test::More完全兼容,使用方法简单。以plural函数为例,展示了Test::Base的使用方法。 ... [详细]
  • sklearn数据集库中的常用数据集类型介绍
    本文介绍了sklearn数据集库中常用的数据集类型,包括玩具数据集和样本生成器。其中详细介绍了波士顿房价数据集,包含了波士顿506处房屋的13种不同特征以及房屋价格,适用于回归任务。 ... [详细]
  • switch语句的一些用法及注意事项
    本文介绍了使用switch语句时的一些用法和注意事项,包括如何实现"fall through"、default语句的作用、在case语句中定义变量时可能出现的问题以及解决方法。同时也提到了C#严格控制switch分支不允许贯穿的规定。通过本文的介绍,读者可以更好地理解和使用switch语句。 ... [详细]
  • 预备知识可参考我整理的博客Windows编程之线程:https:www.cnblogs.comZhuSenlinp16662075.htmlWindows编程之线程同步:https ... [详细]
  • iOS Swift中如何实现自动登录?
    本文介绍了在iOS Swift中如何实现自动登录的方法,包括使用故事板、SWRevealViewController等技术,以及解决用户注销后重新登录自动跳转到主页的问题。 ... [详细]
  • IOS开发之短信发送与拨打电话的方法详解
    本文详细介绍了在IOS开发中实现短信发送和拨打电话的两种方式,一种是使用系统底层发送,虽然无法自定义短信内容和返回原应用,但是简单方便;另一种是使用第三方框架发送,需要导入MessageUI头文件,并遵守MFMessageComposeViewControllerDelegate协议,可以实现自定义短信内容和返回原应用的功能。 ... [详细]
author-avatar
前方体育538
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有