Editing custom classes + external scripting files as3


hey everyone!

 

i'm new scripting in general , as3 in particular. current project @ standstill , i'm hoping out there can point me in right direction. please bare me while explain problem best can...my terminology may make of want scratch eyes out...sorry in advance.

 

here's issue:

i've purchased as3 scrollbar component online in order scroll movie clips have used scroll dynamic text. each scrollbar instance used in separate swf (bio.swf , samples.swf) which, in turn, loaded main movie (start.swf). both individual swf's preview beautifully on own....no scroll issues or errors. load them main start movie, content shows fine scrollers don't work. click on "tracker", follows mouse around page , sticks until click 1 of nav buttons exit different page.

 

there external script file associated scrollbar that, understand it, needs in same place swf's. there caurina file came scrollbar told file shouldn't need referenced. regardless, have both script files in main source file. have been told may "class" issue may "re-cursive"(?) issue.

 

to me, seems swf losing path external script once it's loaded secondary movie.

 

please find below script i've used within each swf in external swf. can me? options...in beginners terms?

 

this script have within bio , samples swf's:

 

sb1.init(vidscroll_mc, "easeoutback",2,true,2);

 

this script appears in external scrollbar.as file:

 

/**

* flashscaper scrollbar component

* customizable scrollbar

*

* @author li jiansheng

* @version 1.0.0

* @private

* @website     http://www.flashscaper

*/

 

package {

 

import caurina.transitions.*;

import flash.display.*;

import flash.events.*;

import flash.geom.*;

 

public class scrollbar extends movieclip {

 

private var target:movieclip;

private var top:number;

private var bottom:number;

private var dragbot:number;

private var range:number;

private var ratio:number;

private var spos:number;

private var srect:rectangle;

private var ctrl:number;//this adapt target's position

private var trans:string;

private var timing:number;

private var isup:boolean;

private var isdown:boolean;

private var isarrow:boolean;

private var arrowmove:number;

private var uparrowht:number;

private var downarrowht:number;

private var sbuffer:number;

 

public function scrollbar():void {

scroller.addeventlistener(mouseevent.mouse_down, dragscroll);

stage.addeventlistener(mouseevent.mouse_up, stopscroll);

stage.addeventlistener(mouseevent.mouse_wheel,mousewheelhandler);

}

//

public function init(t:movieclip, tr:string,tt:number,sa:boolean,b:number):void {

target = t;

trans = tr;

timing = tt;

isarrow = sa;

sbuffer = b;

if (target.height <= track.height) {

this.visible = false;

}

 

//

uparrowht = uparrow.height;

downarrowht = downarrow.height;

if (isarrow) {

top = scroller.y;

dragbot = (scroller.y + track.height) - scroller.height;

bottom = track.height - (scroller.height/sbuffer);

 

} else {

top = scroller.y;

dragbot = (scroller.y + track.height) - scroller.height;

bottom = track.height - (scroller.height/sbuffer);

 

uparrowht = 0;

downarrowht = 0;

removechild(uparrow);

removechild(downarrow);

}

range = bottom - top;

srect = new rectangle(0,top,0,dragbot);

ctrl = target.y;

//set mask

isup = false;

isdown = false;

arrowmove = 10;

 

if (isarrow) {

uparrow.addeventlistener(event.enter_frame, uparrowhandler);

uparrow.addeventlistener(mouseevent.mouse_down, upscroll);

uparrow.addeventlistener(mouseevent.mouse_up, stopscroll);

//

downarrow.addeventlistener(event.enter_frame, downarrowhandler);

downarrow.addeventlistener(mouseevent.mouse_down, downscroll);

downarrow.addeventlistener(mouseevent.mouse_up, stopscroll);

}

var square:sprite = new sprite();

square.graphics.beginfill(0xff0000);

square.graphics.drawrect(target.x, target.y, target.width+5, (track.height+uparrowht+downarrowht));

parent.addchild(square);

target.mask = square;

 

}

public function upscroll(event:mouseevent):void {

isup = true;

}

public function downscroll(event:mouseevent):void {

isdown = true;

}

public function uparrowhandler(event:event):void {

if (isup) {

if (scroller.y > top) {

scroller.y-=arrowmove;

if (scroller.y < top) {

scroller.y = top;

}

startscroll();

}

}

}

//

public function downarrowhandler(event:event):void {

if (isdown) {

if (scroller.y < dragbot) {

scroller.y+=arrowmove;

if (scroller.y > dragbot) {

scroller.y = dragbot;

}

startscroll();

}

}

}

//

public function dragscroll(event:mouseevent):void {

scroller.startdrag(false, srect);

stage.addeventlistener(mouseevent.mouse_move, movescroll);

}

//

public function mousewheelhandler(event:mouseevent):void {

if (event.delta < 0) {

if (scroller.y < dragbot) {

scroller.y-=(event.delta*2);

if (scroller.y > dragbot) {

scroller.y = dragbot;

}

startscroll();

}

} else {

if (scroller.y > top) {

scroller.y-=(event.delta*2);

if (scroller.y < top) {

scroller.y = top;

}

startscroll();

}

}

}

//

public function stopscroll(event:mouseevent):void {

isup = false;

isdown = false;

scroller.stopdrag();

 

stage.removeeventlistener(mouseevent.mouse_move, movescroll);

}

//

public function movescroll(event:mouseevent):void {

startscroll();

 

}

public function startscroll():void {

ratio = (target.height - range)/range;

spos = (scroller.y * ratio)-ctrl;

 

tweener.addtween(target, {y:-spos, time:timing, transition:trans});

}

}

}



More discussions in ActionScript 3


adobe

Comments

Popular posts from this blog

Joomla site hacked, cant see front and - Joomla! Forum - community, help and support

Trouble with PF_OutFlag_I_USE_AUDIO and PF_CHECKOUT_LAYER_AUDIO

Christian Home School Programs - Joomla! Forum - community, help and support