有人可以通过动作脚本3中的动态页面标题来帮助我吗? [英] Can someone help me with Dynamic Page Titles in Actionscript 3 Please?

查看:139
本文介绍了有人可以通过动作脚本3中的动态页面标题来帮助我吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HELP!我如何解决这个Actionscript 3.0,以便为每个页面创建一个动态页面标题?
我是Actionscript 3.0的新手,我正在为每个页面使用动态文本生成页面标题。我的网站有四页,这里是我到目前为止的动作片:

  stop()
function createTitle(whichpage:String){
pageTitle.text = whichpage;
};
var page:String =theres no place like home;
createTitle(page);

函数btn1Press(MouseEvent){
gotoAndStop(1);
}

函数btn2Press(MouseEvent){
gotoAndStop(10);
}

函数btn3Press(MouseEvent){
gotoAndStop(20);
}

函数btn4Press(MouseEvent){
gotoAndStop(30);
}

btn1Press.addEventListener(MouseEvent.CLICK,Home);
btn2Press.addEventListener(MouseEvent.CLICK,Services);
btn3Press.addEventListener(MouseEvent.CLICK,About);
btn4Press.addEventListener(MouseEvent.CLICK,Contact);

stop();


1,10,20,30表示每个页面在
上的框架

四个导航按钮设置如下:

  btn1Press =主页(实例名称Home) 
btn2Press =服务页面(实例名称服务)
btn3Press =关于页面(实例名称关于)
btn4Press =联系人页面(实例名称联系人)

我已经设置了动态文本框。基本上,我需要每个按钮去他们各自的页面,我需要动态文本框中的文本根据哪个页面进行更改。这是我在框架10,20和30(服务,关于和联系)上的附加动作脚本。



page =services;
createTitle(page);
stop();



page =about;
createTitle(page);
stop();



page =contact;
createTitle(page);
stop();



我真的很沮丧,任何帮助都会非常棒!



我不断收到错误#1061关于未定义的函数



所以我想一个更好的方式来问我的问题是:



我在Flash CS4中有一个四页网站,第1页从第1帧开始,第2帧从第20帧开始,第30帧开始,第30帧开始。有四个导航按钮我已经转换为按钮符号。我应该称之为每个按钮,我应该称之为每个按钮的实例?为了使导航按钮正常运行,我需要放置什么代码,并使动态文本框显示与其所在页面相关的标题(欢迎使用主页,欢迎使用感谢您的帮助+耐心等待,我发现这一切都令人困惑。 :(

解决方案

听起来像是要在Flex中切换视图时在Flex中的页面上动态更改HTML标题只有这样做才是通过Flex中的javascript调用的,它会像这样:



FLEX

  public function setTitle(title:String):void {
if(ExternalInterface.available){
ExternalInterface.call(setTitle,title);
}
}

JAVASCRIPT

  function setTitle(t){
document.title.innerText = t;
}


HELP! How would I fix this Actionscript 3.0 so that it creates a Dynamic Page title for each page? I am new to Actionscript 3.0 and I am trying to generate a page title using Dynamic Text for each page. I have four pages in my site, and here is the actionscript that I have so far:

stop ()
function createTitle (whichpage:String) {
pageTitle.text = whichpage;
};
var page:String="theres no place like home";
createTitle (page);

function btn1Press (MouseEvent) {
gotoAndStop (1);
}

function btn2Press (MouseEvent) {
gotoAndStop (10);
}

function btn3Press (MouseEvent) {
gotoAndStop (20);
}

function btn4Press (MouseEvent) {
gotoAndStop (30);
}

btn1Press.addEventListener (MouseEvent.CLICK, Home);
btn2Press.addEventListener (MouseEvent.CLICK, Services);
btn3Press.addEventListener (MouseEvent.CLICK, About);
btn4Press.addEventListener (MouseEvent.CLICK, Contact);

stop();


1,10,20,30 represent the frames that each page is on

The four navigation buttons are setup as follows:

btn1Press = Home Page (Instance name "Home")
btn2Press = Services Page (Instance name "Services")
btn3Press= About Page (Instance name "About")
btn4Press=Contact Page (Instance name "Contact")

I already have the dynamic text box set up. Basically I need each of the buttons to go to their respective pages, and I need the text in the dynamic text box to change depending on which page it is. Here is the additional actionscript that I have at frames 10,20 and 30 (services,about,and contact)

page = "services"; createTitle (page); stop ();

page = "about"; createTitle (page); stop ();

page = "contact"; createTitle (page); stop ();

I am getting really frustrated with this, and any help would be SO awesome!

I keep getting error #1061 about undefined functions

So I think a better way to ask my question would be:

I have a four page site in Flash CS4, Page 1 starts on Frame 1, Page 2 starts on Frame 10, Page 3 starts on Frame 20 and Page 4 starts on Frame 30. There are Four navigation buttons that I have converted to button symbols. What should I call each button, and what should I call the instance of each button? What code do I need to put in the actions panel in order to get the navigation buttons to function properly, and make the dynamic text box display a title specific to the page that it is on ("Welcome to the Home Page", "Welcome to the About Page", etc)

Thanks for your help + patience, I am finding this all pretty confusing. :(

解决方案

Sounds like you want to dynamically change the HTML title on a page from within Flex when switching views in Flex. The only way to do this is via javascript called from within Flex. It would go something like this:

FLEX

public function setTitle(title:String):void {
if (ExternalInterface.available) {
    ExternalInterface.call("setTitle", title);
}
}

JAVASCRIPT

    function setTitle(t){
document.title.innerText = t;
}

这篇关于有人可以通过动作脚本3中的动态页面标题来帮助我吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