Go Back   kirupaForum > Flash > ActionScript 3.0

Reply
 
Thread Tools Display Modes
Old 11-26-2009, 03:05 PM   #1
Mini-Master2000
Registered User
Scrollbar for a Sprite?

Hello,

I'm currently having trouble on integrating a scrollbar that I downloaded from Warm Forest Flash. I built a XML gallery that is going out of the boundary of height of 466 pixels. The thumbnails that are out of the boundary are still visible. On top of that, I tried to add the scrollbar to the sprites inside and outside the for loop, but sadly it doesn't appear. What am I doing wrong? For the height thing, can I set the size of the ULLoader? Or should I just use a mask or something?

Code:
Main.as

import flash.net.URLLoader;
import flash.net.URLRequest;
import fl.containers.UILoader;
import gs.*;
import gs.easing.*;
import caurina.transitions.*;
import org.libspark.ui.SWFWheel;
import com.warmforestflash.ui.FullScreenScrollBar;

SWFWheel.initialize(stage);

var urlRequest:URLRequest = new URLRequest("xml/pics.xml");
var urlLoader:URLLoader = new URLLoader();
var myXML:XML = new XML();
var xmlList:XMLList;
myXML.ignoreWhitespace = true;

urlLoader.addEventListener(Event.COMPLETE,fileLoaded);
urlLoader.load(urlRequest);

var arrayURL:Array = new Array();
var arrayName:Array = new Array();
var holderArray:Array = new Array();

var nrColumns:uint = 4;

var sprite:Sprite = new Sprite();
addChild(sprite);
var thumb:Thumbnail;

var thumbsHolder:Sprite = new Sprite();
sprite.addChild(thumbsHolder);

var loaderHolder:Sprite = new Sprite();
loaderHolder.graphics.beginFill(0xffffff,1);
loaderHolder.graphics.drawRect(0,0,550,330);
loaderHolder.graphics.endFill();
loaderHolder.x = 2000;
loaderHolder.y = 10;
sprite.addChild(loaderHolder);

var photoLoader:UILoader = new UILoader();
photoLoader.width = 540;
photoLoader.height = 320;
photoLoader.x = 5;
photoLoader.y = 5;
photoLoader.buttonMode = true;
photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
loaderHolder.addChild(photoLoader);

function fileLoaded(event:Event):void {
    myXML = XML(event.target.data);
    xmlList = myXML.children();
    for (var i:int=0; i<xmlList.length(); i++) {
        var picURL:String = xmlList[i].url;
        var picName:String = xmlList[i].big_url;
        var _scrollBar:FullScreenScrollBar;
        _scrollBar = new FullScreenScrollBar(thumbsHolder, 0x000000, 0xff4400, 0x05b59a, 0xffffff, 15, 15, 4, true);
        arrayURL.push(picURL);
        arrayName.push(picName);
        holderArray[i] = new Thumbnail(arrayURL[i],i,arrayName[i]);
        holderArray[i].addEventListener(MouseEvent.CLICK,onClick);
        holderArray[i].name = arrayName[i];
        holderArray[i].buttonMode = true;
        if (i<nrColumns) {
            holderArray[i].y = 116;
            holderArray[i].x = i*256;
        } else {
            holderArray[i].y = holderArray[i-nrColumns].y+110;
            holderArray[i].x = holderArray[i-nrColumns].x;
        }
        thumbsHolder.addChild(holderArray[i]);
        thumbsHolder.addChild(_scrollBar);
    }
}

function onClick(event:MouseEvent):void {
    photoLoader.source = event.currentTarget.name;
    Tweener.addTween(thumbsHolder, {x:-650, time:1, transition:"easeOutExpo"});
    //Tweener.addTween(loaderHolder, {x:10, time:1, transition:"easeOutExpo"});
    Tweener.addTween(thumbsHolder, {alpha:0, time:1, transition:"linear"});
    //Tweener.addTween(loaderHolder, {alpha:1, time:1, transition:"linear"});
}

function onClickBack(event:MouseEvent):void {
    Tweener.addTween(thumbsHolder, {x:0, time:1, transition:"easeOutExpo"});
    //Tweener.addTween(loaderHolder, {x:1000, time:1, transition:"easeOutExpo"});
    Tweener.addTween(thumbsHolder, {alpha:1, time:2, transition:"linear"});
    //Tweener.addTween(loaderHolder, {alpha:0, time:2, transition:"linear"});
}
Code:
Thumbnail.as

package {
    
    import flash.display.Sprite;
    import flash.events.MouseEvent;
    import fl.containers.UILoader;
    import caurina.transitions.*;
    import gs.*;
    import gs.easing.*;

    public class Thumbnail extends Sprite {
        
        private var nume:String;
        private var url:String;
        private var id:int;
        private var loader:UILoader;

        function Thumbnail(source:String,itemNr:int,numeThumb:String):void {
            
            url = source;
            id = itemNr;
            this.nume = numeThumb;
            drawLoader();
            addEventListener(MouseEvent.MOUSE_OVER,onOver);
            addEventListener(MouseEvent.MOUSE_OUT,onOut);
            scaleThumb();
            
        }
        
        private function drawLoader():void {
            
            loader = new UILoader();
            loader.source = url;
            loader.mouseEnabled = false;
            //loader.x = -50;
            //loader.y = -50;
            addChild(loader);

        }
        
        private function onOver(event:MouseEvent):void {
            TweenLite.to(this, 0.5, {alpha:1, ease:Quad.easeOut});
        }
        
        private function onOut(event:MouseEvent):void {
            TweenLite.to(this, 0.5, {alpha:0.7, ease:Quad.easeOut});
        }

        private function scaleThumb():void {
            TweenLite.to(this, 0, {scaleX:0.9, scaleY:0.9, alpha:0.7});
        }
        
    }
}

Last edited by Mini-Master2000; 11-26-2009 at 03:40 PM..
Mini-Master2000 is offline   Reply With Quote

Sponsored Links (Guests Only) - Register | Need Help?
 

Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:09 PM.

SUPPORTERS:

kirupa.com's fast and reliable hosting provided by Media Temple. flash components
Creative web apps. Make your own free flash banners and photo slideshows.
Check out the great, high-quality flash extensions. Buy or sell stock flash, video, audio and fonts for as little as 50 cents at FlashDen.

Flash Transition Effects

Flash Effect Tutorials

Digicrafts Components
Flash effects. Art without coding. Upload, publish, deliver. Secure hosting for your professional or academic video, presentations & more. Screencast.com
Streamsolutions Content Delivery Networks Flipping Book - page flip flash component.
Flash-Gallery.com - Get your flash photo gallery (flash component or swf gallery Learn how to advertise on kirupa.com
 

cdn
content delivery network (cdn)

Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Copyright 2010 - kirupa.com Copyright 2010 - kirupa.com