I have the following package
package{
?import flash.display.MovieClip;
?import flash.utils.Timer;
?import flash.events.TimerEvent;
?import flash.text.*;
?import flash.display.Loader;
?import flash.net.*;
?
?public class rotatorButton extends MovieClip{
?private var timer:Timer;
?private var buttonNum:int;
?private var lapse:int;
?private var ticks:int;
?
?public function rotatorButton(num:int,newLapse:int,newX:int,newY:int){
?buttonNum = num;
?lapse = newLapse;
?width = 50;
?var t:TextField = new TextField();
?/* textFormat code
?x = newX;
?y = newY;
?addChild(t);
?timer = new Timer((lapse/40),0);
?timer.addEventListener(TimerEvent.TIMER,fillBackground);
?}
?
?public function getButtonNum()
?{
?return buttonNum;
?}
?
?public function loadItem():void{
?timer.start();
?ticks = 0;
?}
?
?private function fillBackground(e:TimerEvent):void{
?ticks += 1;
?if(ticks %26lt;= 20)
?{
?var loadit = new Loader;
?addChild(loadit);
?loadit.load(new URLRequest(''button'' + ticks + ''.png''));
?}
?}
?}
?
}
Not sure how clear that is but what I'm trying to do is this ....
1. The class instantiates and adds a number as text on top of the image that I created the MovieClip class from
2. As the main class of the fla rotates images it calls the loadItem() function of each cooresponding button.
3. That function starts the timer and, on each tick of the timer, the background image changes.
What is happening right now with this code is that the new image (that I want to be the background image behind the text) is coming in on top of the text.
Is there a way to simply replace the image currently loaded into the MovieClip.
Thanks in advance.
Changing background image of a...If the intention is to have nothing in the fla file, such a s a blank movieclip that you could load the images into, which would keep them where you want them, then you probably need to keep adjusting the index of the textfield after you add each loader to the display.?To do that you probably need to pull the declkaration of the textfield out of the function so that it can be manipulated elsewhere.?Then you could simply use addChild(t); following each time you addChild(loadit); to have the text resume its top position
Changing background image of a...If you want the image in the background then you need to load it into a background. Just using ''addChild()'' will add it to the top of the display list. So create an empty movieclip at the start of the class (before you make the textfield), ie:
var background:MovieClip = new MovieClip();
Then just load images into this clip.
background.addChild(loadit);
No comments:
Post a Comment