我正在创建一个包含flash 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;
}
}
如果可以,请帮助!
非常感谢!!!
Ĵ
答案 0 :(得分:0)
如果无法修改加载的swf,则无法成功阻止该行为。
如果您可以修改已加载的swf,则只应调用Mouse.hide()
,如果您的剪辑已添加到舞台上(通过聆听Event.ADDED_TO_STAGE
)并调用Mouse.show()
从显示列表中删除(通过收听Event.REMOVED_FROM_STAGE
)。
在您的加载程序剪辑中,请务必仅在实际需要显示时添加加载的剪辑addChild()
,并在不再需要时使用removeChild()
将其删除。这将触发上述的监听器,它们负责显示和隐藏鼠标。