A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: this shouldn't be a problem... increase value by 1 with "i" +

  1. #1

    this shouldn't be a problem... increase value by 1 with "i" +

    OK... I cannot seem to understand the loop to increase a value by using the i +. Heres the code that I would like to clean up starting at wF1 and continuing to wF45 (i've only included through wF5 to make the post much smaller:
    Code:
    loadWLinks = function() {
    	wF1 = _root.wed.viewer.frame1._width;
    	wF2 = _root.wed.viewer.frame2._width;
    	wF3 = _root.wed.viewer.frame3._width;
    	wF4 = _root.wed.viewer.frame4._width;
    	wF5 = _root.wed.viewer.frame5._width;
    	if (wF1 >= 100) {
    		frameB1._visible = 1;
    	}
    	if (wF2 <= 99) {
    		frameB2._visible = 0;
    	}
    	if (wF3 >= 100) {
    		frameB3._visible = 1;
    	}
    	if (wF4 <= 99) {
    		frameB4._visible = 0;
    	}
    	if (wF5 >= 100) {
    		frameB5._visible = 1;
    	}
    	};
    listener.onEnterFrame = loadWLinks;
    Thanks for any help anyone may be able to offer.

  2. #2
    Senior Member chi-styler's Avatar
    Join Date
    Jul 2001
    Location
    Bristol, UK
    Posts
    1,237
    I'm guessing you're trying to do something like this:
    code:

    loadWLinks = function() {
    for(var i=1; i<=45; i++) {
    if(i % 2 == 0) {
    if(_root.wed.viewer["frame" + i]._width <= 99) {
    this["frameB" + i]._visible = 1;
    }
    }else{
    if(_root.wed.viewer["frame" + i]._width >= 100) {
    this["frameB" + i]._visible = 0;
    }
    }
    }
    }
    listener.onEnterFrame = loadWLinks;


  3. #3
    Junior Member
    Join Date
    Feb 2001
    Posts
    27
    Here is how I would write it. I haven't tested the code for errors so keep that in mind but you'll get the idea .

    loadWLinks = function() {

    for(i=1;i<=45;i++){
    this["wF"+i] = _root["wed"]["viewer"]["frame"+i]._width;
    if(i%2 == 0){
    // Here we're dealing with even numbers
    if( this["wF"+i] <= 99 )
    _root["wed"]["viewer"]["frame"+i]._visible = 0;
    }else{
    // Here we're dealing with odd numbers
    if( this["wF"+i] >= 100 )
    _root["wed"]["viewer"]["frame"+i]._visible = 1;
    }/* end if */
    }/* end for */

    I hope this helps.

    -- Matt
    Last edited by mwilber; 03-24-2004 at 04:48 PM.
    -----------------------------
    Matthew Wilber

    Multimedia Software Design
    Designs • Concepts • Programming

    Visit my websites:

    MW Media: http://www.greenzeta.com
    Personal: http://www.mwilber.com

  4. #4
    Hmmm... neither are working for me... I've attached a file to give you a better idea of what Im working with.
    Attached Files Attached Files

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