Reputation: 6176
i'd like to make an effect with "alpha", but when i'm using a particular class to set the scrollbar on my text, the text does not respond to my alpha. You'll see that the text does not respond to the alpha 0 at the beginning of the tween.
I'm using a good scrollbar class that i found on internet, but i can't explain why this is happening.
Here's my code in the fla that imports another class, which imports the scrollbar class ;-) :
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});
}
the document class, linked with the fla that contains the code above, where i call the scroll bar class :
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;
}
and here's the scrollbar class :
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 );
}
}
}
Do you know what i could do to make the alpha work?
Thanks a lot
Cheers
Upvotes: 0
Views: 1348
Reputation: 9572
From an AS3 point of view , you will not be able to apply transparency to a TextField unless its embedFonts property is set to true. I would suggest that the problem is with the loaded SWF but you don't provide any code for it...
//----------------------- Edit ---------------------//
What happens if you simply do this? Does the text appear?
function ec (e:Event){ var a = e.target.content; a.alpha = 0; addChild(e.target.content); }
Did you test the .swf locally?
Have you tried to simply load the movie, without the ScrollBar and managed to get the alpha working?
At the moment, I don't see anything in the ScrollBar class that could interfere with the text transparency...
Upvotes: 2