In need of a little help: Flash probs (scrollbar & page stalling!)
So I have been building this flash website for a friend of mine in CS4 -AS3..
I'm new to flash and have been creating the site through tons of watched tutorials and lots of reading online "how to" article/forums etc.
So far I'm pretty happy with the result, But here is the bad part.
For some reason now when I'm close to the end, I am having a few issues that I just can't seem to get a grip on... :confused:
I'm new to this site, and was hoping someone with more experience could direct me, how to solve my probs.
you can find a temp version of the site here:
http://codexdk.250free.com/
So here is the list of the problems.
1: the main menu buttons animations works fine, but when you go from the top to bottom by pressing each of the menus in that order.
After you hit the last page "contact" and it's been loaded, If you then try to go back to one of the other menus (except main) it stalls and does not load the page anymore, To reset you have to choose the Main button again?.
2: The scroll bar under the Bio page never starts at the top when the page has been loaded, but somewhere 1\4 down from the top?.
3: the fade in animation when selecting a video clip, also stalls from time to time if you move the mouse before it has fully loaded the graphics, but you can hear it start playing the video. and again it resets if you hit the Main button.
View of the ActionScripts:
Problem One:
Actionscript Code:
/*Botton functions.*/
function buttonOver(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("over");
}
function buttonOut(e:MouseEvent):void
{
e.currentTarget.gotoAndPlay("out");
}
/*Botton click event*/
main_mc.addEventListener(MouseEvent.CLICK, firstPage);
bio_mc.addEventListener(MouseEvent.CLICK, newPage);
reel_mc.addEventListener(MouseEvent.CLICK, newPage);
clients_mc.addEventListener(MouseEvent.CLICK, newPage);
contact_mc.addEventListener(MouseEvent.CLICK, newPage);
/*Bio, Reel, Client and Contact pages event caller.*/
function newPage(e:MouseEvent):void {
new Tween(highlight_mc,"y",Strong.easeOut,highlight_mc.y,e.currentTarget.y,1,true);
removeChild(currentPage.targetMC);
if (currentPage==main_mc)
{
new Tween(backFrame,"alpha",Strong.easeOut,0,1,1,true);
addChild(backFrame);
}
currentPage=MovieClip(e.currentTarget);
addChild(currentPage.targetMC);
currentPage.targetMC.gotoAndPlay(1);
}
/*Main page function event caller.*/
function firstPage(e:MouseEvent):void
{
this.main_mc.enabled=false;
new Tween(highlight_mc,"y",Strong.easeIn,highlight_mc.y,e.currentTarget.y,1,true);
removeChild(currentPage.targetMC);
var bframe:Tween=new Tween(backFrame,"alpha",Strong.easeOut,1,0,15,false);
bframe.addEventListener(TweenEvent.MOTION_FINISH,endAnim);
function endAnim(e:Event):void
{
removeChild(backFrame);
gotoAndPlay("2");
}
}
Problem Two:
Actionscript Code:
var sd:Number;
var sr:Number;
var cd:Number;
var cr:Number;
var new_y:Number;
var drag_area:Rectangle;
var flash_content:MovieClip;
var flash_content_area:MovieClip;
var scrolling_speed:Number; // 0.00 to 1.00
function scrolling( ct:String, ct_area:String, speed:Number ):void
{
scrolling_speed = speed;
if( scrolling_speed < 0 || scrolling_speed > 1 ) scrolling_speed = 0.50;
flash_content = parent[ct];
flash_content_area = parent[ct_area];
flash_content.mask = flash_content_area;
flash_content.x = flash_content_area.x;
flash_content.y = flash_content_area.y;
flash_scroller.x = flash_scrollable_area.x;
flash_scroller.y = flash_scrollable_area.y;
sr = flash_content_area.height / flash_content.height;
flash_scroller.height = flash_scrollable_area.height * sr;
sd = flash_scrollable_area.height - flash_scroller.height;
cd = flash_content.height - flash_content_area.height;
cr = cd / sd * 1.01;
drag_area = new Rectangle(0, 0, 0, flash_scrollable_area.height - flash_scroller.height);
if ( flash_content.height <= flash_content_area.height )
{
flash_scroller.visible = flash_scrollable_area.visible = false;
}
flash_scroller.addEventListener( MouseEvent.MOUSE_DOWN, scroller_drag );
flash_scroller.addEventListener( MouseEvent.MOUSE_UP, scroller_drop );
this.addEventListener( Event.ENTER_FRAME, on_scroll );
}
function scroller_drag( me:MouseEvent ):void
{
me.target.startDrag(false, drag_area);
stage.addEventListener(MouseEvent.MOUSE_UP, up);
}
function scroller_drop( me:MouseEvent ):void
{
me.target.stopDrag();
stage.removeEventListener(MouseEvent.MOUSE_UP, up);
}
function up( me:MouseEvent ):void
{
flash_scroller.stopDrag();
}
function on_scroll( e:Event ):void
{
new_y = flash_content_area.y + flash_scrollable_area.y * cr - flash_scroller.y * cr;
flash_content.y += ( new_y - flash_content.y ) * scrolling_speed;
}
Problem Three:
Actionscript Code:
/*Video page Loading Function*/
function vid1Page(e:MouseEvent):void
{
var loader:Loader=new Loader();
var mcExternal:MovieClip;
stage.addChild(loader);
loader.load(new URLRequest("swf/videoframe_1.swf"));
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, preload);
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, done);
function preload(e:ProgressEvent):void
{
preloader_mc.visible = true;
var pct:Number = e.bytesLoaded / e.bytesTotal;
preloader_mc.bar_mc.scaleX = pct;
}
function done(e:Event):void
{
preloader_mc.visible = false;
mcExternal=loader.content as MovieClip;
loader.x=0;
loader.y=0;
new Tween(loader,"alpha",Strong.easeOut,0,1,3,true);
stage.addChild(loader);}
}
These are the major problems I am having,
So I hope someone can help a newbie out a little..
Many Thanks
CodeXdk :)