A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: How to move to other scene without content (case: gallery image)

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    2

    How to move to other scene without content (case: gallery image)

    Hello,
    I'm newbie use actionscript. I want to create image gallery, then browsing and found code. After that I applied and working properly.

    [condition]
    I use two scene (A & B). Scene A, used for information content and the B scene is gallery (with code that i found)
    In Scene B, I put create button for back to Scene A

    [problem]
    Back button is working properly, but the gallery content from Scene B also move into Scene A, and covered information content in Scene A. I dont want this.

    [goal]
    How to back into Scene A without move the gallery content from Scene B




    Code:
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    
    var myGalleryXML = new XML();
    myGalleryXML.ignoreWhite = true;
    myGalleryXML.load("image.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;
    
    	_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();
    	createMask();
    	scrolling();
    
    };
    
    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<myImagesTotal; i++) {
    		thumbURL = myImages[i].attributes.thumb_url;
    		myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
    		myThumb_mc._x = _root.thumb_width*i;
    		clipLoader.loadClip("img_thumb/menu/"+thumbURL,myThumb_mc);
    		
    		
    		preloader.onLoadStart = function(target) {
    			target.createTextField("my_txt",target.getNextHighestDepth(),0,0,100,20);
    			target.my_txt.selectable = false;
    		};
    
    
    		preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
    			target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
    		};
    
    		preloader.onLoadComplete = function(target) {
    			new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
    			target.my_txt.removeTextField();
    			target.onRelease = function() {
    				callFullImage(this._name);
    			};
    
    			target.onRollOver = function() {
    				this._alpha = 50;
    			};
    
    			target.onRollOut = function() {
    				this._alpha = 100;
    			};
    
    
    		};
    	}
    }
    
    
    
    function callFullImage(myNumber) {
    
    	myURL = myImages[myNumber].attributes.full_url;
    	myTitle = myImages[myNumber].attributes.title;
    	_root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
    	fullImage_mc._x = _root.full_x;
    	fullImage_mc._y = _root.full_y;
    
    	var fullClipLoader = new MovieClipLoader();
    	var fullPreloader = new Object();
    	fullClipLoader.addListener(fullPreloader);
    
    	fullPreloader.onLoadStart = function(target) {
    		target.createTextField("my_txt",fullImage_mc.getNextHighestDepth(),0,380,200,20);
    		target.my_txt.selectable = false;
    	};
    
    	fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
    		target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
    	};
    
    	fullPreloader.onLoadComplete = function(target) {
    		new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
    		target.my_txt.text = myTitle;
    	};
    
    	fullClipLoader.loadClip("img_big/menu/"+myURL,fullImage_mc);
    	
    }
    
    function createMask() {
    
    	_root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());
    
    	mask_mc._x = _root.gallery_x;
    	mask_mc._y = _root.gallery_y;
    
    	mask_mc.beginFill(0x000000,100);
    	mask_mc.lineTo(_root.gallery_width,0);
    	mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
    	mask_mc.lineTo(0,_root.gallery_height);
    	mask_mc.lineTo(0,0);
    
    	container_mc.setMask(mask_mc);
    
    }
    
    function scrolling() {
    	_root.onEnterFrame = function() {
    
    		if (mask_mc._xmouse<(mask_mc._width*(1/3)) || mask_mc._xmouse>(mask_mc._width*(2/3))) {
    		container_mc._x += Math.cos(((mask_mc._xmouse)/mask_mc._width)*Math.PI)*15;
    
    		if (container_mc._x>mask_mc._x) {
    			container_mc._x = mask_mc._x;
    		}
    
    		if (container_mc._x<(mask_mc._x-(container_mc._width-mask_mc._width))) {
    			container_mc._x = mask_mc._x-(container_mc._width-mask_mc._width);
    		}
    		}
    	};
    }
    Thank you very much for guidance and suggestion

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

    Lots of people would suggest to not scenes as they can play around with vars and such.

    I would recommend using either 2 frames or 2 movieclips.

    To get better help it would be advisable for you to attach your *.fla and associated xml files, so we do not have to try and recreate your files, if its too big then maybe find somewhere for us to download the filed from.

  3. #3
    Registered User
    Join Date
    Jul 2014
    Posts
    2
    hi fruitbeard,

    Thanks for your information..actually i also found some articles that says better not use scene, in the other app, i will not use again

    Like what your advise, I attach the *.fla and other associated file that use in my app

    glscript.zip

    Thank you very much for guidance and suggestion

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

    Ive attached some altered files for you, take a look and scrutinise it, I had to do it kind of quickly but it's there, you now have one xml file instead of numerous and no scenes.

    Just keep the same directory structure as you already have and put these files there.
    you may want to rename your original fla and swf so you don't overwrite them.

    It's CS5 thats as low as I can save files.

    I'm not quite sure what the mask function is doing especially as you remove it directly after creating it.
    and I'm not sure what the scrolling function does either as it involves the non existent mask.
    Last edited by fruitbeard; 08-08-2014 at 10:13 AM.

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