Ensuring a static var stays updated

Sorry for spamming the boards but I have another question...
I want to get the index of the image currently in the center of the carousel and then I want to use this index number in other classes but it has to stay updated each time. I successfully managed to get the index of the image that is currently being clicked on (this image will then be moved to the center of the carousel so as long as one always clicks on an image at the start, my method will work ) but I dont know how to allow other classes to access this. I tried saving it as a static var and then trying to access it by using the following:
private var coverIndex : int = CoverFlow.selectedCoverIndex;
But I receive the error msg that selectedCoverIndex is not available to static class CoverFlow or something of that sort. This is what my CoverFlow code looks like (i.e. where I determine which image I want to position in the center):
public class CoverFlow extends Sprite {
  public var covers : Vector.<DisplayObject>;
  private var cover : DisplayObject;
  private var coverIndex : int;
  private static var selectedCoverIndex : int; // Create a static coverIndex so I can easily use this data for external classes
  private function show(id : uint) : void // e : Event
   for (var i : Number = 0;i < covers.length; i++)
    cover = covers[i];
    // Tried putting if i == id as last statment to stop website coming up automatically but it still does since it then loops through again.
    if (i < id)
     setChildIndex(cover, i);
     TweenLite.to(cover, tweenDuration, {x: (id - i + 1) * -coverDistance, z: coverZ, rotationY: -coverRotationY, ease:easing });
    } else if (i > id)
     setChildIndex(cover, covers.length - 1 - i);
     TweenLite.to(cover, tweenDuration, {x: ((i - id + 1) * coverDistance), z: coverZ, rotationY: coverRotationY, ease:easing });
    } else if(i == id)
     setChildIndex(cover, covers.length - 1);
     TweenLite.to(cover, tweenDuration, {x: 0, z: selectedCoverZ, rotationY: 0, ease:easing });
  //____________________________________________________________________________Mouse functions on CoverFlow
  private function onClick(event : MouseEvent) : void
   // Always display product clicked on as center image
   cover = event.target as DisplayObject;
   coverIndex = covers.indexOf(cover);
   show(coverIndex); // Show the index number of the current displayed object
   selectedCoverIndex = getCoverIndex();
   trace("Index of Selected Cover : " + selectedCoverIndex);
  //____________________________________________________________________________Getters
  public function getCoverIndex() : int
   trace("Cover Index: " + coverIndex);
   return coverIndex;
Hope you understand what I mean!!

How stupid of me!!!
I am not 100% sure it worked though... To start off it returns the current value (null) but then once I have clicked on one of the images, the coverIndex should change to the corresponding value. In the CoverFlow class it changes to a different value but I am not sure it does in the ProductSummaryLabel class (the latter is the class that imports the value from the CoverFlow class). The reason I believe this is that when in the CoverFlow I call the method setLabel from the ProductSummaryLabel class, which in turn is supposed to find the text in an array of texts which corresponds to the same index as that of the coverIndex, I receive athe following error message: "cannot reach a property or method with a null object reference". This seems to indicate that this variable in the ProductSummaryLabel class still contains the original null value and does not update itself.
This is what my setLabel method in ProductSummaryLabel class looks like:
public function setLabel() : void
   // Summary text depends on coverIndex, i.e. which image is currently in the center
   coverIndex = CoverFlow.selectedCoverIndex; // This should update itself each time I call the setLabel method!
   trace("Cover Index (Product Summary Label class setLabel()): " + coverIndex);
   var desiredSummaryString : String = uebersicht[coverIndex];
   trace("Product summary text: " + desiredSummaryString);
   productSummaryLabel.text = desiredSummaryString;
   productSummaryLabel.visible = true;
   trace("Step 10: Summary loaded");
Below is the method in the CoverFlow class which gets the current coverIndex value and below that is the method which calls the setLabel method from the ProductSummaryLabel class (where pl is declared above as  private var pl : ProductSummaryLabel;).
public function getCoverIndex() : int
   return coverIndex;
private function onClick(event : MouseEvent) : void
   // Always display product clicked on as center image
   cover = event.target as DisplayObject;
   coverIndex = covers.indexOf(cover);
   show(coverIndex); // Show the index number of the current displayed object
   selectedCoverIndex = getCoverIndex();
   trace("Index of Selected Cover : " + selectedCoverIndex);
   // Ensures the text of prodctSummaryLabel is updated
   pl.setLabel();

