A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: 2 problems with loaded images

  1. #1
    Senior Member
    Join Date
    Dec 2002
    Posts
    175

    2 problems with loaded images

    Well, I discarded the photoFlow thingie, mainly because everybody is using it.

    I made some new effect for displaying my pictures. Now I used this "tutorial" to load my images in with xml:
    http://board.flashkit.com/board/showthread.php?t=755188 , which works quite well for now.

    The first problem is to get my loaded images on the place I need them to be. With the code, my imgHolder is a movieclip in with a linkage "imgDisplay" to make it a class. This movieclip/class contains another movieclip "imgBtnAni", of which are 2 instances off, "imgAni" and "reflect". The "reflect" begin turned and tinted to give that reflect effect.
    The movieclip "imgBtnAni" has the movieclip "imgContainer" in it, where the loaded image needs to go. Intance name is "afbeelding".
    Problem is that the image won't load into both instances, that of "imgAni" and "reflect". It allways takes the last one. Now how can I get my loaded image on both locations?

    This is the code:
    Code:
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onLoaded);
    
    var xml:XML;
    var xmlList:XMLList;
    var xmlLength:int = 0;
    
    var imgArray:Array = new Array();
    var imageLoader:Loader;
    var imgHolder:imgDisplay;
    
    xmlLoader.load(new URLRequest("portfolio.xml"));
    
    function onLoaded(e:Event):void{
    	xml = new XML(e.target.data);
    	xmlList = xml.categorie.children();
    	xmlLength = xmlList.length();
    	//trace(xmlList.length());
    	
    	for(var i:uint = 0; i < xmlLength; i++){
    		imageLoader = new Loader();
    		imageLoader.load(new URLRequest(xmlList[i].attribute("bestand")));
    		
    		imgHolder = new imgDisplay();
    		addChild(imgHolder);
    		
    		imgHolder.x = i * imgHolder.width;
    		imgHolder.name = "beeld_"+i;
    		
    		imgHolder.imgAni.afbeelding.addChild(imageLoader);
    		imgHolder.reflect.afbeelding.addChild(imageLoader);
    		//trace(imgHolder.imgAni.afbeelding.width);
    		imgHolder.imgAni.afbeelding.x = -175;
    		imgHolder.imgAni.afbeelding.y = -175;
    		imgHolder.reflect.afbeelding.x = -175;
    		imgHolder.reflect.afbeelding.y = -175;
    		imgArray.push(imgHolder);
    	}
    }
    Second problem is that the loaded image don't seem to get the properties width and height. I need them to correct the placement of the images more to the center, since they have different sizes. For now I just place their x and y value on -175.

    Grtz
    http://www.EyeEmotion.be/: just here to give you a nice treatment for the eye


  2. #2
    Senior Member
    Join Date
    Dec 2002
    Posts
    175
    Ok, so the problem with the height and width of the image is fixed. Now I have been able to position my loaded images on the center bottom of the "buttons" like I wanted.

    My code now looks like this:
    Code:
    import fl.transitions.*;
    import fl.transitions.easing.*;
    
    stage.scaleMode = "noScale";
    
    var xmlLoader:URLLoader = new URLLoader();
    xmlLoader.addEventListener(Event.COMPLETE, onLoaded);
    
    
    var xml:XML;
    var xmlList:XMLList;
    var xmlLength:int = 0;
    
    var xImg:Array = new Array();
    var imageLoader:Loader;
    var afb:Sprite;
    var imgHolder:imgDisplay;
    
    var tweenImg:Tween;
    var tweenScroll:Tween;
    
    var i:uint = 0;
    
    xmlLoader.load(new URLRequest("xml/portfolio.xml"));
    
    function onLoaded(e:Event):void{
    	xml = new XML(e.target.data);
    	makeImg();
    }
    
    function makeImg():void{
    	
    	xmlList = xml.categorie.children();
    	xmlLength = xmlList.length();
    
    	imageLoader = new Loader();
    	imageLoader.load(new URLRequest(xmlList[i].attribute("bestand")));
    		
    	imgHolder = new imgDisplay();
    	addChild(imgHolder);	
    	imgHolder.x = i * imgHolder.width;
    	imgHolder.name = "beeld_"+i;
    
    	imageLoader.contentLoaderInfo.addEventListener(Event.INIT, initImgF);
    
    	xImg.push(Math.round(this.x-imgHolder.x)); 
    	imgHolder.imgAni.addEventListener(MouseEvent.MOUSE_OVER, scrollF);
    
    }
    
    
    function initImgF(e:Event):void{
    	afb = new Sprite();
    	afb.addChild(imageLoader);
    	
    	imgHolder.imgAni.afbeelding.addChild(afb);
                //imgHolder.reflect.afbeelding.addChild(afb);
    	imgHolder.imgAni.afbeelding.x = -(afb.width/2);
    	imgHolder.imgAni.afbeelding.y = (175-afb.height);
    	i++;
    	if(i<xmlLength){
    		makeImg();
    	} 
    }
    
    function scrollF(e:MouseEvent):void{
    	if((this.x+e.target.parent.parent.x) < 500){
    	             tweenImg = new Tween(this,  "x", Regular.easeOut, this.x, xImg[getChildIndex(e.target.parent.parent)], 15, false);
    	} else {
    		tweenImg = new Tween(this,  "x", Regular.easeOut, this.x, xImg[getChildIndex(e.target.parent.parent)], 15, false);
    	}
    }
    The problem for placing another instance of the image for the reflection still exists. So still need help with that.

    You can see the current build on here

    Clicking the buttons will "zoom in" on the pictures. But as you will see, it still needs adjustments. I want the other buttons to slide to either left or right. So that it looks as if the picture being zoomed, is pushing the buttons to the side. If anyone know how to approach that, it will be appreciated.

    Grtz and hope somebody can help.
    http://www.EyeEmotion.be/: just here to give you a nice treatment for the eye


  3. #3
    Senior Member
    Join Date
    Dec 2002
    Posts
    175
    Still no luck with copying the image for the reflection. So how do I copy a Sprite to another Sprite? I still think it's strange that I can't place that one sprite on 2 places. Why is that?
    I also tried the draw() and the copyPixels(), but no luck there either.

    So... any actionscript guru's out there who can help.

    The rest of my gallery seems to work (although sometimes some bugs seem to arise). At http://www.EyeEmotion.be/ver2008 you can view how the current gallery is implemented in the website. Gallery currently only at "Photography", "Art n Graphics" and "Desktop Publishing".

    Hope somebody can help with the reflection.

    Cheers
    http://www.EyeEmotion.be/: just here to give you a nice treatment for the eye


  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Senior Member
    Join Date
    Dec 2002
    Posts
    175
    thnx for the reply.

    Using that gives me te following error.

    1118: Implicit coercion of a value with static type flash.displayisplayObject to a possibly unrelated type flash.display:Sprite.

    :s
    http://www.EyeEmotion.be/: just here to give you a nice treatment for the eye


  6. #6
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    Replace Sprite with Object.
    - The right of the People to create Flash movies shall not be infringed. -

  7. #7
    Senior Member
    Join Date
    Dec 2002
    Posts
    175
    Replacing everything to Object or Sprite doesn't give an error. But it also doesn't do anything. My loaded image still isn't copied and placed on that location. :s.

    Any other ideas?

    Cheers
    http://www.EyeEmotion.be/: just here to give you a nice treatment for the eye


  8. #8
    Senior Member
    Join Date
    Dec 2002
    Posts
    175
    Anybody?

    I know it is possible... otherwise people couldn't have made that coverflow thing.
    I just find it odd that previous things didn't work, as they seem so logical. So what could be the problem for the reflection not to work?

    Really hope that there is someone who can figure it out, because I'm running out of ideas.

    Cheers
    http://www.EyeEmotion.be/: just here to give you a nice treatment for the eye


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