A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: variable string is wiped when starting a new function

  1. #1
    Junior Member
    Join Date
    Apr 2009
    Posts
    9

    variable string is wiped when starting a new function

    Hi, I have 5 links that exist as one large font and four small fonts. The large one dictates the current page and the smaller ones are links to other pages, which become the large font if they are clicked to dictate they are now the new page.

    When a link is small font link is clicked, it activates 3 tween animations for presentations sake, all dont in actionscript 2. The small font ._y is placed at the bottom of the page and swoops back up. The current large font ._y swoops down and, over this, the newly selected page large font swoops up to replace the previous large font.

    I have tried specifying what the current page is in a new object variable so that is is remembered for when a new link (small font) is clicked. However, whenever a new function is started it seems to wipe out the current value of the object, so it cannot pass on what the current page is. Here is the code (I posted this earlier in the newbies section but think it's more suited to this forum, please delete the earlier post if necessary, sorry):

    Code:
    import mx.transitions.Tween; 
    import mx.transitions.easing.*; 
    var currentchoice:Object = new Object(); 
    currentchoice.selection = large_anne; 
    
    small_portfolio.onRollOver = function () { 
    var colorful = new Color("small_portfolio"); 
    colorful.setRGB(0xAAAAAA); 
    }
    
    small_portfolio.onRollOut = function () { 
    var colorful = new Color("small_portfolio"); 
    colorful.setRGB(0xFFFFFF); 
    } 
    
    small_portfolio.onRelease = function() { 
    var myHoriTween:Tween = new Tween (small_portfolio,"_y",Strong.easeOut,100,10,1,true ); 
    var myHoriTween:Tween = new Tween (currentchoice.selection,"_y",Strong.easeOut,-10,100,2,true);
    attachMovie("large_portfolio", "large_portfolio", 1); 
    var myHoriTween:Tween = new Tween (large_portfolio,"_y",Strong.easeOut,100,-10,2,true); 
    currentchoice.selection = large_portfolio; 
    } 
    
    small_statement.onRollOver = function () { 
    var colorful = new Color("small_statement"); 
    colorful.setRGB(0xAAAAAA); 
    } 
    
    small_statement.onRollOut = function () { 
    var colorful = new Color("small_statement"); 
    colorful.setRGB(0xFFFFFF); 
    } 
    
    small_statement.onRelease = function() { 
    var myHoriTween:Tween = new Tween (small_statement,"_y",Strong.easeOut,100,10,1,true ); 
    var myHoriTween:Tween = new Tween (currentchoice.selection,"_y",Strong.easeOut,-10,100,2,true);
    attachMovie("large_statement", "large_statement", 1); 
    var myHoriTween:Tween = new Tween (large_statement,"_y",Strong.easeOut,100,-10,2,true);
    currentchoice.selection = large_portfolio; 
    } 
    
    small_biography.onRollOver = function () { 
    var colorful = new Color("small_biography"); 
    colorful.setRGB(0xAAAAAA); 
    } 
    
    small_biography.onRollOut = function () { 
    var colorful = new Color("small_biography"); 
    colorful.setRGB(0xFFFFFF); 
    } 
    
    small_biography.onRelease = function() { 
    text_txt.text = currentchoice.selection; 
    }
    Thanks!

  2. #2
    Junior Member
    Join Date
    Apr 2009
    Posts
    9
    I've attached the flash file if it's any help, thanks.
    Attached Files Attached Files

  3. #3
    Junior Member
    Join Date
    Apr 2009
    Posts
    9
    I'm still having no luck with this, does anybody have a suggestion? Thanks.

  4. #4
    Senior Member
    Join Date
    Nov 2005
    Location
    dante's inferno
    Posts
    904
    try:

    PHP Code:
    var currentSelection:String large_anne
    then set for button code:
    PHP Code:
    currentSelection:String large_portfolio
    IMS

  5. #5
    Junior Member
    Join Date
    Apr 2009
    Posts
    9
    Thanks IMS, I appreciate it.

    Your button code threw up syntax errors, I redid it a little to get rid of errors but it didn't make any progress.

  6. #6
    Junior Member
    Join Date
    Apr 2009
    Posts
    9
    Does anybody have any ideas on this? I'm still having trouble 2 weeks later.

  7. #7
    Junior Member
    Join Date
    Apr 2009
    Posts
    9
    I tried using shared objects instead but it's giving the same results:

    Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    user_so  = SharedObject.getLocal("user");
    
    if(user_so.data.largetext1 != undefined) {
    
    //data exists
    //do actions
    user_so.data.largetext1  = large_anne; 
    } else {
    //data does not exists
    //do actions
    user_so.data.largetext1  = large_anne; 
    }
    
    
    
    small_portfolio.onRollOver = function () {
    	var colorful = new Color("small_portfolio");
    	colorful.setRGB(0xAAAAAA);
    }
    small_portfolio.onRollOut = function () {
    	var colorful = new Color("small_portfolio");
    	colorful.setRGB(0xFFFFFF);
    }
    
    small_portfolio.onRelease = function() {
    	attachMovie("large_portfolio", "large_portfolio", 1);
    	user_so.data.largetext2 = large_portfolio;
    	var myHoriTween:Tween = new Tween (small_portfolio,"_y",Strong.easeOut,100,10,1,true);
    	var myHoriTween:Tween = new Tween (user_so.data.largetext1,"_y",Strong.easeOut,-10,100,2,true);
    	var myHoriTween:Tween = new Tween (user_so.data.largetext2,"_y",Strong.easeOut,100,-10,2,true);
    	myHoriTween.onMotionFinished = function (){
    	user_so.data.largetext1 = large_portfolio;
    	}
    }
    
    small_statement.onRollOver = function () {
    	var colorful = new Color("small_statement");
    	colorful.setRGB(0xAAAAAA);
    }
    small_statement.onRollOut = function () {
    	var colorful = new Color("small_statement");
    	colorful.setRGB(0xFFFFFF);
    }
    
    small_statement.onRelease = function() {
    	attachMovie("large_statement", "large_statement", 1);
    	user_so.data.largetext2 = large_statement;
    	var myHoriTween:Tween = new Tween (small_statement,"_y",Strong.easeOut,100,10,1,true);
    	var myHoriTween:Tween = new Tween (user_so.data.largetext1,"_y",Strong.easeOut,-10,100,2,true);
    	var myHoriTween:Tween = new Tween (user_so.data.largetext2,"_y",Strong.easeOut,100,-10,2,true);
    	myHoriTween.onMotionFinished = function (){
    	user_so.data.largetext1 = large_statement;
    	text2_txt.text = large_statement;
    	}
    }
    
    small_biography.onRollOver = function () {
    	var colorful = new Color("small_biography");
    	colorful.setRGB(0xAAAAAA);
    }
    small_biography.onRollOut = function () {
    	var colorful = new Color("small_biography");
    	colorful.setRGB(0xFFFFFF);
    }
    small_biography.onRelease = function() {
    	text_txt.text = user_so.data.largetext1;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center