Import fl.containers.ScrollPane;

Hello,
I was looking over some of the AS3 packages, and I was
trying sample code for ScrollPane.
In any case, I kept getting errors, so I reduced the
FLA down to
import fl.containers.ScrollPane;
I also tried:
import fl.containers.*;
The error is:
1172: Definition fl.containers could not be found.
I would think the Flash enviroment "knows"
where this is located.
What is wrong? Do I have to explicitly add the path?
Thanks,
Jim

i know that "no" sounded curt but that's what it seemed you wanted.  i gave a complete answer in the message prior to that "no" response.
for example, you can use the easing classes without using any component:
import fl.transitions.easing.Back;
var n:Number = Back.easeInOut(3,3,3,3);
and, of course,  you can use the tween class without using any component.  but most of the fl classes do involve components and when you want to reference a component, it needs to be your library.

Similar Messages

  • I can't get ScrollPane.invalidate() to work.  Need help on this one.

    I have a dynamically created scrollpane who's content comes
    from a movieclip in the library.
    When I add this content from the library, I can't for the
    life of me get the scrollpane to correctly render the scrollbars.
    This is the code that I have. The movieclip in the library is
    linked as mc1 (width 100 height 46)
    import fl.containers.ScrollPane;
    import fl.controls.ScrollPolicy;
    import fl.controls.DataGrid;
    import fl.data.DataProvider;
    var aSp:ScrollPane = new ScrollPane();
    aSp.verticalScrollPolicy = "on";
    aSp.horizontalScrollPolicy = "on";
    var aBox:MovieClip = new MovieClip();
    drawBox(aBox);
    aSp.setSize(300, 300);
    aSp.source = aBox;
    addChild(aSp);
    function drawBox(box:MovieClip):void {
    var myMc1:mc1 = new mc1();
    myMc1.y = 50;
    myMc1.x = 50;
    box.addChild(myMc1);
    var mymc2:mc1 = new mc1();
    mymc2.x = 200;
    mymc2.y = 50;
    box.addChild(mymc2);
    }

    I figured it out. Nevermind.

  • ScrollPane doesn't display its content

    I created a scrollpane in as3 and set its source to another object, which contains several rows of icons.
    The scrollbar in the scrollpane is getting the right length, which means the object was loaded as expected, but the contant is not showing correctly.
    I created a Thumbnail class for this file to load and make each individual thumbnail.
    Here is my code, the red text is where each thumbnail is loaded:
    import fl.containers.UILoader;
    import caurina.transitions.*;
    import flash.events.Event;
    import fl.containers.ScrollPane;
    var urlRequest:URLRequest = new URLRequest("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 = 3;
    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(0x666666,1);
    loaderHolder.graphics.drawRoundRect(0,0,450,340, 20,20);
    loaderHolder.graphics.endFill();
    loaderHolder.x = 280;
    loaderHolder.y = 240;
    sprite.addChild(loaderHolder);
    var photoLoader:UILoader = new UILoader();
    photoLoader.width = 450;
    photoLoader.height = 340;
    photoLoader.y = 5;
    photoLoader.x = 5;
    photoLoader.buttonMode = true;
    photoLoader.addEventListener(MouseEvent.CLICK,onClickBack);
    loaderHolder.addChild(photoLoader);
    var scrollPane:ScrollPane=new ScrollPane();
    var skin:MovieClip = new MovieClip();
    scrollPane.x = 805;
    scrollPane.y = 405;
    scrollPane.width = 215;
    scrollPane.height = 280;
    scrollPane.setStyle( "skin", skin );
    scrollPane.setStyle( "upSkin", skin );
    scrollPane.source = thumbsHolder;
    sprite.addChild(scrollPane);
    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;
      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 = 440;
       holderArray[i].x = i * 65 + 840;
      else
       holderArray[i].y = holderArray[i - nrColumns].y + 65;
       holderArray[i].x = holderArray[i - nrColumns].x;
      thumbsHolder.addChild(holderArray[i]);
      scrollPane.update();
    function onClick(event:MouseEvent):void
    photoLoader.alpha = 0.1;
    photoLoader.source = event.currentTarget.name;
    photoLoader.addEventListener(Event.COMPLETE, fadeOut);
    function fadeOut(event:Event):void
      Tweener.addTween(photoLoader, {alpha:1, time:0.5, transition:"linear"});
    function onClickBack(event:MouseEvent):void
      Tweener.addTween(loaderHolder, {alpha:.5, time:2, transition:"linear"});

    Bold is about the only text editing feature that works in the current editor panel.  The rest were disabled due to spam-related abuse (addng white text, etc)
    I cannot really follow what is going into where and where it is being put (just too lazy to track it down at this time of night), but it sounds like it might be possible that your content is being planted at a location that it is not visible in the scrollpane panel.  The scrollpane is only 215 pixels wide but you have something called a loaderHolder that is being placed at x = 280.  And then elsewhere you have holderArray[i].x = i * 65 + 840;, which is placing it well beyond the 215 width.

  • Scaling a SWF in a scrollpane?

    I have a SWF file, with it's own buttons and events etc. that I am trying to load into a scrollpane in a parent application, and have it be scale-able (i.e. zoom in and out).  It doesn't need to animate zoom, click to new scale is ok for now.
    I have tried this in the document class:
    package {
         import flash.display.MovieClip;
         import flash.display.Shape;
         import flash.display.Sprite;
         import flash.display.DisplayObject;
         import flash.events.*;
         import flash.geom.Rectangle;
         import flash.net.*;
         import flash.utils.Timer;
         import fl.containers.ScrollPane;
         public class InspectorShell extends MovieClip {
              private var gameToLoad:URLRequest = new URLRequest("inspector11.swf");
              public function InspectorShell():void {
                   var sp:ScrollPane = new ScrollPane();
                   sp.width = 600;
                   sp.height = 400;
                   sp.move(0,0);
                   sp.scrollDrag = true;
                   sp.verticalScrollPolicy = "false";
                   sp.horizontalScrollPolicy = "false";
                   sp.cacheAsBitmap = true;
                   addChild(sp);
                   sp.load(gameToLoad);
                   sp.content.scaleX = .5;
                   sp.content.scaleY = .5;
    Everything seems to work except the scale  statements at the end, they generate a compiler error:
    TypeError: Error #1009: Cannot access a property or method of a null object reference.
    at InspectorShell()

    It's likely the lines where you set content.scaleX and scaleY since there is no content until it is actually loaded... you should do those inside a COMPLETE listener.

  • Using ScrollPane in Flashbuilder

    Hi,
    if i follow the example in the API. I can't get a ScrollPane to work.
    I import fl.containers.ScrollPane but FlashBuilder4 says it can't be found.
    That the rest can't work is obvious.
    How can I work with ScrollPanes only using FlashBuilder?

    If you must use Flex 3 but want to use Flash Builder 4, you can choose the 3.5 SDK when you create a project in Flash Builder, and you will be building a Flex 3 project and all the old videos should work for you.
    If you want to use Flex 4 and Flash Builder 4, then I suggest you learn from the Flex 4 and Flash Builder 4 videos (http://www.adobe.com/devnet/flex/videotraining/). That way there won't be any confusion between the old and new versions.
    You can download the solution files for any of the exercises. The one called "Adding data to your application" will help you populate a DropDownList control. HTHs.

  • Add Dynamic Content to ScrollPane

    I have created a Address Class that uses Remote Hosting to
    get addresses for site locations and creates the appropriate
    listings in a MovieClip.
    I am trying to use this class as the source for a scroll pane
    inside another movie clip.
    I get the site locations to show up in the scrollPane but
    they will not scroll.
    I believe I need to pause some how in the constructor until I
    have all the site addresses created.
    Anyone know how I would do that or know how to get the
    scrollpane to scroll.
    Thanks
    Adam
    Here are some snippets
    The container MovieClip
    import FlashCFMXApplication.AL_Addresses;
    import fl.containers.ScrollPane;
    var scrollPane:ScrollPane;
    scrollPane = new ScrollPane;
    scrollPane.scrollDrag = true;
    scrollPane.width = 270;
    scrollPane.height = 380;
    scrollPane.y = -180;
    scrollPane.source = new AL_Addresses;
    addChild(scrollPane);
    stop();
    AL_Addresses.as
    package FlashCFMXApplication{
    import flash.display.Sprite
    public class AL_Addresses extends Sprite
    import flash.display.*;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.net.Responder;
    import fl.data.DataProvider;
    import FlashCFMXApplication.ArrayCollectionDP
    private var siteTitleFormat:TextFormat;
    private var siteCityFormat:TextFormat;
    private var requestObject = new Object;
    private var getStateSites = new Responder(getSites,
    onFault);
    private var getStats = new Responder(getSiteStats, onFault);
    public var maxWidth:int;
    public var Addresses_mc = new MovieClip();
    public var getStateSites_mc:MovieClip;
    public var box:Shape = new Shape();
    public function AL_Addresses() {
    import flash.net.NetConnection;
    var myService:NetConnection;
    myService = new NetConnection();
    //set encoding to AMF0 for complex objects
    myService.objectEncoding = 0;
    myService.connect("
    http://site.com/flashservices/gateway")
    requestObject.requestType = "rs"
    requestObject.requestData = "AL";
    myService.call( "sites.functions.getStateSites" ,
    getStateSites,requestObject);
    private function getSites(result){
    siteTitleFormat = new TextFormat();
    siteTitleFormat.font = "Arial";
    siteTitleFormat.size = 13; //12
    siteTitleFormat.color = 0xBCBCBC;
    siteTitleFormat.bold = true;
    siteCityFormat = new TextFormat();
    siteCityFormat.font = "Arial";
    siteCityFormat.size = 13; //12
    siteCityFormat.color = 0xF87A04;
    siteCityFormat.bold = true;
    var myDataProvider:DataProvider;
    myDataProvider = new DataProvider();
    myDataProvider =
    ArrayCollectionDP.toDataProvider(result.SITES_RS);
    var x:int = 10;
    var y:int = 5;
    var tmp_mc:MovieClip;
    for (var i:int = 0; i <= myDataProvider.length-1; i++){
    var x_text:int = 0;
    var y_text:int = 0;
    tmp_mc = new MovieClip;
    var Name:TextField = new TextField();
    Name.width = 270;
    Name.x = x_text;
    Name.y = y_text;
    Name.text = myDataProvider.getItemAt(i).NAME;
    Name.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(Name);
    y_text = y_text + 15
    var Address:TextField = new TextField();
    Address.width = 270;
    Address.x = x_text;
    Address.y = y_text;
    Address.text = myDataProvider.getItemAt(i).ADDRESS;
    Address.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(Address);
    y_text = y_text + 15
    var City:TextField = new TextField();
    City.x = x_text;
    City.y = y_text;
    City.text = myDataProvider.getItemAt(i).CITY;
    City.setTextFormat(siteCityFormat);
    tmp_mc.addChild(City);
    x_text = x_text + City.textWidth + 5;
    var State:TextField = new TextField();
    State.width = 100;
    State.x = x_text;
    State.y = y_text;
    State.text = myDataProvider.getItemAt(i).STATE;
    State.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(State);
    x_text = x_text + State.textWidth + 3;
    var Zip:TextField = new TextField();
    Zip.x = x_text;
    Zip.y = y_text;
    Zip.text = myDataProvider.getItemAt(i).ZIP;
    Zip.setTextFormat(siteTitleFormat);
    tmp_mc.addChild(Zip);
    tmp_mc.x = x;
    tmp_mc.y = y;
    Addresses_mc.addChild(tmp_mc);
    y = y + 120;
    getStateSites_mc.addChild(Addresses_mc);
    public function onFault( f){
    trace("There was a problem: " + f.description);
    }//class
    } //package

    I don't see it in your code anywhere, but maybe you removed
    it (or I'm just not seeing it). You should update it only after you
    have filled the scrollpane, not when you add the scrollpane to the
    stage. It is not likely the scrollpane is filled by the time these
    two lines are processed, especially if you are loading content from
    a server...
    scrollPane.source = new AL_Addresses;
    addChild(scrollPane);

  • Asociar MC y SCROLLPANE

    Hola:
    Tengo un MC en el que cargo una imagen con el siguiente
    código asociado a un
    botón:
    on(release){
    _root.fecha_mc.loadMovie("sol.jpg");
    Quiero que ese MC (con la imagen que carga) queden dentro de
    un SCROLLPANE,
    tengo que asociarlos pero no sé cómo.
    Muchas gracias.
    Federico

    Muchas gracias!!!!!!!
    Federico
    "Juan Muro" <[email protected]> escribió en el
    mensaje de noticias
    news:gqi55b$pkn$[email protected]..
    > Hola federico:
    > Es sencillo, según la ayuda de macromedia, creo
    recordar que había tres
    > métodos de hacerlo:
    > // método 1: Imagen JPEG
    > my_sp.contentPath
    =http://www.helpexamples.com/flash/images/image1.jpg;
    > // método 2: Símbolo en la biblioteca
    > my_sp.contentPath ="movieClip_Name";
    > // método 3: Archivo SWF
    > my_sp.contentPath ="logo.swf";
    > Ya ves que para una imágen a un swf lo único
    que varía es que la ruta debe
    > ser absoluta o relativa y en las comillas, sin embargo
    el movieclip debe
    > estar en el mismo nivel que el swf principal.
    > Previamente deberías cargar la superclase con un:
    > import mx.containers.ScrollPane;
    > o bien arrastrando el scrollpane al escenario y luego
    suprimiéndolo antes
    > de publicar la película.
    > Salu2
    > `8¬]
    > Juan Muro
    >
    >
    > "Federico" <[email protected]>
    escribió en el mensaje
    > news:gqg7qb$bg3$[email protected]..
    >> Hola:
    >>
    >> Tengo un MC en el que cargo una imagen con el
    siguiente código asociado a
    >> un botón:
    >>
    >> on(release){
    >> _root.fecha_mc.loadMovie("sol.jpg");
    >> }
    >>
    >> Quiero que ese MC (con la imagen que carga) queden
    dentro de un
    >> SCROLLPANE, tengo que asociarlos pero no sé
    cómo.
    >> Muchas gracias.
    >>
    >>
    >> Federico
    >>
    >
    >

  • Function issue

    i have a package containg function "Main".
    in frame one i have movieclip with scroll script and child of this movieclip, as well as a btn that trigger "gotoandstop(2)" ,frame 2  contains video, and a btn "return" that trigger "gotoandstop(1)" (back to frame 1).
    however when returning to frame one the movie clip loses the scroll and child is not added.
    what is my mistake?

    this is the code:
    the  public function resumeVideo  activates"gotoandstop(1)".
    on frame 1 i want all the app to start again (including of course the
      scroll_mc.addChild(A1)
      scroll_mc.addChild(A2)
    located in function Main
    thank you
    package {
              import fl.containers.ScrollPane;
              import fl.controls.ScrollPolicy;
              import flash.desktop.NativeApplication;
              import flash.desktop.SystemIdleMode;
              import flash.display.MovieClip;
              import flash.media.Video;
              import flash.net.NetConnection;
              import flash.net.NetStream;
              import flash.events.MouseEvent;
              import flash.events.NetStatusEvent;
              import fl.controls.List
              import flash.events.Event;
                        public class Main extends MovieClip {
                        public var song:Array=["lego.flv","hatizmoret.flv","shir_hageshem.flv","ez.flv", "tarnegol.flv","se_ugdi.flv","dag.flv","lizard.flv","toy_train_set_qt. flv","hadubim.flv","geveret_shfanfana.flv",
                                                 "parash_ben_hail.fl v","snake.flv","pil_pilon.flv","cat.flv","gan_shelanu.flv","purrfect_b irthday_qt.flv","nadneda.flv","hatul_ganav.flv",
                                                 "yonatan_hakatan.fl v","dog.flv","aviron.flv","zipor.flv","hipo.flv","ladod_moshe.flv","sh afan.flv","hipushit.flv","achbar.flv","tolaat.flv","zefardea.flv","dov .flv",
                                                 "shaon_ben_hail.flv ","kof.flv","hayom_yom_huledet.flv","ima_yekara.flv","oniya.flv","bee_ and_flowers_qt.flv ","hasida.flv","ima_avaza.flv","yedidi_tintan.flv","donkey.flv",
                                                 "haoto_shelanu.flv" ,"bimdinat_hagamadim.flv"]
                        public var song_number:String
                        public var netConnection:NetConnection;
                        private var netStream:NetStream;
                        private var video:Video;
                        private var VIDEO_URL:String;
                        public var speed:Number;
                        public var speedArray:Array;
                                                                          public var prevY:Number;
                        public var DRAG:Number = 20;
                        public var HEIGHT:int = 310;
                        public var posX:int= 10;
                        public var posY:int =10;
                        public var widt:int=100;
                                                                       public var high:int=100
                                                                       public var A1:MovieClip=new a1()
                        public var A2:MovieClip=new a2()
                        public var scroll_mc:MovieClip
                        public function Main() {
                                                                scroll_mc.addChild(A1)
                                                                scroll_mc.addChild(A2)
                                              A1.x=posX
                                              A1.y=posY
                                                                A1.height=high;
                                                                A1.width=widt;
                A1.addEventListener(MouseEvent.CLICK, next_frame1);
                A2.x=(posX +110)
                A2.y=posY
                A2.height=high;
                A2.width=widt;     
                                                                A2.addEventListener(MouseEvent.CLICK, next_frame2);           
                                  scroll_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
                                  NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
                                  netConnection = new NetConnection();
                                  netConnection.connect(null);
                                  netStream = new NetStream(netConnection);
                                  netStream.client = this;
                                  netStream.addEventListener(NetStatusEvent.NET_STATUS, statusUpdated);
                                  video = new Video();
                                  video.attachNetStream(netStream);
                                  video.width = 480;
                                  video.height = 320;
                                  addChildAt(video, 0);
                                                      public function next_frame1(e:MouseEvent):void {
                                                                gotoAndStop(2)
                                                                song_number=song[0]
                                                                setupControls();
                                                                trace(VIDEO_URL)
                                                                trace(song_number)
                                                      public function next_frame2(e:MouseEvent):void {
                                                                gotoAndStop(2)
                                                                song_number=song[1]
                                                                setupControls();
                        function onDown(evt:MouseEvent):void {
                        speedArray = new Array(0,0,0,0,0,0,0,0,0,0);
                        speed = 0;
                        prevY = this.mouseY;
                        stage.addEventListener(Event.ENTER_FRAME, onDownEnter);
                        stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
                        function onDownEnter(evt:Event):void {
                        var sp = this.mouseY - prevY;
                        scroll_mc.y += sp;
                        if (scroll_mc.y < (HEIGHT-scroll_mc.height)) {
                        scroll_mc.y = (HEIGHT-scroll_mc.height);
                        else if (scroll_mc.y > 0) {
                        scroll_mc.y = 0;
                        speedArray.push(sp);
                        speedArray.shift();
                        prevY = this.mouseY;
                        function onUp(evt:MouseEvent):void {
                        stage.removeEventListener(Event.ENTER_FRAME, onDownEnter);
                        stage.removeEventListener(MouseEvent.MOUSE_UP, onUp);
                        speed = 0;
                        for (var i:int = 0; i<speedArray.length; i++) {
                        speed += speedArray[i];
                        speed /= speedArray.length;
                        addEventListener(Event.ENTER_FRAME, onEnter);
                        function onEnter(evt:Event):void {
                        if (Math.abs(speed) < .5) {
                        speed = 0;
                        if (speed < 0) {
                        if (scroll_mc.y > (HEIGHT-scroll_mc.height) - speed) {
                        scroll_mc.y += speed;
                        speed -= speed/DRAG;
                        else {
                        scroll_mc.y = (HEIGHT-scroll_mc.height);
                        speed = 0;
                        else {
                        if (scroll_mc.y < 0-speed) {
                        scroll_mc.y += speed;
                        speed -= speed/DRAG;
                        else {
                        scroll_mc.y = 0;
                        speed = 0;
                        public function itemClick(event:Event):void{
                                  setupControls();
                        public function onMetaData(dataObj:Object):void {
                                  ; // Do nothing.
                        public function onXMPData(dataObj:Object):void {
                                  ; // Do nothing.
                        public function statusUpdated(e:NetStatusEvent):void {
                                  if(e.info.code == "NetStream.Play.Stop")
                                            showBtns(["playBtn"]);
                        public function setupControls():void {
                        controls.playBtn.addEventListener(MouseEvent.MOUSE_UP, playVideo);
                        controls.restartBtn.addEventListener(MouseEvent.MOUSE_UP, restartVideo);
                        controls.resumeBtn.addEventListener(MouseEvent.MOUSE_UP, resumeVideo);
                                  stage.addEventListener(MouseEvent.MOUSE_UP, pauseVideo);
                                  showBtns(["playBtn"]);
                                                      public function playVideo(e:MouseEvent):void {
                                                                VIDEO_URL = "http://www.tovale.co.il/ktantanim/"+song_number
                                                                netStream.play(VIDEO_URL);
                                                                hideBtns();
                                                                e.stopPropagation();
                                                                trace(VIDEO_URL)
                                                                trace(song_number)
                        public function pauseVideo(e:MouseEvent):void {
                                  if(controls.visible == false)
                                            netStream.pause();
                                            showBtns(["resumeBtn", "restartBtn"]);
                        public function restartVideo(e:MouseEvent):void {
                                  netStream.seek(0);
                                  netStream.resume();
                                  hideBtns();
                                  e.stopPropagation();
                        public function resumeVideo(e:MouseEvent):void {
                                 // netStream.resume();
                                                                           netStream.close()
                                                                           video.clear()
                                 hideBtns();
                                 e.stopPropagation();
                                                                           gotoAndStop(1)
                                                                           next_frame2(e:MouseEvent):void
                        public function hideBtns():void {
                                  controls.visible = false;
                                  blocker.visible = false;
                        public function showBtns(btns:Array):void {
                                  controls.visible = true;
                                  blocker.visible = true;
                                  for(var instName:String in controls)
                                            if(btns.indexOf(instName) != -1)
                                                      controls[instName].visible = true;
                                            else
                                                      controls[instName].visible = false;

  • Next previous button in gallery

    Hi guys, been a while, hope everyone is well.  I am having a problem implementing a next/previous button on an image once it has been enlarged in my gallery.  I have done it in pure as3 but all tutorials seem to use the timeline.  I will post my code underneath so you can see what I am up too.  The next/previous button should I think be added to the modelClicked function.
    From what I understand, I will get a next/previous button and turn them into a button object.  I will then delete them from my stage and instantiate them within the class below.  I would then add them to the modelClicked function with events tied to them.  What should I then do in these events to make it fit in with the code below?
    Any advise appreciated,
    Cheers
    Nick
    package classes.models
        import flash.display.Bitmap;
        import flash.display.Loader;
        import flash.display.MovieClip;
        import flash.display.Sprite;
        import flash.geom.Rectangle;
        import flash.events.MouseEvent;
        import flash.events.Event;
        import flash.net.URLRequest;
        import eu.flashlabs.ui.BasicButton;
        import classes.ui.StateClip;
        import classes.ui.Placeholder;
        import classes.utils.URLUtil;
        import classes.vo.ModelsStates;
        import fl.containers.ScrollPane;
        import fl.controls.ProgressBar;
        import com.greensock.TweenLite;
        public class IndividualModel extends StateClip
            // CONSTANTS
            private static const PADDING_TOP:Number= 28;
            private static const PADDING_LEFT:Number= 50;
            private static const COLS:int= 4;
            private static const ROWS:int= 8;
            private static const GAP_HORIZONTAL:Number= 5;
            private static const GAP_VERTICAL:Number= 5;
            // MEMBER VARIABLES
            private var _data:XML;
            public function get data():XML
                return _data;
            public function set data(value:XML):void
                setData(value);
            private var items:Array;
            private var backBtn:BasicButton;
            private var itemsHolder:MovieClip;
            private var loadIndex:int;
            private var sp:ScrollPane;
            private var clonedBitmap:Bitmap;
            private var originalBitmap:Bitmap;
            private var rect:Rectangle;
            private var screen:Sprite = new Sprite();
            public function IndividualModel()
                super();
                items = [];
                addEventListener(Event.ADDED_TO_STAGE, addedToStageHandler);
            private function addedToStageHandler(event:Event):void
                initChildren();
            private function initChildren():void
                itemsHolder = new MovieClip();
                addChild(itemsHolder);
                sp = getChildByName("mc_pane") as ScrollPane;
                backBtn = getChildByName("btn_back") as BasicButton;
                backBtn.addEventListener(MouseEvent.CLICK, backBtn_clickHandler);
                screen.graphics.beginFill(0x111111, .75);
                screen.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
                screen.graphics.endFill();
            public function destroy():void
                clearItems();
            // PUBLIC INTERFACE
            // LAYOUT
            private function clearItems():void
                while (items.length > 0)
                    var item:ModelsItem = items.pop() as ModelsItem;
                    itemsHolder.removeChild(item);
                    item.destroy();
            private function populateItems():void
                for (var i:int = 0; i < Math.min(COLS * ROWS, data.picture.length()); i++)
                    var item:ModelsItem = new ModelsItem();
                    item.data = data.picture[i];
                    item.x = PADDING_LEFT + (i % COLS) * (ModelsItem.ITEM_WIDTH + GAP_HORIZONTAL);
                    item.y = PADDING_TOP + Math.floor(i / COLS) * (ModelsItem.ITEM_HEIGHT + GAP_VERTICAL);
                    /*item.addEventListener(MouseEvent.CLICK, modelClicked);*/
                    itemsHolder.addChild(item);
                    /*item.mouseEnabled = false;*/
                    sp.source = itemsHolder;
                    items.push(item);
                sp.verticalScrollPolicy = "on";
                sp.horizontalScrollPolicy = "off";
                sp.update();
            // PICTURE LOADING
            private function loadNextPicture():void
                if (loadIndex < items.length)
                    var loader:Loader = new Loader();
                    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadNextPicture_completeHandler);
                    var item:ModelsItem = items[loadIndex] as ModelsItem;
                    loader.load(new URLRequest(URLUtil.getURL([email protected]())));
                    /*item.mouseEnabled = true;*/
            private function loadNextPicture_completeHandler(event:Event):void
                event.target.removeEventListener(Event.COMPLETE, loadNextPicture_completeHandler);
                ModelsItem(items[loadIndex]).bitmap = event.target.content as Bitmap;
                ModelsItem(items[loadIndex]).addEventListener(MouseEvent.CLICK, modelClicked);
                loadIndex++;
                loadNextPicture();
            // EVENT HANDLERS
            private function backBtn_clickHandler(event:MouseEvent):void
                state = ModelsStates.HIDDEN;
            private function modelClicked(e:MouseEvent):void
                stage.addChild(screen);
                var item:ModelsItem = e.currentTarget as ModelsItem;
                originalBitmap = item.bitmap;
                clonedBitmap = new Bitmap(originalBitmap.bitmapData.clone());
                stage.addChild(clonedBitmap);
                rect = originalBitmap.getBounds(stage);
                clonedBitmap.x = rect.x;
                clonedBitmap.y = rect.y;
                clonedBitmap.width = rect.width;
                clonedBitmap.height = rect.height;
                clonedBitmap.smoothing = true;
                TweenLite.to(clonedBitmap, 1, { x: (stage.stageWidth - originalBitmap.width) / 4, y: (stage.stageHeight - originalBitmap.height) / 6, onComplete:zoomInFinished, scaleX: 1, scaleY: 1 });
            private function zoomInFinished():void
                trace("Zoom In Finished");
                stage.addEventListener(MouseEvent.CLICK, mouseClicked);
            private function mouseClicked(e:MouseEvent):void
                TweenLite.to(clonedBitmap, 1, { x: rect.x, y: rect.y, onComplete:zoomOutFinished, width: rect.width, height: rect.height});
                stage.removeEventListener(MouseEvent.CLICK, mouseClicked);
            private function zoomOutFinished():void
                trace("Mouse Clicked");
                stage.removeChild(screen);
                stage.removeChild(clonedBitmap);
            // GETTERS & SETTERS
            private function setData(value:XML):void
                _data = value;
                clearItems();
                populateItems();
                loadIndex = 0;
                loadNextPicture();
                state = ModelsStates.SHOWN;
            // UTILS
            override protected function animateInComplete():void
                super.animateInComplete();
                switch (state)
                    case ModelsStates.SHOWN :
                        break;
                    case ModelsStates.HIDDEN :
                        break;

    I don't actually know how you're loading your data.  It's also very difficult to figure out what's happening in your code, since you're extending Classes you don't show. What I can tell you is that you need to store the data about iterating each collection at the level where it's needed. You may want to look at the composite pattern http://www.as3dp.com/2007/05/composite-pattern-book-part-1/ .
    In my opinion, the biggest problem you have is poor separation of concerns--you call things Models that are clearly Views, and because you are storing relevant data in Views rather than simply using your Views to represent data, you're making the task of representing and iterating through your data much harder than it needs to be.
    The ideal structure would be a data structure that has data for each thumbnail in some sort of collection, like an Array or Vector. This data structure would only be responsible for storing the data and maintaining a pointer to the currently selected thumbnail.  When the pointer changes, the data object dispatches a change event, so Views that care about this pointer can update. Each piece of data could then have a member variable that is one of these collections that manages the correct pointer.  That's where the composite pattern comes in.
    Now, the task of building your Views becomes much easier. You have one View that gets a collection and shows all the thumbnails and one View that gets a specific thumbnail, mix and match as needed. The Views, again watch the change event and do whatever they need to do when the pointer changes.
    At this point, who sets the pointer ceases to matter. It can be inside one of your Views or outside any of your Views--when the pointer changes, the View that is watching that particular collection will update, and if the result of that update is that a nested View then watches a different collection, that's ok--it still follows the same principles.

  • How do I make a SEARCH button an image

    Does anyone know or can point me to a source how to implement
    a custom designed image into a SEARCH button.
    I found out how to make it a standard button but can not find
    a way to customize it.
    I am working in DW MX 2004

    Why don't you use scrollpane
    import fl.containers.ScrollPane;
    var myScrollPane:ScrollPane = new ScrollPane();
    myScrollPane.source = "http://localhost/strategist/images/image0.gif";
    addChild(myScrollPane);

  • Simple add child issue

    stupidly i try to add child mc "green" to "scroll_mc", but green is not visible.
    package {
              import fl.containers.ScrollPane;
              import fl.controls.ScrollPolicy;
              import flash.desktop.NativeApplication;
              import flash.desktop.SystemIdleMode;
              import flash.display.MovieClip;
              import flash.media.Video;
              import flash.net.NetConnection;
              import flash.net.NetStream;
              import flash.events.MouseEvent;
              import flash.events.NetStatusEvent;
              import fl.controls.List
              import flash.events.Event;
                        public class Main extends MovieClip {
                                  private var song:Array=["lego.flv","hatizmoret.flv","shir_hageshem.flv","ez.flv","tarnegol.flv","se_u gdi.flv","dag.flv","lizard.flv","toy_train_set_qt.flv","hadubim.flv","geveret_shfanfana.fl v",
                                                                                                        "parash_ben_hail.flv","snake.flv","pil_ pilon.flv","cat.flv","gan_shelanu.flv","purrfect_birthday_qt.flv","nadneda.flv","hatul_gan av.flv",
                                                                                                        "yonatan_hakatan.flv","dog.flv","aviron .flv","zipor.flv","hipo.flv","ladod_moshe.flv","shafan.flv","hipushit.flv","achbar.flv","t olaat.flv","zefardea.flv","dov.flv",
                                                                                                        "shaon_ben_hail.flv","kof.flv","hayom_y om_huledet.flv","ima_yekara.flv","oniya.flv","bee_and_flowers_qt.flv ","hasida.flv","ima_avaza.flv","yedidi_tintan.flv","donkey.flv",
                                                                                                        "haoto_shelanu.flv","bimdinat_hagamadim .flv"]
                        public var song_number:String
                        private var netConnection:NetConnection;
                        private var netStream:NetStream;
                        private var video:Video;
                        private var VIDEO_URL:String;
                        public var speed:Number;
      public var speedArray:Array;
      public var prevY:Number;
                        public var DRAG:Number = 20;
                        public var HEIGHT:int = 310;
                        public function Main() {
                                  public var scroll_mc:MovieClip
                                  public var Green:MovieClip=new green()
                                  public var posX:int= 10;
                                  public var posY:int =20;
                                  scroll_mc.addChild(Green)
                                  Green.x=posX
                                  Green.y=posY
                                  trace(Green.x)
                                  scroll_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
                                  NativeApplication.nativeApplication.systemIdleMode = SystemIdleMode.KEEP_AWAKE;
                                  netConnection = new NetConnection();
                                  netConnection.connect(null);
                                  netStream = new NetStream(netConnection);
                                  netStream.client = this;
                                  netStream.addEventListener(NetStatusEvent.NET_STATUS, statusUpdated);
                                  video = new Video();
                                  video.attachNetStream(netStream);
                                  video.width = 480;
                                  video.height = 320;
                                  addChildAt(video, 0);
                        private function  fl_ClickToGoToAndStopAtFrame_2(event:MouseEvent):void
              gotoAndStop(2);
                        function onDown(evt:MouseEvent):void {
                        speedArray = new Array(0,0,0,0,0,0,0,0,0,0);
                        speed = 0;
                        prevY = this.mouseY;
                        stage.addEventListener(Event.ENTER_FRAME, onDownEnter);
                        stage.addEventListener(MouseEvent.MOUSE_UP, onUp);
                        function onDownEnter(evt:Event):void {
                        var sp = this.mouseY - prevY;
                        scroll_mc.y += sp;
                        if (scroll_mc.y < (HEIGHT-scroll_mc.height)) {
                        scroll_mc.y = (HEIGHT-scroll_mc.height);
                        else if (scroll_mc.y > 0) {
                        scroll_mc.y = 0;
                        speedArray.push(sp);
                        speedArray.shift();
                        prevY = this.mouseY;
                        function onUp(evt:MouseEvent):void {
                        stage.removeEventListener(Event.ENTER_FRAME, onDownEnter);
                        stage.removeEventListener(MouseEvent.MOUSE_UP, onUp);
                        speed = 0;
                        for (var i:int = 0; i<speedArray.length; i++) {
                        speed += speedArray[i];
                        speed /= speedArray.length;
                        addEventListener(Event.ENTER_FRAME, onEnter);
                        function onEnter(evt:Event):void {
                        if (Math.abs(speed) < .5) {
                        speed = 0;
                        if (speed < 0) {
                        if (scroll_mc.y > (HEIGHT-scroll_mc.height) - speed) {
                        scroll_mc.y += speed;
                        speed -= speed/DRAG;
                        else {
                        scroll_mc.y = (HEIGHT-scroll_mc.height);
                        speed = 0;
                        else {
                        if (scroll_mc.y < 0-speed) {
                        scroll_mc.y += speed;
                        speed -= speed/DRAG;
                        else {
                        scroll_mc.y = 0;
                        speed = 0;
                        public function itemClick(event:Event):void{
                                  if(event.target.selectedItem.label==" קוביות לי יש"){
                                            gotoAndStop(2)
                                            song_number=song[0]
                                  if(event.target.selectedItem.label=="התזמורת"){
                                            gotoAndStop(2)
                                            song_number=song[1]
                                  if(event.target.selectedItem.label=="שי ר הגשם"){
                                            gotoAndStop(2)
                                            song_number=song[2]
                                  if(event.target.selectedItem.label==" יש לנו תיש "){
                                            gotoAndStop(2)
                                            song_number=song[3]
                                  if(event.target.selectedItem.label==" גברת תרנגולת "){
                                            gotoAndStop(2)
                                            song_number=song[4]
                                  if(event.target.selectedItem.label==" שה וגדי"){
                                            gotoAndStop(2)
                                            song_number=song[5]
                                  if(event.target.selectedItem.label==" דג קטן"){
                                            gotoAndStop(2)
                                            song_number=song[6]
                                  if(event.target.selectedItem.label==" הלטאה"){
                                            gotoAndStop(2)
                                            song_number=song[7]
                                  if(event.target.selectedItem.label==" הנה באה הרכבת"){
                                            gotoAndStop(2)
                                            song_number=song[8]
                                  if(event.target.selectedItem.label=="הדובים"){
                                            gotoAndStop(2)
                                            song_number=song[9]
                                  if(event.target.selectedItem.label==" לשפן יש בית"){
                                            gotoAndStop(2)
                                            song_number=song[10]
                                  if(event.target.selectedItem.label==" רוץ בן סוסי"){
                                            gotoAndStop(2)
                                            song_number=song[11]
                                  if(event.target.selectedItem.label==" הנחש"){
                                            gotoAndStop(2)
                                            song_number=song[12]
                                  /*if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  if(event.target.selectedItem.label==" במדינת הגמדים"){
                                            gotoAndStop(2)
                                            song_number=song[42]
                                  setupControls();
                        public function onMetaData(dataObj:Object):void {
                                  ; // Do nothing.
                        public function onXMPData(dataObj:Object):void {
                                  ; // Do nothing.
                        private function statusUpdated(e:NetStatusEvent):void {
                                  if(e.info.code == "NetStream.Play.Stop")
                                            showBtns(["playBtn"]);
                        private function setupControls():void {
                                  controls.playBtn.addEventListener(MouseEvent.MOUSE_UP, playVideo);
                                  controls.restartBtn.addEventListener(MouseEvent.MOUSE_UP, restartVideo);
                                  controls.resumeBtn.addEventListener(MouseEvent.MOUSE_UP, resumeVideo);
                                  stage.addEventListener(MouseEvent.MOUSE_UP, pauseVideo);
                                  showBtns(["playBtn"]);
    private function playVideo(e:MouseEvent):void {
    VIDEO_URL = "http://www.tovale.co.il/ktantanim/"+song_number
    netStream.play(VIDEO_URL);
    hideBtns();
    e.stopPropagation();
    trace(VIDEO_URL)
    trace(song_number)
                        private function pauseVideo(e:MouseEvent):void {
                                  if(controls.visible == false)
                                            netStream.pause();
                                            showBtns(["resumeBtn", "restartBtn"]);
                        private function restartVideo(e:MouseEvent):void {
                                  netStream.seek(0);
                                  netStream.resume();
                                  hideBtns();
                                  e.stopPropagation();
                        private function resumeVideo(e:MouseEvent):void {
                                  netStream.resume();
                                  hideBtns();
                                  e.stopPropagation();
                        private function hideBtns():void {
                                  controls.visible = false;
                                  blocker.visible = false;
                        private function showBtns(btns:Array):void {
                                  controls.visible = true;
                                  blocker.visible = true;
                                  for(var instName:String in controls)
                                            if(btns.indexOf(instName) != -1)
                                                      controls[instName].visible = true;
                                            else
                                                      controls[instName].visible = false;

    You should be declaring your public variables in the public space like the rest... otherwise they only have scope within the function you place them in.
    You declare a scroll_mc but you do not create an instance of it.
    You should explain more about the problem and only include the code that is relevant to it.

  • Accordion inside a scrollPane

    I need to put an accordion in a scrollPane. The only way I
    can figure out how to do it is to have an empty movieclip in the
    library, then set that as the contentPath of my scrollPane and
    creating an accordion inside.
    The problem is that if my accordion has 2 or more children or
    segments, there is a giant space after the accordion in the
    scrollPane that I can't get rid of.
    Here is my code:
    import mx.containers.Accordion;
    thisScroll.contentPath = "emptyMC";
    scrollContent = thisScroll.content;
    scrollContent.createClassObject(mx.containers.Accordion,
    "my_acc", scrollContent.getNextHighestDepth());
    thisAccordion = scrollContent.my_acc;
    thisAccordion.createChild("", "panel1", "first panel");
    thisAccordion.createChild("", "panel2", "second panel");
    Can any body help?

    I need to put an accordion in a scrollPane. The only way I
    can figure out how to do it is to have an empty movieclip in the
    library, then set that as the contentPath of my scrollPane and
    creating an accordion inside.
    The problem is that if my accordion has 2 or more children or
    segments, there is a giant space after the accordion in the
    scrollPane that I can't get rid of.
    Here is my code:
    import mx.containers.Accordion;
    thisScroll.contentPath = "emptyMC";
    scrollContent = thisScroll.content;
    scrollContent.createClassObject(mx.containers.Accordion,
    "my_acc", scrollContent.getNextHighestDepth());
    thisAccordion = scrollContent.my_acc;
    thisAccordion.createChild("", "panel1", "first panel");
    thisAccordion.createChild("", "panel2", "second panel");
    Can any body help?

  • Custom graphics in java.awt.ScrollPane

    Hi all,
    I have to draw a custom created image in a scroll pane. As the image is very large I want to display it in a scroll pane. As parts of the image may change within seconds, and drawing the whole image is very time consuming (several seconds) I want to draw only the part of the image that is currently visible to the user.
    My idea: creating a new class that extends from java.awt.ScrollPane, overwrite the paint(Graphics) method and do the drawings inside. Unfortunately, it does not work. The background of the scoll pane is blue, but it does not show the red box (the current viewport is not shown in red).
    Below please find the source code that I am using:
    package graphics;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.ScrollPane;
    import java.awt.event.AdjustmentEvent;
    public class CMyComponent extends ScrollPane {
         /** <p>Listener to force a component to repaint when a scroll bar changes its
          * position.</p>
         private final class ScrollBarAdjustmentListener implements java.awt.event.AdjustmentListener {
              /** <p>The component to force to repaint.</p> */
              private final Component m_Target;
              /** <p>Default constructor.</p>
               * @param Target The component to force to repaint.
              private ScrollBarAdjustmentListener(Component Target) { m_Target = Target; }
              /** <p>Forces to component to repaint upon adjustment of the scroll bar.</p>
               *  @see java.awt.event.AdjustmentListener#adjustmentValueChanged(java.awt.event.AdjustmentEvent)
              public void adjustmentValueChanged(AdjustmentEvent e) { m_Target.paint(m_Target.getGraphics()); }
         public CMyComponent() {
              // Ensure that the component repaints upon changing of the scroll bars
              ScrollBarAdjustmentListener sbal = new ScrollBarAdjustmentListener(this);
              getHAdjustable().addAdjustmentListener(sbal);
              getVAdjustable().addAdjustmentListener(sbal);
         public void paint(Graphics g) {
              setBackground(Color.BLUE);
              g.setColor(Color.RED);
              g.fillRect(getScrollPosition().x, getScrollPosition().y, getViewportSize().width, getViewportSize().height);
         public final static void main(String[] args) {
              java.awt.Frame f = new java.awt.Frame();
              f.add(new CMyComponent());
              f.pack();
              f.setVisible(true);
    }

    Dear all,
    I used the last days and tried several things. I think now I have a quite good working solution (just one bug remains) and it is very performant. To give others a chance to see what I have done I post the source code of the main class (a canvas drawing and implementing scrolling) here. As soon as the sourceforge project is accepted, I will publish the whole sources at there. Enjoy. And if you have some idea for my last bug in getElementAtPixel(Point), then please tell me.
    package internetrail.graphics.hexgrid;
    import java.awt.Canvas;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Image;
    import java.awt.Point;
    import java.awt.Polygon;
    import java.awt.event.ComponentEvent;
    import java.awt.event.ComponentListener;
    import java.awt.geom.Area;
    import java.awt.image.BufferedImage;
    import java.util.WeakHashMap;
    import java.util.Map;
    /** <p>Hex grid view.</p>
    * <p>Visualizes a {@link IHexGridModel}.</p>
    * @version 0.1, 03.06.2006
    * @author Bjoern Wuest, Germany
    public final class CHexGridView extends Canvas implements ComponentListener, IHexGridElementListener {
         /** <p>Serial version unique identifier.</p> */
         private static final long serialVersionUID = -965902826101261530L;
         /** <p>Instance-constant parameter for the width of a hex grid element.</p> */
         public final int CONST_Width;
         /** <p>Instance-constant parameter for 1/4 of the width of a hex grid element.</p> */
         public final int CONST_Width1fourth;
         /** <p>Instance-constant parameter for 3/4 of the width of a hex grid element.</p> */
         public final int CONST_Width3fourth;
         /** <p>Instance-constant parameter for 1.5 times of the width of a hex grid element.</p> */
         public final int CONST_Width1dot5;
         /** <p>Instance-constant parameter for 4 times of the width of a hex grid element.</p> */
         public final int CONST_Widthquad;
         /** <p>Instance-constant parameter for the height of a hex grid element.</p> */
         public final int CONST_Height;
         /** <p>Instance-constant parameter for 1/2 of the height of a hex grid element.</p> */
         public final int CONST_Heighthalf;
         /** <p>Instance-constant parameter for the double height of a hex grid element.</p> */
         public final int CONST_Heightdouble;
         /** <p>The steepness of a side of the hex grid element (calculated for the upper left arc).</p> */
         public final double CONST_Steepness;
         /** <p>The model of this hex grid </p> */
         private final IHexGridModel m_Model;
         /** <p>A cache for already created images of the hex map.</p> */
         private final Map<Point, Image> m_Cache = new WeakHashMap<Point, Image>();
         /** <p>The graphical area to draw the selection ring around a hex element.</p> */
         private final Area m_SelectionRing;
         /** <p>The image of the selection ring around a hex element.</p> */
         private final BufferedImage m_SelectionRingImage;
         /** <p>The current position of the hex grid in pixels (top left visible corner).</p> */
         private Point m_ScrollPosition = new Point(0, 0);
         /** <p>Flag to define if a grid is shown ({@code true}) or not ({@code false}).</p> */
         private boolean m_ShowGrid = true;
         /** <p>Flag to define if the selected hex grid element should be highlighted ({@code true}) or not ({@code false}).</p> */
         private boolean m_ShowSelected = true;
         /** <p>The offset of hex grid elements shown on the screen, measured in hex grid elements.</p> */
         private Point m_CurrentOffset = new Point(0, 0);
         /** <p>The offset of the image shown on the screen, measured in pixels.</p> */
         private Point m_PixelOffset = new Point(0, 0);
         /** <p>The index of the currently selected hex grid element.</p> */
         private Point m_CurrentSelected = new Point(0, 0);
         /** <p>The width of a buffered pre-calculated image in pixel.</p> */
         private int m_ImageWidth;
         /** <p>The height of a buffered pre-calculated image in pixel.</p> */
         private int m_ImageHeight;
         /** <p>The maximum number of columns of hex grid elements to be shown at once on the screen.</p> */
         private int m_MaxColumn;
         /** <p>The maximum number of rows of hex grid elements to be shown at once on the screen.</p> */
         private int m_MaxRow;
         /** <p>Create a new hex grid view.</p>
          * <p>The hex grid view is bound to a {@link IHexGridModel} and registers at
          * that model to listen for {@link IHexGridElement} updates.</p>
          * @param Model The model backing this view.
         public CHexGridView(IHexGridModel Model) {
              // Set the model
              m_Model = Model;
              CONST_Width = m_Model.getElementsWidth();
              CONST_Height = m_Model.getElementsHeight();
              CONST_Width1fourth = CONST_Width/4;
              CONST_Width3fourth = CONST_Width*3/4;
              CONST_Width1dot5 = CONST_Width*3/2;
              CONST_Heighthalf = CONST_Height/2;
              CONST_Widthquad = CONST_Width*4;
              CONST_Heightdouble = CONST_Height*2;
              CONST_Steepness = (double)CONST_Heighthalf / CONST_Width1fourth;
              m_ImageWidth = getSize().width+CONST_Widthquad;
              m_ImageHeight = getSize().height+CONST_Heightdouble;
              m_MaxColumn = m_ImageWidth / CONST_Width3fourth;
              m_MaxRow = m_ImageHeight / CONST_Height;
              // Register this canvas for various notifications
              m_Model.addElementListener(this);
              addComponentListener(this);
              // Create the selection ring to highlight hex grid elements
              m_SelectionRing = new Area(new Polygon(new int[]{-1, CONST_Width1fourth-1, CONST_Width3fourth+1, CONST_Width+1, CONST_Width3fourth+1, CONST_Width1fourth-1}, new int[]{CONST_Heighthalf, -1, -1, CONST_Heighthalf, CONST_Height+1, CONST_Height+1}, 6));
              m_SelectionRing.subtract(new Area(new Polygon(new int[]{2, CONST_Width1fourth+2, CONST_Width3fourth-2, CONST_Width-2, CONST_Width3fourth-2, CONST_Width1fourth+2}, new int[]{CONST_Heighthalf, 2, 2, CONST_Heighthalf, CONST_Height-2, CONST_Height-2}, 6)));
              m_SelectionRingImage = new BufferedImage(CONST_Width, CONST_Height, BufferedImage.TYPE_INT_ARGB);
              Graphics2D g = m_SelectionRingImage.createGraphics();
              g.setColor(Color.WHITE);
              g.fill(m_SelectionRing);
         @Override public synchronized void paint(Graphics g2) {
              // Caculate the offset of indexes to show
              int offsetX = 2 * (m_ScrollPosition.x / CONST_Width1dot5) - 2;
              int offsetY = (int)(Math.ceil(m_ScrollPosition.y / CONST_Height) - 1);
              m_CurrentOffset = new Point(offsetX, offsetY);
              // Check if the image is in the cache
              Image drawing = m_Cache.get(m_CurrentOffset);
              if (drawing == null) {
                   // The image is not cached, so draw it
                   drawing = new BufferedImage(m_ImageWidth, m_ImageHeight, BufferedImage.TYPE_INT_ARGB);
                   Graphics2D g = ((BufferedImage)drawing).createGraphics();
                   // Draw background
                   g.setColor(Color.BLACK);
                   g.fillRect(0, 0, m_ImageWidth, m_ImageHeight);
                   // Draw the hex grid
                   for (int column = 0; column <= m_MaxColumn; column += 2) {
                        for (int row = 0; row <= m_MaxRow; row++) {
                             // Draw even column
                             IHexGridElement element = m_Model.getElementAt(offsetX + column, offsetY + row);
                             if (element != null) { g.drawImage(element.getImage(m_ShowGrid), (int)(column*(CONST_Width3fourth-0.5)), CONST_Height*row, null); }
                             // Draw odd column
                             element = m_Model.getElementAt(offsetX + column+1, offsetY + row);
                             if (element!= null) { g.drawImage(element.getImage(m_ShowGrid), (int)(column*(CONST_Width3fourth-0.5)+CONST_Width3fourth), CONST_Heighthalf*(row*2+1), null); }
                   // Put the image into the cache
                   m_Cache.put(m_CurrentOffset, drawing);
              // Calculate the position of the image to show
              offsetX = CONST_Width1dot5 + (m_ScrollPosition.x % CONST_Width1dot5);
              offsetY = CONST_Height + (m_ScrollPosition.y % CONST_Height);
              m_PixelOffset = new Point(offsetX, offsetY);
              g2.drawImage(drawing, -offsetX, -offsetY, null);
              // If the selected element should he highlighted, then do so
              if (m_ShowSelected) {
                   // Check if the selected element is on screen
                   if (isElementOnScreen(m_CurrentSelected)) {
                        // Correct vertical offset for odd columns
                        if ((m_CurrentSelected.x % 2 == 1)) { offsetY -= CONST_Heighthalf; }
                        // Draw the selection circle
                        g2.drawImage(m_SelectionRingImage, (m_CurrentSelected.x - m_CurrentOffset.x) * CONST_Width3fourth - offsetX - ((m_CurrentSelected.x + 1) / 2), (m_CurrentSelected.y - m_CurrentOffset.y) * CONST_Height - offsetY, null);
         @Override public synchronized void update(Graphics g) { paint(g); }
         public synchronized void componentResized(ComponentEvent e) {
              // Upon resizing of the component, adjust several pre-calculated values
              m_ImageWidth = getSize().width+CONST_Widthquad;
              m_ImageHeight = getSize().height+CONST_Heightdouble;
              m_MaxColumn = m_ImageWidth / CONST_Width3fourth;
              m_MaxRow = m_ImageHeight / CONST_Height;
              // And flush the cache
              m_Cache.clear();
         public void componentMoved(ComponentEvent e) { /* do nothing */ }
         public void componentShown(ComponentEvent e) { /* do nothing */ }
         public void componentHidden(ComponentEvent e) { /* do nothing */ }
         public synchronized void elementUpdated(IHexGridElement Element) {
              // Clear cache where the element may be contained at
              for (Point p : m_Cache.keySet()) { if (isElementInScope(Element.getIndex(), p, new Point(p.x + m_MaxColumn, p.y + m_MaxRow))) { m_Cache.remove(p); } }
              // Update the currently shown image if the update element is shown, too
              if (isElementOnScreen(Element.getIndex())) { repaint(); }
         /** <p>Returns the model visualized by this grid view.</p>
          * @return The model visualized by this grid view.
         public IHexGridModel getModel() { return m_Model; }
         /** <p>Returns the current selected hex grid element.</p>
          * @return The current selected hex grid element.
         public IHexGridElement getSelected() { return m_Model.getElementAt(m_CurrentSelected.x, m_CurrentSelected.y); }
         /** <p>Sets the current selected hex grid element by its index.</p>
          * <p>If the selected hex grid element should be highlighted and is currently
          * shown on the screen, then this method will {@link #repaint() redraw} this
          * component automatically.</p>
          * @param Index The index of the hex grid element to become the selected one.
          * @throws IllegalArgumentException If the index refers to a non-existing hex
          * grid element.
         public synchronized void setSelected(Point Index) throws IllegalArgumentException {
              // Check that the index is valid
              if ((Index.x < 0) || (Index.y < 0) || (Index.x > m_Model.getXElements()) || (Index.y > m_Model.getYElements())) { throw new IllegalArgumentException("There is no hex grid element with such index."); }
              m_CurrentSelected = Index;
              // If the element is on screen and should be highlighted, then repaint
              if (m_ShowSelected && isElementOnScreen(m_CurrentSelected)) { repaint(); }
         /** <p>Moves the visible elements to the left by the number of pixels.</p>
          * <p>To move the visible elements to the left by one hex grid element, pass
          * {@link #CONST_Width3fourth} as the parameter. The component will
          * automatically {@link #repaint()}.</p>
          * @param Pixels The number of pixels to move to the left.
          * @return The number of pixels moved to the left. This is always between 0
          * and {@code abs(Pixels)}.
         public synchronized int moveLeft(int Pixels) {
              int delta = m_ScrollPosition.x - Math.max(0, m_ScrollPosition.x - Math.max(0, Pixels));
              if (delta != 0) {
                   m_ScrollPosition.x -= delta;
                   repaint();
              return delta;
         /** <p>Moves the visible elements up by the number of pixels.</p>
          * <p>To move the visible elements up by one hex grid element, pass {@link
          * #CONST_Height} as the parameter. The component will automatically {@link
          * #repaint()}.</p>
          * @param Pixels The number of pixels to move up.
          * @return The number of pixels moved up. This is always between 0 and {@code
          * abs(Pixels)}.
         public synchronized int moveUp(int Pixels) {
              int delta = m_ScrollPosition.y - Math.max(0, m_ScrollPosition.y - Math.max(0, Pixels));
              if (delta != 0) {
                   m_ScrollPosition.y -= delta;
                   repaint();
              return delta;
         /** <p>Moves the visible elements to the right by the number of pixels.</p>
          * <p>To move the visible elements to the right by one hex grid element, pass
          * {@link #CONST_Width3fourth} as the parameter. The component will
          * automatically {@link #repaint()}.</p>
          * @param Pixels The number of pixels to move to the right.
          * @return The number of pixels moved to the right. This is always between 0
          * and {@code abs(Pixels)}.
         public synchronized int moveRight(int Pixels) {
              int delta = Math.min(m_Model.getXElements() * CONST_Width3fourth + CONST_Width1fourth - getSize().width, m_ScrollPosition.x + Math.max(0, Pixels)) - m_ScrollPosition.x;
              if (delta != 0) {
                   m_ScrollPosition.x += delta;
                   repaint();
              return delta;
         /** <p>Moves the visible elements down by the number of pixels.</p>
          * <p>To move the visible elements down by one hex grid element, pass {@link
          * #CONST_Height} as the parameter. The component will automatically {@link
          * #repaint()}.</p>
          * @param Pixels The number of pixels to move down.
          * @return The number of pixels moved down. This is always between 0 and
          * {@code abs(Pixels)}.
         public synchronized int moveDown(int Pixels) {
              int delta = Math.min(m_Model.getYElements() * CONST_Height + CONST_Heighthalf - getSize().height, m_ScrollPosition.y + Math.max(0, Pixels)) - m_ScrollPosition.y;
              if (delta != 0) {
                   m_ScrollPosition.y += delta;
                   repaint();
              return delta;
         /** <p>Checks if the hex grid element of the given index is currently
          * displayed on the screen (even just one pixel).</p>
          * <p>The intention of this method is to check if a {@link #repaint()} is
          * necessary or not.</p>
          * @param ElementIndex The index of the element to check.
          * @return {@code true} if the hex grid element of the given index is
          * displayed on the screen, {@code false} if not.
         public synchronized boolean isElementOnScreen(Point ElementIndex) { return isElementInScope(ElementIndex, m_CurrentOffset, new Point(m_CurrentOffset.x + m_MaxColumn, m_CurrentOffset.y + m_MaxRow)); }
         /** <p>Checks if the hex grid element of the given index is within the given
          * indexes.</p>
          * <p>The intention of this method is to check if a {@link #repaint()} is
          * necessary or not.</p>
          * @param ElementIndex The index of the element to check.
          * @param ReferenceIndexLeftTop The left top index of the area to check.
          * @param ReferenceIndexRightBottom The right bottom index of the area to check.
          * @return {@code true} if the hex grid element of the given index is within
          * the given area, {@code false} if not.
         public synchronized boolean isElementInScope(Point ElementIndex, Point ReferenceIndexLeftTop, Point ReferenceIndexRightBottom) { if ((ElementIndex.x >= ReferenceIndexLeftTop.x) && (ElementIndex.x <= ReferenceIndexRightBottom.x) && (ElementIndex.y >= ReferenceIndexLeftTop.y) && (ElementIndex.y <= (ReferenceIndexRightBottom.y))) { return true; } else { return false; } }
         /** <p>Return the {@link IHexGridElement hex grid element} shown at the given
          * pixel on the screen.</p>
          * <p><b>Remark: There seems to be a bug in retrieving the proper element,
          * propably caused by rounding errors and unprecise pixel calculations.</p>
          * @param P The pixel on the screen.
          * @return The {@link IHexGridElement hex grid element} shown at the pixel.
         public synchronized IHexGridElement getElementAtPixel(Point P) {
              // @FIXME Here seems to be some bugs remaining
              int dummy = 0; // Variable for warning to indicate that there is something to do :)
              // Calculate the pixel on the image, not on the screen
              int px = P.x + m_PixelOffset.x;
              int py = P.y + m_PixelOffset.y;
              // Determine the x-index of the column (is maybe decreased by one)
              int x = px / CONST_Width3fourth + m_CurrentOffset.x;
              // If the column is odd, then shift the y-pixel by half element height
              if ((x % 2) == 1) { py -= CONST_Heighthalf; }
              // Determine the y-index of the row (is maybe decreased by one)
              int y = py / CONST_Height + m_CurrentOffset.y;
              // Normative coordinates to a single element
              px -= (x - m_CurrentOffset.x) * CONST_Width3fourth;
              py -= (y - m_CurrentOffset.y) * CONST_Height;
              // Check if the normative pixel is in the first quarter of a column
              if (px < CONST_Width1fourth) {
                   // Adjustments to the index may be necessary
                   if (py < CONST_Heighthalf) {
                        // We are in the upper half of a hex-element
                        double ty = CONST_Heighthalf - CONST_Steepness * px;
                        if (py < ty) { x--; }
                   } else {
                        // We are in the lower half of a hex-element
                        double ty = CONST_Heighthalf + CONST_Steepness * px;
                        if (py > ty) {
                             x--;
                             y++;
              return m_Model.getElementAt(x, y);
    }Ah, just to give you some idea: I use this component to visualize a hex grid map with more than 1 million grid elements. And it works, really fast, and requires less than 10 MByte of memory.

  • ScrollPane not disappearing after dynamic creation

    Gentlefolk;
    Have a movieclip that that has formatted text. This content
    is longer than the stage, so I thought of putting it in a
    scrollpane. Creating a dynamic text box kills the text formatting.
    The scrollpane has a name "my_SP". If I have this code on a
    button on the page where I want the content to reside, the
    following works:
    on (release) {
    my_SP.contentPath="StepAction_ID";
    BUT, place this same code on another button that is NOT on
    that page, and no content appears in the scrollbox, for example:
    on (release) {
    this.gotoAndStop(5);
    this.my_sp2.contentPath="StepAction_ID";
    Here I want Flash to go to frame 5 and place the content in
    StepAction_ID into the scrollbox "my_sp2". It does not populate.
    I CAN force the population by creating the scrollbox
    dynamically:
    on (release) {
    this.gotoAndStop(5);
    this.createClassObject(mx.containers.ScrollPane, "my_sp2",
    20);
    my_sp2.move(100, 200);
    my_sp2.setSize(400, 200);
    this.my_sp2.contentPath="StepAction_ID";
    BUT, when I click another button and go elsewhere in the
    file, the scrollbox remains, and I have text overwriting the
    scrollbox content.
    How can I get scrollbox content to stay on one frame?
    Many thanks!
    Don

    Hi,
    I have simulated your scenario. Schedule agreement schedule lines will not get added to MD05. this is always static.
    regards,
    Krishna Mohan

  • Scrolling multiple images in scrollPane

    Hey. I want to add multiple images (they are now in movie
    clips) to a scrollPane, and it's giving me more problems than I
    think it should. I thought of adding many images to one movie clip,
    but what I may end up doing is switching the order of the images
    several times, so I began to think of another way.
    What I have now is a scrollPane with two movie clips in it.
    They are on top of one another. I thought that I should be able to
    leave the y value of one at 0 and set the other so that it's 200
    and then they would scroll one after the other. I haven't been able
    to get this to work. Is this something that is do-able within a
    scrollPane, or not? I'm working the best I can with the AS, but
    it's still new to me.
    Thank you for your insight. Create a great day.

    Thank you, I’ve been working on trying your suggestion.
    I’ve been able to attach the movie to the first, however, the
    second movie is not showing up within the scroll pane. To
    complicate matters, the third movie also seems to cancel out the
    second, even when I attach the movie outside of the scrollPane. I
    have one layer, and the movie clips I’m working with are
    Image1_mc, Image2_mc, and Image3_mc.
    My script:
    this.createClassObject(mx.containers.ScrollPane, "my_sp",
    20);
    my_sp.move(0, 30);
    my_sp.setSize(650, 250);
    my_sp.contentPath = "Image1_mc";
    my_sp.attachMovie("Image2_mc", " Image2_mc", 0, {_x:0,
    _y:100});
    my_sp.attachMovie("Image3_mc", " Image3_mc",
    this.getNextHighestDepth(), {_x:0, _y:200});  variations of
    these two lines are what I’ve been tweaking
    var nstepListener:Object = new Object();
    nstepListener.change = function(evt_obj:Object) {
    my_sp.content._alpha = my_nstep.value;
    my_nstep.addEventListener("change", nstepListener);

Maybe you are looking for

  • Iview/ Page for Development plan

    Hi, I want to display/ maintain the Individual development plans in ESS. In backend its maintained using transaction PPDPIM. Does there exist any default page/Iview that i can use for this or I have to define a transactional oview. Please advice. Tha

  • Setting DOCTYPE in ALUI 6.1 - portalconfig.xml never worked

    Documentation for ALUI 6.1 says to specify DOCTYPE you set it in the portalconfig.xml. Well we've tried this, and all types of iterations - using preset integers they support and custom - and they never show up. Could this be because we're using Liqu

  • Email sending once a user is created?

    Hi Guys I have a requirement of sending emails to a user with his user name and password which we are generating with out his(the users) intervention. Please suggest you way to approach this requirement in OIM. IS the Add User task in Xellerate User

  • RedirectMatch equivalent command in Sun Webserver

    I am looking for a equivalent command for this in SUN Webserver. This command is specific to IBM HTTP server. RedirectMatch permanent ^/$ /content/common/index.jsp Purpose: One of our sites www.xyz.com is redicted to URL www.xyz.com/content/common/in

  • Flashing question mark during start up

    Hello, I have a mid-2007 mac mini and recently I upgraded the RAM to 2 GB from 1 GB (two flashes of 1GB each). When I open the mac mini, a flashing question mark appears. I' ve read the support thread from apple, but nothing helps. The only progress