本文介绍了我怎么能编译$ C $下此Flash教程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始阅读本教程:http://active.tutsplus.com/tutorials/actionscript/creating-a-reusable-flash-uploader-with-actionscript-3-0-and-php/

我使用的是FlashDevelop,我贴了满code到ActionScript文件。我收到的错误是这样的:

I'm using FlashDevelop, and I pasted the full code into an ActionScript file. The errors I'm receiving are like this:

C:\Users\tempus\Documents\uploaderas\Uploader.as(30): col: 4 Error: Access of undefined property select_btn.
select_btn.addEventListener( MouseEvent.CLICK, browse );
^
C:\Users\tempus\Documents\uploaderas\Uploader.as(31): col: 4 Error: Access of undefined property progress_mc.
progress_mc.bar.scaleX = 0;

...

我的理解是错误的出现是由于对象没有被宣布为(他们似乎是从什么地方实例化),但我不知道如何/我应包括申报。你可以点我朝着一个解决方案吗?

I understand that the errors appear because the objects have not been declared ( and they appear to be instantiated from somewhere ), but I don't understand how/what should I include to declare them. Could you point me towards a solution?

推荐答案

这是因为按钮都在Flash IDE中创建(如本教程是为了使用Flash IDE编译)。由于按钮在code方面是不存在的,你得到这个错误。

It's because the buttons are created in the Flash IDE (as the tutorial was meant to be compiled using the Flash IDE). Since the buttons don't exist in the code aspect you get that error.

您可以创建自己通过code中的元素,或者使用Flash IDE和出口留点UI元素的SWC / SWF,包括在你的FlashDevelop项目。我假设你想要做的是后者 -

You can either create the elements yourself via code, or use the Flash IDE and export a swc/swf of the neccessary UI elements and include that in your flashDevelop project. I'm assuming you'll want to do the latter -

在Flash IDE中,打开.fla文件,打开库面板,找到进步的资产,右键单击它并打开属性。选中为ActionScript导出选项,然后在类字段给它像SelectBtn唯一的名称。用同样的方法在进步的资产(只喜欢进度条不同的类名)。转至Flash发布设置,以及闪光灯选项卡上选择导出SWC。发布文件并放置在您的Flash开发项目文件夹(你的项目的传统lib文件夹)公布的深港西部通道。

in the Flash IDE, open the .fla, open the library panel, find the progress asset, right click it and bring up the properties. Check the "Export For ActionScript" option, then in the 'Class' field give it a unique name like "SelectBtn". Do the same for the 'progress' asset (only a different class name like 'ProgressBar'). Go to the flash publish settings, and on the flash tab select 'export swc'. publish the file and place the published swc in your flash Develop project folder (traditionally the lib folder of your project).

在Flash开发中,右键单击您的SWC并选择添加到资料库。 (您可能需要再次右键单击并转到选项,选择包括完全选项)。现在,您可以访问在Flash中的类,你设置。然后在你的code,声明并初始化显示资产:

In Flash Develop, right click your swc and choose 'Add To Library'. (You may need to right-click again and go to options and choose the include completely option). Now you can access those classes you setup in Flash. Then in your code, declare and initialize the display assets:

public var select_btn:SelectBtn = new SelectBtn();
public var progress_mc:ProgressBar = new ProgressBar();

您还将需要做的textField的了。这将是最简单的办法来,虽然这样做在你的code。

You'll also need to do that textField too. It would be easiest just to do it in your code though.

public var label_txt:TextField = new TextField();

请记住,你需要手动定位和使用的addChild在所有三个要素这种方式。如果你想保持定位这是闪光灯,只需选择在舞台上和preSS F8所有元素,将它们转换为影片剪辑。然后,在图书馆设置联动一样的人,并给它的东西,如DisplayAssets一类的名称,然后导出一个新的深港西部通道。那么你的code是这样的:

Keep in mind you'll need to manually position and use addChild on all three elements this way. If you want to keep the positioning that's in flash, just select all the elements on the stage and press F8 to convert them to a MovieClip. Then in the library setup linkage the same as the others and give it a class name of something like "DisplayAssets" and export a new swc. Then your code would look like this:

public var select_btn:Sprite;
public var progress_mc:Sprite;

public function Uploader(){
    var displayAssets:DisplayAssets = new DisplayAssets();
    addChild(displayAssets);

    select_btn = displayAssets.select_btn;
    progress_mc = displayAssets.progress_mc;

    //the rest of the code
}

这篇关于我怎么能编译$ C $下此Flash教程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 02:14