A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [RESOLVED] Can you possibly convert the output of a subString to a number?

  1. #1
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389

    resolved [RESOLVED] Can you possibly convert the output of a subString to a number?

    Hi,

    I need to load my images beggining at 1 but I'm getting a chronological numeration starting at 0 when I use the substring method to extract the number of the thumbs I have for my full images.

    I'd like to convert it, if possible, to a number so I can add one when loading the clip.

    Code:
    function callFullImage(myNumber) {
    	_root.createEmptyMovieClip("fullImage_mc", _root.getNextHighestDepth());
    	fullImage_mc._x = _root.full_x;
    	fullImage_mc._y = _root.full_y;
    	var fullClipLoader = new MovieClipLoader();
    	var myURL = myNumber.substring(14);
    	
    	trace(myURL);
    	fullClipLoader.loadClip("images/Barcelona/Untitled-"+myURL+".jpg", fullImage_mc);
    }

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    what value are you using when you call callFullImage(?????) with your button or clip?

  3. #3
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    Well... I'm not sure. I though I was using a number.

    I call it like so:

    Code:
    function callFullImage(myNumber) {
    	_root.createEmptyMovieClip("fullImage_mc", _root.getNextHighestDepth());
    	fullImage_mc._x = _root.full_x;
    	fullImage_mc._y = _root.full_y;
    	var fullClipLoader = new MovieClipLoader();
    	var myURL = myNumber.substring(14);
    	
    	trace(myURL);
    	fullClipLoader.loadClip("images/Barcelona/Untitled-"+myURL+".jpg", fullImage_mc);
    }
    but if I add the thumb I'm clicking I get 01, 11, 21,31...

  4. #4
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    OK, when you click a button you must be calling the function, perhps like so
    myButton.onRelease = function()
    {
    callFullImage(????);
    }

  5. #5
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    You can attahc your fla if you want me to look or I am unable to follow from the code you have given without more3

  6. #6
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    You should expand your MovieClipLoader code to give you more flexibilty for other things too,
    PHP Code:
    var fullClipLoader:MovieClipLoader;
    var 
    fullClipListen:Object;
    var 
    fullClipTarget:MovieClip;

    var 
    myURL:String;
    var 
    percentLoad:Number;
    var 
    loadedBytes:Number;
    var 
    totalBytes:Number;

    callFullImage("1234567890123456789");

    function 
    callFullImage(myNumber)
    {
        
    _root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
        
    fullImage_mc._x _root.full_x;
        
    fullImage_mc._y _root.full_y;

        
    fullClipLoader = new MovieClipLoader();
        
    fullClipListen = new Object();

        
    myURL myNumber.substring(14);// everything from character 14
        
    trace("Original: " myURL);
        
    trace("Added 1: " + (Number(myURL) + 1));

        
    fullClipLoader.addListener(fullClipListen);
        
    fullClipLoader.loadClip("images/Barcelona/Untitled-" myURL ".jpg",fullImage_mc);
    }

    // *** MovieClipLoader - start,loading,finish,initiate.
    fullClipListen.onLoadStart = function(fullClipTarget)
    {
        
    trace("Loading image into MovieClip " fullClipTarget._name);
    };

    fullClipListen.onLoadProgress = function(fullClipTargetloadedBytestotalBytes)
    {
        
    percentLoad Math.floor((loadedBytes totalBytes) * 100);
        
    trace("Loaded: (" loadedBytes "/" totalBytes " bytes) - " percentLoad "%");
    };

    fullClipListen.onLoadComplete = function(fullClipTarget)
    {
        
    trace("Image loaded - now do things (initiate).");
    };

    fullClipListen.onLoadInit = function(fullClipTarget)
    {
        
    fullClipTarget.forceSmoothing true;
        
    fullClipTarget._width Stage.width;
        
    fullClipTarget._height Stage.height;
    };
    // *** End MovieClipLoader. 
    The only thing I'm not sure about with your original code is why the substring(14)

    where does the 14 come into it and why, could it not be simplified

  7. #7
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    I have looked at your newer cleaner looking website, you need to get rid of the right click again.
    when the movie has loaded try right clicking and pressing play, see what happens.

  8. #8
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    Hi,

    just got back from class...

    I forgot about that aspect about the right click. I'm working at quite a slow pace. I'm working on the original and getting rid of things on the run so I will probably forget about a lot of relevant things, but at least I remembered the force smoothing on loading the images. I hope I did it right.

    So I'm following an example on a new gallery where the thumbs will scroll beneath a mask, but it is based on having different folders for the thumbs and the images. What happened was I tried to decrease the size of the thumbs programatically and that's why I'm having that 14 there. I'm using susbstring to leave the final number of thumbContainer0, thumbContainer1, thumbContainer3, etc...

    I won't post it yet since I think I might as well work with two different folders because I just realized that on changing folders, the thumbs will have different sizes again.


    I have a sort of sloppy sketch so far, so I'll tune the right button mouse issue for now.

    Thanks

  9. #9
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hey Cap,

    for your number conversion

    PHP Code:
    myURL String(Number(myNumber.substring(14)) + 1);
    trace(myURL);
    fullClipLoader.loadClip("images/Barcelona/Untitled-" myURL ".jpg",fullImage_mc); 

  10. #10
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    Thanks, I will try it anyway.

    Here's all the code I have now in one frame so far:

    Code:
    var myGalleryXML = new XML();
    myGalleryXML.ignoreWhite = true;
    myGalleryXML.load("gallery.xml");
    
    myGalleryXML.onLoad = function() {
    	_root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
    	_root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
    	_root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
    	_root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
    	_root.myImages = myGalleryXML.firstChild.childNodes;
    	_root.myImagesTotal = myImages.length;
    	trace(_root.myImagesTotal);
    	_root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
    	_root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
    	_root.full_x = myGalleryXML.firstChild.attributes.full_x;
    	_root.full_y = myGalleryXML.firstChild.attributes.full_y;
    	
    	callThumbs();
    };
    
    function callFullImage(myNumber) {
    	_root.createEmptyMovieClip("fullImage_mc", _root.getNextHighestDepth());
    	fullImage_mc._x = _root.full_x;
    	fullImage_mc._y = _root.full_y;
    	var fullClipLoader = new MovieClipLoader();
    	var myURL = myNumber.substring(14);
    	
    	trace(myURL);
    	fullClipLoader.loadClip("images/Barcelona/Untitled-"+myURL+".jpg", fullImage_mc);
    }
    
    function callThumbs() {
    	_root.createEmptyMovieClip("container_mc", _root.getNextHighestDepth());
    	container_mc._x = _root.gallery_x;
    	container_mc._y = _root.gallery_y;
    	
    	var clipLoader = new MovieClipLoader();
    	
    	var preloader = new Object();
    	clipLoader.addListener(preloader);
    	
    	for (i=0; i<_root.myImagesTotal; i++) {
    		thumbURL = myImages[i].attributes.thumb_url;
    		
    		myThumb_mc = container_mc.createEmptyMovieClip("thumbContainer"+i, container_mc.getNextHighestDepth());
    		myThumb_mc._x = _root.thumb_width*i+5;
    		
    		clipLoader.loadClip(thumbURL, myThumb_mc);
    		
    		myThumb_mc.forceSmoothing = true;
    	}
    	
    	preloader.onLoadComplete = function(target) {
    	target.onRelease = function() {
    		callFullImage(this._name);
    		
    		
    		};
    	};
    	_level0.container_mc.thumbContainer0._xscale = 7.5;
    	_level0.container_mc.thumbContainer1._xscale = 6.2;
    	_level0.container_mc.thumbContainer2._xscale = 15.7;
    	_level0.container_mc.thumbContainer3._xscale = 17.5;
    	_level0.container_mc.thumbContainer4._xscale = 7.3;
    	_level0.container_mc.thumbContainer5._xscale = 10.6;
    	_level0.container_mc.thumbContainer6._xscale = 19.4;
    	_level0.container_mc.thumbContainer7._xscale = 6.4;
    	_level0.container_mc.thumbContainer8._xscale = 19.2;
    	_level0.container_mc.thumbContainer9._xscale = 9.2;
    	_level0.container_mc.thumbContainer10._xscale = 19.2;
    	_level0.container_mc.thumbContainer11._xscale = 19.2;
    	_level0.container_mc.thumbContainer12._xscale = 6.2;
    	_level0.container_mc.thumbContainer13._xscale = 6.2;
    	
    	_level0.container_mc.thumbContainer0._yscale = 12;
    	_level0.container_mc.thumbContainer1._yscale = 17.8;
    	_level0.container_mc.thumbContainer2._yscale = 12;
    	_level0.container_mc.thumbContainer3._yscale = 12;
    	_level0.container_mc.thumbContainer4._yscale = 12;
    	_level0.container_mc.thumbContainer5._yscale = 12;
    	_level0.container_mc.thumbContainer6._yscale = 9.8;
    	_level0.container_mc.thumbContainer7._yscale = 19;
    	_level0.container_mc.thumbContainer8._yscale = 9.6;
    	_level0.container_mc.thumbContainer9._yscale = 12.3;
    	_level0.container_mc.thumbContainer10._yscale = 10;
    	_level0.container_mc.thumbContainer11._yscale = 10;
    	_level0.container_mc.thumbContainer12._yscale = 20.8;
    	_level0.container_mc.thumbContainer13._yscale = 21.4;
    }
    this is how I shrink the thumbs, but I forgot I'll have other folders

    I'll keep working

  11. #11
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,780
    Hi Cap,

    wow, thats a mouth full of code there Cap, you should think about making more use of the xml files instead of having all the xscale and stuff inside your fla. you can make quite nice arrays from xml files.

    Save you an awful lot of hand coding the fla.

  12. #12
    Senior Member
    Join Date
    Jan 2007
    Location
    Barcelona
    Posts
    389
    I know. I need to really decide what I want to achieve. I'm just merging concepts too quickly.

    I'd like to have my thumbs scroll horizontally so I wonder what technique I should approach.

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