我使用flash swf文件創建了一個組合,並將它們加載到外部!加載另一個外部swf時,從「播放」中停止外部加載的swf(AS 3)
我有一個主頁,每個swf有五個「鏈接」。現在第一個swf我有一個隱藏鼠標的自定義光標。當我點擊該鏈接時,它會播放,當我再次快速轉到主頁時,它會在不應該這樣做時將鼠標隱藏起來。
與所有其他鏈接相同。當我忙於第一個swf並想要去五個人的最後一個swf時,我的鼠標就消失了!它幾乎就像繼續「玩」沒有看到瑞士銀行...
這是相當難以解釋,所以我希望你明白我的意思!
這是我到目前爲止的代碼!
var currentpage:uint = 0;
//one loader object per project:
var loadingobject1:Loader = new Loader();
loadingobject1.x = 445;
loadingobject1.y = 160;
var loadingobject2:Loader = new Loader();
loadingobject2.x = 488;
loadingobject2.y = 180;
var loadingobject3:Loader = new Loader();
loadingobject3.x = 510;
loadingobject3.y = 223;
var loadingobject4:Loader = new Loader();
loadingobject4.x = 510;
loadingobject4.y = 223;
var loadingobject5:Loader = new Loader();
loadingobject5.x = 455;
loadingobject5.y = 175;
button_home.buttonMode = true;
button_home.addEventListener(MouseEvent.CLICK, pageswitch0);
button_project1.buttonMode = true;
button_project1.addEventListener(MouseEvent.CLICK, pageswitch1);
button_project2.buttonMode = true;
button_project2.addEventListener(MouseEvent.CLICK, pageswitch2);
button_project3.buttonMode = true;
button_project3.addEventListener(MouseEvent.CLICK, pageswitch3);
button_project4.buttonMode = true;
button_project4.addEventListener(MouseEvent.CLICK, pageswitch4);
button_project5.buttonMode = true;
button_project5.addEventListener(MouseEvent.CLICK, pageswitch5);
button_home.visible = false;
BG.visible = false;
sound_control_home.visible = true;
Mouse.show();
//HEADERS//
T1.visible = false;
T2.visible = false;
T3.visible = false;
T4.visible = false;
T5.visible = false;
SoundMixer.stopAll();
//////////////////////////////////////////////////////
////////////////////// Sound ///////////////////////
//////////////////////////////////////////////////////
var default_volume_home:Number = 0.85; // 0.00 to 1.00
var background_music:Sound = new homepage_music();
var music_channel_home:SoundChannel = background_music.play(0, 10000);
var music_volume_home:SoundTransform = new SoundTransform();
music_volume_home.volume = default_volume_home;
music_channel_home.soundTransform = music_volume_home;
sound_control_home.stop();
sound_control_home.addEventListener(MouseEvent.CLICK, play_pause_home);
function play_pause_home(e:MouseEvent):void
{
music_volume_home.volume = default_volume_home;
if(e.target.currentFrame == 1)
music_volume_home.volume = 0;
music_channel_home.soundTransform = music_volume_home;
e.target.play();
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// PAGESWITCH 0 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Homepage ///////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function pageswitch0(m:MouseEvent)
{
if (currentpage != 0)//making sure the page isn't already selected
{
//testing which page is currently visible and unloading it (note in the other functions that if it's the home page the visibility is just set to false):
if (currentpage == 1)
{
loadingobject1.unload();
}
else if (currentpage == 2)
{
loadingobject2.unload();
}
else if (currentpage == 3)
{
loadingobject3.unload();
}
else if (currentpage == 4)
{
loadingobject4.unload();
}
else if (currentpage == 5)
{
loadingobject5.unload();
}
homepage.visible = true;//making the home page visible
SoundMixer.stopAll();
Mouse.show();
var default_volume_home:Number = 0.7;
var background_music:Sound = new homepage_music();
var music_channel_home:SoundChannel = background_music.play(0, 10000);
var music_volume_home:SoundTransform = new SoundTransform();
music_volume_home.volume = default_volume_home;
music_channel_home.soundTransform = music_volume_home;
sound_control_home.stop();
sound_control_home.addEventListener(MouseEvent.CLICK, play_pause_home);
function play_pause_home(e:MouseEvent):void
{
music_volume_home.volume = default_volume_home;
if(e.target.currentFrame == 1)
music_volume_home.volume = 0;
music_channel_home.soundTransform = music_volume_home;
e.target.play();
}
currentpage = 0;//setting the currentpage variable to the correct value
button_home.visible = false;
BG.visible = false;
sound_control_home.visible = true;
//HEADERS
T1.visible = false;
T2.visible = false;
T3.visible = false;
T4.visible = false;
T5.visible = false;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Theme 1 /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// PAGESWITCH 1 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function pageswitch1(m:MouseEvent)
{
Mouse.show();
if (currentpage != 1)
{
if (currentpage == 0)
{
homepage.visible = false;
}
else if (currentpage == 2)
{
loadingobject2.unload();
}
else if (currentpage == 3)
{
loadingobject3.unload();
}
else if (currentpage == 4)
{
loadingobject4.unload();
}
else if (currentpage == 5)
{
loadingobject5.unload();
}
//loading an external file
var whattoload:URLRequest = new URLRequest("start.swf");
loadingobject1.load(whattoload);
addChild(loadingobject1);
currentpage = 1;
button_home.visible = true;
BG.visible = true;
sound_control_home.visible = false;
SoundMixer.stopAll();
Mouse.show();
//HEADERS
T1.visible = true;
T2.visible = false;
T3.visible = false;
T4.visible = false;
T5.visible = false;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Theme 2 /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// PAGESWITCH 2 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function pageswitch2(m:MouseEvent)
{
Mouse.show();
if (currentpage != 2)
{
if (currentpage == 0)
{
homepage.visible = false;
}
else if (currentpage == 1)
{
loadingobject1.unload();
}
else if (currentpage == 3)
{
loadingobject3.unload();
}
else if (currentpage == 4)
{
loadingobject4.unload();
}
else if (currentpage == 5)
{
loadingobject5.unload();
}
var whattoload:URLRequest = new URLRequest("Theme_2.swf");
loadingobject2.load(whattoload);
addChild(loadingobject2);
loadingobject2.scaleX = 0.99;
loadingobject2.scaleY = 0.99;
currentpage = 2;
button_home.visible = true;
BG.visible = true;
sound_control_home.visible = false;
SoundMixer.stopAll();
//HEADERS
T1.visible = false;
T2.visible = true;
T3.visible = false;
T4.visible = false;
T5.visible = false;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Theme 3 /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// PAGESWITCH 3 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function pageswitch3(m:MouseEvent)
{
Mouse.show();
if (currentpage != 3)
{
if (currentpage == 0)
{
homepage.visible = false;
}
else if (currentpage == 1)
{
loadingobject1.unload();
}
else if (currentpage == 2)
{
loadingobject2.unload();
}
else if (currentpage == 4)
{
loadingobject4.unload();
}
else if (currentpage == 5)
{
loadingobject5.unload();
}
var whattoload:URLRequest = new URLRequest("Theme_3.swf");
loadingobject3.load(whattoload);
addChild(loadingobject3);
loadingobject3.scaleX = 0.99;
loadingobject3.scaleY = 0.99;
SoundMixer.stopAll();
currentpage = 3;
button_home.visible = true;
BG.visible = true;
T1.visible = false;
T2.visible = false;
T3.visible = true;
T4.visible = false;
T5.visible = false;
sound_control_home.visible = false;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Theme 4 /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// PAGESWITCH 4 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function pageswitch4(m:MouseEvent)
{
Mouse.show();
if (currentpage != 4)
{
if (currentpage == 0)
{
homepage.visible = false;
}
else if (currentpage == 1)
{
loadingobject1.unload();
}
else if (currentpage == 2)
{
loadingobject2.unload();
}
else if (currentpage == 3)
{
loadingobject3.unload();
}
else if (currentpage == 5)
{
loadingobject5.unload();
}
//loading an external file:
var whattoload:URLRequest = new URLRequest("Theme_4.swf");
loadingobject4.load(whattoload);
addChild(loadingobject4);
SoundMixer.stopAll();
loadingobject4.scaleX = 0.65;
loadingobject4.scaleY = 0.65;
currentpage = 4;
button_home.visible = true;
BG.visible = true;
sound_control_home.visible = false;
//HEADERS
T1.visible = false;
T2.visible = false;
T3.visible = false;
T4.visible = true;
T5.visible = false;
}
}
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Theme 5 /////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
////////////////////////////// PAGESWITCH 5 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
function pageswitch5(m:MouseEvent)
{
Mouse.show();
if (currentpage != 5)
{
if (currentpage == 0)
{
homepage.visible = false;
}
else if (currentpage == 1)
{
loadingobject1.unload();
}
else if (currentpage == 2)
{
loadingobject2.unload();
}
else if (currentpage == 3)
{
loadingobject3.unload();
}
else if (currentpage == 4)
{
loadingobject4.unload();
}
//loading an external file:
var whattoload:URLRequest = new URLRequest("T5.swf");
loadingobject5.load(whattoload);
addChild(loadingobject5);
SoundMixer.stopAll();
loadingobject5.scaleX = 0.78;
loadingobject5.scaleY = 0.78;
currentpage = 5;
button_home.visible = true;
BG.visible = true;
sound_control_home.visible = false;
//HEADERS
T1.visible = false;
T2.visible = false;
T3.visible = false;
T4.visible = false;
T5.visible = true;
}
}
如果可以,請幫助!
非常感謝!
Ĵ
也許你可以發佈你提到的網頁,這樣我們可以看到行動中的行爲? –