2011-11-08 75 views
0

我使用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; 
    } 
} 

如果可以,请帮助!

非常感谢!

Ĵ

+0

也许你可以发布你提到的网页,这样我们可以看到行动中的行为? –

回答

0

你不会阻止这样的行为,如果你不能修改加载的SWF文件的任何成功。

如果能够修改加载的SWF,你应该叫Mouse.hide()而已,如果你的剪辑添加到舞台(通过听Event.ADDED_TO_STAGE),并调用Mouse.show()如果从显示列表中删除(通过听Event.REMOVED_FROM_STAGE) 。

在您的加载片段中,请务必只在的片段中添加加载的片段,但实际上需要显示该片段并在不再需要时使用removeChild()将其删除。这将触发上面描述的监听器来显示和隐藏鼠标。