2007年12月5日 星期三

Week 10 - scrolling dynamic text example

I found an example of how to using dynamic text with picture from Internet, so you don’t have to call external xml files.

Step 1 – Create a symbol and double click the symbol to put Actionscript

Step 2 – Name the layer “Action” and put those ActionScript in frame 1,2,3

Frame 1 -
ifFrameLoaded(3){
gotoAndStop(3)
}

Frame 2-
gotoAndPlay(1);

Frame 3
stop();


Step 3 – Name layer 2 “Menu” and then make another symbol and double click the symbol to put dynamic text and stroller

First layer name “ Actions” and the SctionScript is

hdrName = "Scrolling Text";
// Script engine - Do not modify
boundry_mc._x = txt_mc._x-10;
boundry_mc._y = txt_mc._y;
boundry_mc._width = txt_mc._width+20;
boundry_mc._height = scrollBar._height;
txt_mc.setMask(boundry_mc);
scrollBttn.originY = scrollBttn._y;
scrollBttn.originX = scrollBttn._x;
scrollBttn.maxY = scrollBar._height-scrollBttn._height+scrollBttn.originY-2;
txt_mc.originY = txt_mc._y;
onEnterFrame = function () {
ratio = (txt_mc._height+15-scrollBar._height)/(scrollBar._height-scrollBttn._height);
if (txt_mc._height+15>scrollBar._height) {
destScroll = ((-scrollBttn._y+txt_mc.originY)*ratio)+txt_mc.originY;
txt_mc._y += Math.round((destScroll-txt_mc._y)/5);
}
};



Second layer name “TextClip”, here is where you have dynamic text (instance name: text_mc) and picture


Third layer name ” Scroll Bar”, here you create a track (instance name: text scrollbar_mc) and drag (instance name: text scrollBttn)


Forth layer name “Mask”, make a big white rectangle and put it to cover the dynamic text (instance name: boundry_mc)

You have to match your mask color as same as your background color.


Last step – test movie or test scene.