Similar Messages

  • Communicate between SWF & Global static vars

    Sorry for my inglish...
    I’m having some problems on getting full communication between loaded SWFs. I'm totally stuck and my timing is running.
    Suppose the following scenario:
    Father-SWF has his own class and loads A-SWF and B-SWF. A and B SWF has his own class and package. To exchange values and run functions between SWF, I’m using a Global class with public static vars. Some of this vars are function, example:
    GLOBAL CLASS WITH STATIC VARS (com. with other class and package beetween SWF)
    package scripts
         public class GlobalAct
              public static var mainStage:Object;
              public static var myFuncGlobalA:Function;
              public static var myFuncGlobalB:Function;
    MAIN CLASS FATHER SWF
    package
         import flash.display.MovieClip;
         import scripts.GlobalAct;
         public class FatherClass extends
    MovieClip
              public function FatherClass():void
                   GlobalAct.mainStage
    = this;
                   GlobalAct.
    myFuncGlobal = myFunc;
              public function myFunc():void
                   //some wird stuff
    A_SWF CLASS
    package
    scripts
         import flash.display.MovieClip;
         import scripts.GlobalAct;
         public class Layout extends
    MovieClip
              private var someMc:MovieClip;
              public function Layout()
                    someMc
    = new MovieClip();
                    someMc. addEventListener(MouseEvent.CLICK,
    mouseFunc);
              public function mouseFunc (evt:MouseEvent):void
                   GlobalAct. myFuncGlobalA ();
    B_SWF CLASS
         Similar to A-SWF class but with other kind of functions…calling “GlobalAct.myFuncGlobalB();” for example.
    This works great, when I run Father-SWF, it load every SWF and functions run from SWF to SWF.
    The problem happens when I load Father-SWF in another SWF. There is a MAIN-SWF with his own set os class and a Global static vars Class.
    MAIN-SWF loads a SWF that will load Father-SWF into the MAIN-SWF.
    WORKING
    Father-SWF -> many SWF that could load other SWF
    NOT WORKING
    Main SWF -> SWF -> Father-SWF -> many SWF that could load other SWF
    When this happens none of the Global functions seems to work. The other Global vars seems OK, only function vars seems not to work.
    I only get the error: “TypeError: Error #1006: value is not a function. at scripts::Layout/ mouseFunc ()” when I try to click a button inside A-SWF.
    Does I lose my Global reference when loading the Father-SWF in another SWF?
    How can I make this bullet proof and generic for every situation?
    What’s the best oop practice to communicate between class and SWF on AS3?

    I figured it out.
    It's under the pop-up window. Select edit locations to select confirm.

  • AS3: static vars and on-stage MC's

    hi,
    my basic problem is as follows:
    i have one swf which loads another one. both of them have
    document class.
    i want to access a variable of the main swf's class from the
    inner swf's
    class, so i turned that var into static. it works fine, as
    long as i don't
    access MC's on the main swf's stage from its class. i've
    tried to solve it
    using the 'ApplicationDomain' but it still fails.
    for testing purposes i've made 2 swf's - 'main.swf' and
    'inner.swf', where
    on the main's stage i've placed a button, with instance name
    'myBtn'.
    this is the main's class:
    package {
    import flash.display.MovieClip;
    import flash.display.Loader;
    import flash.net.URLRequest;
    import flash.system.*;
    import flash.events.*;
    public class MainClass extends MovieClip {
    private static var myStatic:String = "abc";
    private var ldLoader:Loader;
    public function MainClass(){
    loaderInfo.addEventListener(Event.INIT, myOnInit);
    private function myOnInit(eEvent){
    ldLoader = new Loader();
    var urlRequest = new URLRequest("inner.swf");
    var context:LoaderContext = new LoaderContext (false,
    ApplicationDomain.currentDomain);
    ldLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,
    completeHandler);
    ldLoader.load(urlRequest, context);
    this.myBtn.addEventListener(MouseEvent.MOUSE_UP,btnUp);
    private function btnUp(evt){
    trace("btn up");
    private function completeHandler(evt){
    var inner = this.addChild(evt.target.content);
    inner.myOnInit();
    static function get staticVar():String{
    return myStatic;
    this is the inner's class:
    package {
    import flash.display.MovieClip;
    public class InnerClass extends MovieClip{
    public function InnerClass(){}
    public function myOnInit(){
    trace(MainClass.staticVar);
    when i compile 'inner' i get the following error:
    1119: Access of possibly undefined property myBtn through a
    reference with
    static type MainClass.
    the only way to avoid this error is to comment the last line
    of the
    'myOnInit' function in the main class, however then there's
    no access to the
    main's MC's.
    any solution?
    thanks in advance,
    eRez
    www.allofme.com

    Hi,
    can you give us a bit of code ... that will help. And did you
    declare your movieClip before (and outside of) the constructor?
    Like this i mean:
    class RandImg{
    private var mcDefault:MovieClip; // --> here it is ..
    mcDefault
    public function RandImg(){ // --> cunstructor
    trace("mcDefault path = " + mcDefault);
    If mcDefault is not declare before and outside your
    constructor, its impossible for your class to access it. Of course
    you are probably aware of that .. but im trying to figure out what
    can be the problem .. just guessing.
    So please give us some code and we will try to help!

  • HT4623 since i updated my iphone 4 to ios 6, i ve noticed that the wifi connection turns off each time when the screen is locked. I need to be connected with wifi all the time so as to stay updated with all my emails.

    since i updated my iphone 4 to ios 6, i ve noticed that the wifi connection turns off each time when the screen is locked. I need to be connected with wifi all the time so as to stay updated with all my emails. is there anyway for this problem.
    (PS: i know we could use 3G but i want to use wifi instead)

    I am having a really wierd issue as well that is probally related. I dont see 95% of the album artwork associated with my music. Also, it seems as if this has gotten worse since I started using that match feature

  • SAP : Stay update

    Dear Experts,
    We all are aware that there's continuous up-gradation in all the modules of SAP on regular basis, based on for example : value addition, new techniques, new methodology, up-gradation due to changes in Govt Fiscal Policies, etc.
    I wish to stay updated with SAP, which magazine, community or seminars should i subscribe for.
    please guide me.

    Hi Hussein
    This is an interesting question. It made me do some research.
    This magazine is very interesting and covers latest issues and update related articles. Its free to subscribe.
    http://www.sapnetweavermagazine.com/
    It has links to other publications like SAP Professional Journal, SAP Insider, All Functional Expert related magazines,
    Also, You can be in touch with latest updates from SAP's main website which gives details about the Enhancement Packages.
    And ofcourse, the SDN Forum gives a detailed explanation to all FAQs and day-to-day queries.
    Lastly, the webinars, articles and webcasts on Ecohub are really of great help! - http://www.sdn.sap.com/irj/ecohub
    Various SAP related communities on LinkedIn have frequent discussions and news articles.
    Hope this helps!
    Share if you too have some resources.
    Regards
    Z

  • Static Var Memory???

    Hi,
    I have a doubt in the static variable memory storage. Suppose if
    i have declared a static var like:-
    static int i=10;
    Here the variable will occupy 32 bytes that is for int datatype or it will occupy only 2 for the value 10 ? Since it is static??
    Thanks,
    JavaCrazyLover

    Static has nothing to do with the size of variable.... it simply means that when in a class a variable/ method is declared as static all the objects of that class will not have individual copies of that variable/method and wlll instead refer to the same variable/method.....
    An integer always occcupies 4 bytes, ie. 32 bits. so if you store 10 in an integer the first 4 bits would be 1010 and the rest of the 28 bits would be filled with 0's regardless of whether it is static or not
    rgds,
    Juhi
    ps. one must always keep in mind that numbers are not stored in base 10...they are always stored in the form of their binary equivalent, i.e in base 2

  • I have used Pages 09 and Keynote without any major problems until this new update. I have read many of the fixes but have a problem. When you get Pages 09 and Keynote back, Apples continues to want to update the 09 system. So it stays updated.

    I have used Pages 09 and Keynote without any major problems until this new update. I have read many of the fixes but have a problem. When you get Pages 09 and Keynote back, Apples continues to want to update the 09 system. So it stays updated. I have had to turn off my auto updating that was nice but I'll do it one at a time in order to keep the Pages 09 and Keynote. When something works don't mess with it. Any fixes out there?

    I can't say that I have had a problem playing videos in Flash because I could always play them in browsers other than Firefox.
    In Firefox Tools>options>Advanced Hardware acceleration is turned on.
    I don't know if that is different that tuning it off and on in Flash or not, but for now it is a moot point.
    As I stated in my previous message, after following all earlier suggestions/instructions nothing helped. But The latest one, someone suggested that maybe version 17 of Flash might be a stable version.
    I made no other changes except to install it, a few days ago, and so far so good.
    Many thanks for your help,
    Giovanni

  • Static var vs const var

    What's difference 
    public static var = 1000;
    public const var = 1000;
    Can I use public var {get;set;}
    public var {get;}
    puplic var {set;}

    A static field belongs to the type itself rather than to a specific object instance of that type:
    https://msdn.microsoft.com/en-us/library/98f28cdx.aspx.
    An object instance can access the static field but a static property or method cannot access an instance (non-static) field.
    The const keyword is used to declare a compile-time constant field that cannot be modified during runtime:
    https://msdn.microsoft.com/en-us/library/e6w8fe1b.aspx
    Please refer to the links above for more information.
    And please remember to close your threads by marking all helpful posts as answer and then start a new thread if you have a new question.

  • How to ensure Firefox stays updated in Linux Mint 17 - Qiana

    I happen to have dual OS, Windows OS 7 & Linux Mint 17 (Qiana). I love Linux Mint more than Windows 7. If only I could move away completely from Windows I would be the happiest person on the face of the earth. But unfortunately we're not there yet. e.g. under Windows Firefox tends to update itself, the moment new version is released by Mozilla. But the same doesn't occur with Linux Mint, instead it keeps on listing various error messages.
    At present, under Linux Mint I'm using v33, which Linux Mint says is the latest. Whereas v34 is available on Mozilla site. If I've to update FF from 33 to 34, I've download it then either uninstall v33 + install v34 OR install v34 & hope that it overwrites v33 & hope there aren't two versions running on my OS.
    Why can't it is capable to renew like in Mac or Windows, where I go to Help/About Firefox/Update (directly from that panel)?
    By the time FF v34 is available for update under Linux Mint, there will be another version, which will obviously have more security patches.
    One thing I want to clarify, I'm not here to blame any person or group, If I'm able to help I would love to, but this is beyond my expertise, so I'm just trying to raise the issue for the concerned expertise to work towards benefit of all the netizens. If you do have any runaround to this I would really appreciate the feedback. Also this is the first time that I'm voicing my concern, so if I've offended someone, even inadvertently - I apologise.
    Thank you

    Linux Mint controls the updates for their version of Firefox that comes with their operating system. It is controlled through their repository.
    You could install the Linux - Firefox version that comes from Mozilla directly, to have updates done by Mozilla on the Mozilla schedule.
    https://www.mozilla.com/en-US/firefox/all.html

  • PowerMac G5 - Calendar Fails to Stay Updated

    When I power down the G5 and turn it back on a while later, an error message displays (after it boots up) that indicates the Calendar is set to pre-2000. I've set the clock in Sys Pref and locked it, however, it won't stay locked.
    Is it possibly a battery inside the G5 that has failed? Or something else ... I've updated the firmware and run the current OS (Tiger).
    thank you.

    It's probably a 1/2 AA 3.6 volt lithium like this
    http://www.battery-force.co.uk/bf/detail/SNSL35001A/show.html?via=aw
    But you only have to open the side door and look inside to check. This diagram and the User Manual show where it is
    http://docs.info.apple.com/article.html?artnum=86790
    The d-i-y instuctions explain how to change it. Note the static precautions.

  • ExceptionInInitializerError: problems with static vars...

    Hi!
    I got an Env class.
    It has many static variables:
    public static LogFile log=new LogFile("log.log");
    ....and other LogFiles, IniFiles, Connection, etc.
    I dont want to send this vars via parameters to other objects...
    I want to handle the logs globally.
    So, when I try to call the Env.log.addline("...") from other objects then it causes an ExceptionInInitializerError....(and NullPOinterException)
    Why? I think its a simple thing for you, but I'm new in Java developing.
    Please help me!
    Is there other way to declare global variables, that can reached by any other class?

    Is there other way to declare global variables, that can reached by any other class?No, you're doing it correctly by what you have posted here - there is something else you're coding incorrectly.
    Please post a short, concise, executable example of what you're trying to do. This does not have to be the actual code you are using. Write a small example that demonstrates your intent, and only that. Wrap the code in a class and give it a main method that runs it - if we can just copy and paste the code into a text file, compile it and run it without any changes, then we can be sure that we haven't made incorrect assumptions about how you are using it.
    Post your code between [code] and [/code] tags as described in Formatting Help on the message entry page. Cut and paste the code, rather than re-typing it (re-typing often introduces subtle errors that make your problem difficult to troubleshoot). Please preview your post when posting code.

  • Ensure List/Menu populate my update form with the correct data before update

    Hello,
    Please how do I ensure my update form is populated with the correct data before update?
    On my update page I have text fields and select fields (dynamic list/menu). When I open my profile page to make updates, I see the field well positioned in the text fields but in the select list/menu fields, I see "Select from list" instead of the value that was initiated selected
    Correct Values before update
    Wrong values during update
    As you can see from the images below, when I open the update page, the list automatically populate the select fields with the last values in the list instead of the Initial values that where selected by the user before the update.
    Can anyone please review and let me know where I have gone wrong.
    Thank you
    Mike

    Hello All,
    Once more thank you. I have sorted the issue out.
    I observed that I was selecting the wrong field. I selected the field matching the record set of the select instead of the field matching the record set of the table I am working as seen on the image belew
    I was selecting this - This is the record set of the table that hold values for the city select list
    Instead of this. This is the record set of the table behind the form I am working on
    My issue is now re-solved.
    Mike

  • Problem with static vars of SQLJ java stored procedure

    Hi,
    When I'm calling a PL/SQL stored procedure that call a Java stored procedure from another Java stored procedure, the second call to the Java stored procedure does not see the first Java stored procedure static variables.
    Why is that?
    Can I configure it to work otherwise so all the Java stored procedure calls in this session will share the same static variables?
    Thanks

    Hi:
    Remove your ; at the end of the sql string.
    String sql = "SELECT VERSION_OFA FROM XX_PARAMETERS";
    I don't know why JDev accept the ; at the end of string in a prepare statement but AFAIK its not legal.
    If your are using the SQL pane of JDev may be the tool strip the ; for you.
    Best regards, Marcelo.

  • Time/Date not staying updated when unit is powered off.

    I'm trying to help a buddy out with his G5. Every time he powers off his G5 and unplugs it, the time/date settings don't stay the same. I wanted to find out if it was something simple like a CMOS battery. I don't know much about G5 stuff, but on anything other than Mac, a new CMOS battery usually fixes this.

    PRAM Battery, 4 years is close to their lifespan...
    See which one the G5 has...
    http://eshop.macsales.com/item/Newer%20Technology/CR2032/
    http://eshop.macsales.com/item/Newer%20Technology/BAA36VPRAM/

  • Static MAC stay if interface down

    Hello,
    Due to business circonstance I need a static mac in my switch.
    However, if the interface releated to this static mac is down the mac entry remain and cause all traffic to be dropped.
    I would, this mac address to be learned only if a specific interface is down. otherwise my static entry should direct of this mac to this specific interface.
    I need a static mac, but this also break redundancy if this specific interface is down :(

    Hi,
    I am not sure whether this answers your specific requirement or not, but have you tried adding the 'auto-learn' option to the static mac-address entry - this seems to cause the switch to ignore the static mac address if the same mac address is learnt on another interface. Is that what you want or do you simply want the static mac address to have precedence over dynamically learnt mac addresses unless the line protocol of the static mac address interface goes down.
    Very best wishess
    Mike

Maybe you are looking for

  • How to Stop automatic file saving on IPAD Adobe Reader 11.2

    How can stop my PDF document being saved with the fillable form data when being using Adobe Reader 11.2 on an IPAD - the file is automatically saved when the user returns to the document folder.  The original pdf file was created from a Word document

  • "Required folder could not be found"

    I have an iPod Nano 4th gen. I am trying to sync new music to it and I get the error message "required folder could not be found." I have both uninstalled & reinstalled iTunes as well as restored the iPod, both with no luck. Any advice?

  • Compressing data in Smartform

    Dear All   I am  supposed to  customize   a    Smartforms(HCM)   which   has   a   work   schedule   being displayed  as  follows currently  Week No  1                        Days Off  SAT/SUN            Start Time         End Time               Sat 

  • Is anyone else seeing reboots when taking screenshots?

    When taking screenshots under firmware 2.2 (holding down home button, then sleep button), I'm seeing frequent reboots. Anyone else? The iPhone isn't confusing this with a reset, which requires that both be held down for a considerably longer time, is

  • Terrible Transfer Experience - 10+ hours with bad customer service

    I've been a Verizon Fios customer for 3 years. For the most part service has been good, though there were a few instances where I've lost internet and cable for no apparent reason for a few days here and there. However, my experience with Verizon Fio