Hi All,
I’m fairly new to Flash and very new to Actionscript 3… I have a Rotating Flash banner on my homepage that slides in 4 different external images using LOADER
However - the LOADER always seems to load the image above other movieclips that I want it to go under
I’ve tried loading the image into movieclips that are in a layer below the thing that I want to be on top
but the image always ends up above everything else… grrrr
probably me being stupid - any help would be gratefully received.
Thanks
Here’s the code…
mover_mc is where I am loading the external image - mover_mc is currently on the main timeline - I’ve tried sticking it elsewhere but still can’t get it to work
package {
import flash.display.*;
import flash.events.*;
import flash.ui.Keyboard;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.net.navigateToURL;
import flash.utils.Timer;
import flash.utils.getTimer;
import flash.events.TimerEvent;
public class ContentClick extends MovieClip {
private var moveContent:MovieClip;
private var b1:MovieClip;
private var b2:MovieClip;
private var b3:MovieClip;
private var b4:MovieClip;
private var newX:Number = 0;
private var Xspeed:Number = 0;
private var movedIn:Boolean = true;
private var externalXML:XML;
private var loader:URLLoader = new URLLoader();
private var request:URLRequest = new URLRequest("ind.xml");
private var myLoader:Loader = new Loader();
private var timer:Timer;
private var timer2:Timer;
private var timer3:Timer;
private var timer4:Timer;
private var Pos:Number = 1;
public function ContentClick() {
init();
}
private function init():void {
moveContent = mover_mc;
addChild(moveContent);
b1 = ind_btn;
b2 = corp_btn;
b3 = int_btn;
b4 = gen_btn;
//
moveContent.addEventListener(Event.ENTER_FRAME, moveX);
b1.addEventListener(MouseEvent.CLICK, clickOne);
b2.addEventListener(MouseEvent.CLICK, clickTwo);
b3.addEventListener(MouseEvent.CLICK, clickThree);
b4.addEventListener(MouseEvent.CLICK, clickFour);
loader.addEventListener(Event.COMPLETE, onComplete);
mover_mc.addEventListener(MouseEvent.CLICK, clickListener);
timer = new Timer(5000, 1)
timer2 = new Timer(5000, 1)
timer3 = new Timer(5000, 1)
timer4 = new Timer(5000, 1)
timer.addEventListener(TimerEvent.TIMER, timeListener);
timer2.addEventListener(TimerEvent.TIMER, timeListener2);
timer3.addEventListener(TimerEvent.TIMER, timeListener3);
timer4.addEventListener(TimerEvent.TIMER, timeListener4);
timer.start();
loader.load(request);
mover_mc.image_mc.addChild(myLoader);
ind_btn.buttonMode = true;
ind_btn.gotoAndStop("_down");
}
//
public function moveX(event:Event):void {
Xspeed = ((mover_mc.x-newX)/2+Xspeed)/5;
mover_mc.x -= Xspeed;
if (mover_mc.x<-450) {
mover_mc.x=600;
newX=0;
}
}
//
public function checkPos() {
if (movedIn==false) {
newX=0;
movedIn=true;
} else {
newX=-1100;
}
}
function clickOne(Event:MouseEvent):void {
request = new URLRequest("ind.xml");
loader.load(request);
corp_btn.buttonMode = true;
corp_btn.gotoAndStop("_up");
int_btn.buttonMode = true;
int_btn.gotoAndStop("_up");
gen_btn.buttonMode = true;
gen_btn.gotoAndStop("_up");
ind_btn.buttonMode = false;
ind_btn.gotoAndStop("_down");
timer.stop();
timer2.stop();
timer3.stop();
timer4.stop();
checkPos();
}
//
function clickTwo(Event:MouseEvent):void {
request = new URLRequest("corp.xml");
loader.load(request);
ind_btn.buttonMode = true;
ind_btn.gotoAndStop("_up");
int_btn.buttonMode = true;
int_btn.gotoAndStop("_up");
gen_btn.buttonMode = true;
gen_btn.gotoAndStop("_up");
corp_btn.buttonMode = false;
corp_btn.gotoAndStop("_down");
timer.stop();
timer2.stop();
timer3.stop();
timer4.stop();
checkPos();
}
function clickThree(Event:MouseEvent):void {
request = new URLRequest("int.xml");
loader.load(request);
ind_btn.buttonMode = true;
ind_btn.gotoAndStop("_up");
corp_btn.buttonMode = true;
corp_btn.gotoAndStop("_up");
gen_btn.buttonMode = true;
gen_btn.gotoAndStop("_up");
int_btn.buttonMode = false;
int_btn.gotoAndStop("_down");
timer.stop();
timer2.stop();
timer3.stop();
timer4.stop();
checkPos();
}
function clickFour(Event:MouseEvent):void {
var navURL:URLRequest = new URLRequest("GP-Telephone-helpline/index.asp?source=home-aboutBtn");
navigateToURL(navURL, "_top");
}
function clickListener(Event:MouseEvent):void {
var navURL:URLRequest = new URLRequest(externalXML.dialogue[0].link);
navigateToURL(navURL, "_top");
}
function timeListener (e:TimerEvent):void {
if (Pos == 1) {
request = new URLRequest("corp.xml");
loader.load(request);
ind_btn.buttonMode = true;
ind_btn.gotoAndStop("_up");
int_btn.buttonMode = true;
int_btn.gotoAndStop("_up");
gen_btn.buttonMode = true;
gen_btn.gotoAndStop("_up");
corp_btn.buttonMode = false;
corp_btn.gotoAndStop("_down");
Pos = 2;
timer2.start();
checkPos();
}
}
function timeListener2 (e:TimerEvent):void {
if (Pos == 2) {
request = new URLRequest("int.xml");
loader.load(request);
ind_btn.buttonMode = true;
ind_btn.gotoAndStop("_up");
corp_btn.buttonMode = true;
corp_btn.gotoAndStop("_up");
gen_btn.buttonMode = true;
gen_btn.gotoAndStop("_up");
int_btn.buttonMode = false;
int_btn.gotoAndStop("_down");
Pos = 3;
timer3.start();
checkPos();
}
}
function timeListener3 (e:TimerEvent):void {
if (Pos == 3) {
request = new URLRequest("gen.xml");
loader.load(request);
ind_btn.buttonMode = true;
ind_btn.gotoAndStop("_up");
corp_btn.buttonMode = true;
corp_btn.gotoAndStop("_up");
int_btn.buttonMode = true;
int_btn.gotoAndStop("_up");
gen_btn.buttonMode = false;
gen_btn.gotoAndStop("_down");
Pos = 4;
timer4.start();
checkPos();
}
}
function timeListener4 (e:TimerEvent):void {
if (Pos == 4) {
request = new URLRequest("ind.xml");
loader.load(request);
ind_btn.buttonMode = false;
ind_btn.gotoAndStop("_down");
corp_btn.buttonMode = true;
corp_btn.gotoAndStop("_up");
int_btn.buttonMode = true;
int_btn.gotoAndStop("_up");
gen_btn.buttonMode = true;
gen_btn.gotoAndStop("_up");
Pos = 5;
checkPos();
}
}
//
public function onComplete(event:Event):void {
var loader:URLLoader = event.target as URLLoader;
if (loader != null) {
externalXML = new XML(loader.data);
mover_mc.heading_txt.htmlText = externalXML.dialogue[0].heading;
mover_mc.myText_txt.htmlText = externalXML.dialogue[0].text;
mover_mc.link_txt.htmlText = externalXML.dialogue[0].linktext;
var url:URLRequest = new URLRequest(externalXML.dialogue[0].img);
myLoader.load(url);
} else {
trace("loader is not a URLLoader!");
}
}
}
}