在闪光灯CS4中的滚动条
我正试图将垂直滚动条放到Flash CS4中的动态TextField上。 当我在场景1中做到这一点时,一切正常。 但是,如果我将TextField +滚动条移动到场景2,它会中断。 我运行代码时得到的错误表明Flash正在加载滚动条,然后尝试查找关联的TextField。 问题在于,由于TextField在进入场景2之前不会加载,所以Flash会引发错误。
我尝试了很多东西来解决这个问题。 最主要的是我需要在actionscript(而不是组件库)中创建TextField和Scrollbar,以便可以控制每个创建时间。 要创建TextField,我输入:
//create a textfield for the story
import flash.text.TextField;
var story_txt:TextField = new TextField();
//story_txt.multiline = true;
story_txt.x = 154;
story_txt.y = 233.5;
story_txt.width = 348;
story_txt.height = 104.5;
story_txt.border = true;
story_txt.type = "dynamic";
story_txt.backgroundColor = 0xffffff;
story_txt.background = true;
story_txt.wordWrap = true;
story_txt.multiline = true;
并创建滚动条,然后我输入:
import fl.controls.UIScrollBar;
//add the story_txt to the stage
addChild(story_txt);
var mySb:UIScrollBar = new UIScrollBar();
mySb.direction = "vertical";
// Size it to match the text field.
mySb.setSize(story_txt.width, story_txt.height);
// Move it immediately to the right of the text field.
mySb.move(story_txt.x, story_txt.height + story_txt.y);
// put them on the Stage
mySb.scrollTarget = story_txt;
//mySb.scrollTargetName = "story_txt";
stage.addChild(mySb);
唯一的问题是,这个代码只有当我将ScrollBar水平并关闭wordwrap时才起作用。 出于某种原因,垂直滚动条将无法使用wordrap(和w / o wordwrap,Flash认为不需要垂直滚动条,因为它只能看到单行文本。
获得带有滚动条的文本框应该是一个简单的过程,但这实际上是无法实现的。 关于如何在WordWrap打开时让ScrollBar工作的任何想法?
基本上你不应该在Flash中使用场景。 他们有很多已知的问题。
这个线程可能有帮助。
场景使用通常是不好的做法。 它们是保留当前版本的闪存与早期版本兼容的遗留功能。 如果您必须使用IDE将事物放置在舞台上,则应在主时间轴上使用不同的帧来代替场景,并将需要时间线的事物放置在自己的动画片段内进行动画制作。 闪存IDE实际上将编译时的所有场景缩减为一个时间线,但有许多异常情况不会出现在手动时间线操作中。
来自Adobe的场景的缺点:http://help.adobe.com/zh_CN/Flash/10.0_UsingFlash/WSd60f23110762d6b883b18f10cb1fe1af6-7eb3a.html
链接地址: http://www.djcxy.com/p/17843.html