在 Action Script 2.0 中附加带有下一个/前进按钮的电影控件
我使用attachMovie 在舞台上连续调用影片剪辑。我使用前进按钮来滑动它们,但是当我想以相同的顺序返回时,一切都会变得混乱。 您可以在此处看到正在播放的 swf,
http://www.taltin.net/FILES_WEBDESIGN/Fluid1_1.swf
我对每一帧进行了编号,以便您可以在单击后退按钮时看到它会变得混乱。
// Each of the button functions here call the add_page() function and
// pass the Identifier of the page that they will display
b_0.onRelease = function() {
next_page( "Video1A_" + page_count);
};
b_1.onRelease = function() {
prev_page( "Video1A_" + page_count);
};
// This function manages the page clips that are attached to content_mc.
// The variable page_count is used to make sure that each page gets a unique
// name and depth. It also gives us a way to get the instance name of the
// last page clip that was created.
var page_count = 1;
// The add_page() function takes the Linkage identifier of the new page to be
// created as a parameter.
function next_page( next_page ) {
// Make the name of the last page attached
var old_page = content_mc[ "Video1A_" + page_count ];
// If that page exists remove it by sliding off out of the visible area.
if ( old_page != undefined ) {
old_page.slideTo( '-600', '0', 1, '', 0, old_page + '.removeMovieClip()' );
}
// Up page count by 1
page_count ++;
// Attach the new page to content_mc
var new_page = content_mc.attachMovie( next_page, "Video1A_" + page_count, page_count );
// Position the new page below the visible area
new_page._x = 600;
// slide the new page into the visible area.
new_page.slideTo( '-600', 0, 2 );
}
// The add_page() function takes the Linkage identifier of the new page to be
// created as a parameter.
function prev_page( next_page ) {
// Make the name of the last page attached
var old_page = content_mc[ "Video1A_" + page_count ];
// If that page exists remove it by sliding off out of the visible area.
if ( old_page != undefined ) {
old_page.slideTo( '600', '0', 2, '', 0, old_page + '.removeMovieClip()' );
}
// Up page count by 1
page_count --;
// Attach the new page to content_mc
var new_page = content_mc.attachMovie( next_page, "Video1A_" + page_count, page_count );
// Position the new page below the visible area
new_page._x = -600;
// slide the new page into the visible area.
new_page.slideTo( '600', 0, 2 );
}
I use attachMovie to call movie clips succesively on the stage. I use a forward button to slide them in progression but when I want to go back in the same order everything gets messed up.
You can see the swf playing here,
http://www.taltin.net/FILES_WEBDESIGN/Fluid1_1.swf
I numbered each frame so you can see when clicking on back button it gets messed up.
// Each of the button functions here call the add_page() function and
// pass the Identifier of the page that they will display
b_0.onRelease = function() {
next_page( "Video1A_" + page_count);
};
b_1.onRelease = function() {
prev_page( "Video1A_" + page_count);
};
// This function manages the page clips that are attached to content_mc.
// The variable page_count is used to make sure that each page gets a unique
// name and depth. It also gives us a way to get the instance name of the
// last page clip that was created.
var page_count = 1;
// The add_page() function takes the Linkage identifier of the new page to be
// created as a parameter.
function next_page( next_page ) {
// Make the name of the last page attached
var old_page = content_mc[ "Video1A_" + page_count ];
// If that page exists remove it by sliding off out of the visible area.
if ( old_page != undefined ) {
old_page.slideTo( '-600', '0', 1, '', 0, old_page + '.removeMovieClip()' );
}
// Up page count by 1
page_count ++;
// Attach the new page to content_mc
var new_page = content_mc.attachMovie( next_page, "Video1A_" + page_count, page_count );
// Position the new page below the visible area
new_page._x = 600;
// slide the new page into the visible area.
new_page.slideTo( '-600', 0, 2 );
}
// The add_page() function takes the Linkage identifier of the new page to be
// created as a parameter.
function prev_page( next_page ) {
// Make the name of the last page attached
var old_page = content_mc[ "Video1A_" + page_count ];
// If that page exists remove it by sliding off out of the visible area.
if ( old_page != undefined ) {
old_page.slideTo( '600', '0', 2, '', 0, old_page + '.removeMovieClip()' );
}
// Up page count by 1
page_count --;
// Attach the new page to content_mc
var new_page = content_mc.attachMovie( next_page, "Video1A_" + page_count, page_count );
// Position the new page below the visible area
new_page._x = -600;
// slide the new page into the visible area.
new_page.slideTo( '600', 0, 2 );
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
粗体部分是错误的,您附加的影片剪辑是传递过来的 next_page 参数,
如果您要将 page_count 设为全局变量并具有用于转到下一页和用于转到上一页的单独函数,为什么这样做你甚至在函数中使用参数?
the bolded part is wrong, the movie clip you are attaching is the next_page argument as passed on from
if you're going to make page_count a global variable and have separate functions for going to the next and for going for the previous page, why do you even use arguments in the function?