如何让 Flash CS4 按钮将用户定向到另一个 URL?
如果之前已经完全解决了这个问题,我深表歉意,但我已经阅读了其他几个线程,但似乎仍然无法让我的文件正常工作。
我的动作脚本代码位于此消息的底部。我使用 Adobe 网站上的说明创建了它: http://help .adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fd7.html
我相信我已将所有对象设置为正确的符号类型(按钮),并且所有实例都已正确命名(请参阅屏幕截图位于:www.footprintsfamilyphoto.com/wp-content/themes/Footprints/images/flash_buttonissue.jpg)
动作脚本位于此处。如果您有建议,请告诉我! (注:我对 Flash 非常陌生):
stop ();
function babieschildren(event:MouseEvent):void
{
trace("babies children method was called!!!");
var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/babies-children");
navigateToURL(targetURL, "_self");
}
bc_btn1.addEventListener(MouseEvent.CLICK, babieschildren);
bc_btn2.addEventListener(MouseEvent.CLICK, babieschildren);
function families(event:MouseEvent):void
{
trace("families method was called!!!");
var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/families");
navigateToURL(targetURL, "_self");
}
f_btn1.addEventListener(MouseEvent.CLICK, families);
f_btn2.addEventListener(MouseEvent.CLICK, families);
function couplesweddings(event:MouseEvent):void
{
trace("couples weddings method was called!!!");
var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/couples-weddings");
navigateToURL(targetURL, "_self");
}
cw_btn1.addEventListener(MouseEvent.CLICK, couplesweddings);
cw_btn2.addEventListener(MouseEvent.CLICK, couplesweddings);
Flash 文件的附加说明 - 文件是一个大约 5 秒的动画,应停止在最后一帧。最后一帧包含 6 个按钮,应将用户引导至网站的 3 个不同页面。请参阅上面的屏幕截图图像链接。
好吧,我尝试了更多的事情,我将“家庭”功能更改为“家庭”,因为出于某种原因它告诉我这是一个重复的功能。这解决了循环问题(文件正在循环而不是停止在这些按钮所在的框架上,并且我收到有关系列函数的编译错误 - “重复函数定义”和“不兼容的覆盖” - 我相当有信心它是不是重复的函数,因为这是我在整个文件中拥有的唯一操作脚本...)。
现在它停止在右侧框架上,编译错误似乎已解决,但当我单击按钮时,我在输出框中没有看到跟踪语句。当我测试电影时,我确实在输出框中收到了一个初始错误,它显示:
TypeError:错误#1009:无法访问 null 的属性或方法 对象引用。在 Portfolio_fla::MainTimeline/frame133()
谁能让我知道这意味着什么?
我已经检查并重新检查了所有按钮名称(和实例名称),它们都在那里,与动作脚本(第 133 帧)位于同一帧中,所以这不应该导致 1009。
也只是删除了每个function 和 addEventListener 一一设置并测试了电影,但 1009 错误在所有 3 种情况下均持续存在。如果删除除“stop ();”之外的所有代码,我不会收到 1009 错误并测试电影。
注意:我在这里提出了一个关于 1009 错误的新的、更具体的问题: stackoverflow.com/questions/2948119/flash-buttons-dont-work-typeerror-error-1009-cannot-access-a-property-or-met
My apologies if this has been fully addressed before, but I've read through several other threads and still can't seem to get my file to work.
My actionscript code is at the bottom of this message. I created it using instructions from the Adobe website: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7fd7.html
I believe I've all of my objects set to the correct type of symbol (button) and all of my instances are named appropriately (see screenshot here: www.footprintsfamilyphoto.com/wp-content/themes/Footprints/images/flash_buttonissue.jpg)
Action Script here. Let me know if you have suggestions! (Note: I am very new to Flash):
stop ();
function babieschildren(event:MouseEvent):void
{
trace("babies children method was called!!!");
var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/babies-children");
navigateToURL(targetURL, "_self");
}
bc_btn1.addEventListener(MouseEvent.CLICK, babieschildren);
bc_btn2.addEventListener(MouseEvent.CLICK, babieschildren);
function families(event:MouseEvent):void
{
trace("families method was called!!!");
var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/families");
navigateToURL(targetURL, "_self");
}
f_btn1.addEventListener(MouseEvent.CLICK, families);
f_btn2.addEventListener(MouseEvent.CLICK, families);
function couplesweddings(event:MouseEvent):void
{
trace("couples weddings method was called!!!");
var targetURL:URLRequest = new URLRequest("http://www.footprintsfamilyphoto.com/portfolio/couples-weddings");
navigateToURL(targetURL, "_self");
}
cw_btn1.addEventListener(MouseEvent.CLICK, couplesweddings);
cw_btn2.addEventListener(MouseEvent.CLICK, couplesweddings);
Additional description of Flash file - file is an approx 5 second animation that should stop on the last frame. The last frame contains 6 buttons which should route the user to 3 different pages of the website. Refer to screenshot image link above.
Alright, I tried a couple more things, I changed the "families" function to "fams" since for some reason it was telling me that it was a duplicate function. That resolved the looping issue (the file was looping instead of stopping on the frame where these buttons are located, and I was receiving compilation errors about the families function - "duplicate function definition" and "incompatible override" - I'm fairly confident it's not a duplicate function, as this is the only action script that I have in this entire file...).
Now it stops on the right frame, the compilation errors appear to be resolved, but I don't see the trace statements in the output box when I click on the buttons. I do get an initial error in the output box when I test the movie, it reads:
TypeError: Error #1009: Cannot access a property or method of a null
object reference. at Portfolio_fla::MainTimeline/frame133()
Can anyone let me know what that means?
i've checked and rechecked all the button names (and instance names), they're all there, right in the same frame as the action script (frame 133), so that shouldn't be causing the 1009.
Also just removed each function and addEventListener set one by one and tested the movie, but the 1009 error persisted in all 3 cases. I do not get the 1009 error if I delete all of the code other than "stop ();" and test the movie.
Note: I've opened a new, more specific question regarding the 1009 error here:
stackoverflow.com/questions/2948119/flash-buttons-dont-work-typeerror-error-1009-cannot-access-a-property-or-met
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你的代码看起来不错。在方法中添加跟踪语句以确保它们确实被调用。还要检查是否有任何弹出窗口阻止程序;当您调用 navigateToURL 而不使用第二个参数,Flash 将尝试创建一个新窗口来打开其中的 URL。对于我们开发人员来说不幸的是(对于用户来说幸运的是),大多数弹出窗口阻止程序都会阻止这种情况发生。将第二个参数添加到您的调用中并查看它是否有效。
请注意,这将导致新的 URL 加载到当前窗口/选项卡中,从而有效地替换包含 SWF 的页面
You code looks fine. Add trace statements in the methods to make sure they're indeed called. Also check for any pop-up blockers; when you call navigateToURL without the second parameter, Flash will try to create a new window to open the URL in. Unfortunately for us developers, (and fortunately for users), most of the pop-up blockers will prevent this from happening. Add the second parameter to your calls and see if it works.
Note that this will cause the new URL to be loaded in the current window/tab, effectively replacing the page that has your SWF