我想用“alpha”效果,但是当我使用特定的类在我的文本上设置滚动条时,文本不响应我的alpha。 您将看到文本不响应补间开头的alpha 0。
我正在使用我在互联网上找到的一个好的滚动条类,但我无法解释为什么会发生这种情况。
这是我在fla中导入另一个类的代码,它导入滚动条类;-):
import com.greensock.*;
import com.greensock.easing.*;
var loader:Loader = new Loader;
var url:URLRequest = new URLRequest("Rhizo.swf");
loader.load(url);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, ec);
function ec (e:Event){
var a = e.target.content;
a.alpha = 0;
addChild(e.target.content);
TweenLite.to(a, 3, { x:30, alpha:1});
}
文档类,与包含上面代码的fla链接,我调用滚动条类:
public class ScrollBarAS3 extends MovieClip {
public var my_scrollbar:MakeScrollBar;
public function ScrollBarAS3() {
my_scrollbar = new MakeScrollBar( scroll_mc, scroll_text );
scroll_txt.selectable = true;
}
public function scroll_text( n:Number ) {
scroll_txt.scrollV = Math.round( ( scroll_txt.maxScrollV - 1 ) * n ) + 1;
}
这是滚动条类:
package {
import flash.display.Stage;
import flash.display.MovieClip;
import flash.events.*;
import flash.geom.Rectangle;
public class MakeScrollBar extends MovieClip {
private var host_mc:MovieClip;
private var call_back:Function;
private var drag_mc:MovieClip;
private var track_mc:MovieClip;
private var scroll_rect:Rectangle;
private var upper_limit:Number;
private var range:Number;
public function MakeScrollBar( _mc:MovieClip, cb:Function ) {
host_mc = _mc;
call_back = cb;
drag_mc = host_mc.drag_mc; //
drag_mc.buttonMode = true;
drag_mc.mouseChildren = false
drag_mc.addEventListener( MouseEvent.MOUSE_DOWN, press_drag );
track_mc = host_mc.track_mc;
track_mc.buttonMode = true;
track_mc.mouseChildren = false
track_mc.addEventListener( MouseEvent.CLICK, click_track );
set_limits();
}
private function press_drag( event:MouseEvent ):void {
/***************************************************/
drag_mc.stage.addEventListener( MouseEvent.MOUSE_UP, release_drag, false, 0, true );
/***************************************************/
drag_mc.startDrag( false, scroll_rect );
drag_mc.addEventListener( Event.ENTER_FRAME, drag );
}
private function release_drag( event:MouseEvent ):void {
drag_mc.removeEventListener( Event.ENTER_FRAME, drag );
drag_mc.stage.removeEventListener( MouseEvent.MOUSE_UP, release_drag );
drag_mc.stopDrag();
}
private function click_track( event:MouseEvent ):void {
}
private function set_limits():void {
scroll_rect = new Rectangle( track_mc.x, track_mc.y, 0, track_mc.height - drag_mc.height );
upper_limit = track_mc.y;
range = track_mc.height - drag_mc.height;
}
private function drag( event:Event ):void {
var p = ( drag_mc.y - track_mc.y ) / range;
call_back( p );
}
}
}
你知道我能做些什么来让alpha工作吗?
非常感谢
干杯
答案 0 :(得分:2)
从AS3的角度来看,除非将其embedFonts属性设置为true,否则您将无法将透明度应用于TextField。我建议问题是加载的SWF,但你没有为它提供任何代码...
// -----------------------编辑--------------------- //
如果您只是这样做会怎么样?文字出现了吗?
function ec (e:Event){ var a = e.target.content; a.alpha = 0; addChild(e.target.content); }
您是否在本地测试.swf?
您是否尝试过简单地加载电影,没有ScrollBar并设法使alpha工作?
目前,我没有在ScrollBar类中看到任何可能干扰文本透明度的内容......