A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: [AS3] slideshow problem

  1. #1
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766

    [AS3] slideshow problem

    I am coding a simple slideshow, where I load images with XML, and then tween through them.
    The tween/transition is basically a function I wrote to cut the image in small pieces and have each individual piece tween in. This works well enough for jpg/png, but as soon as I try doing this with a swf instead of a image, strange lines appear, as if it didn't load the entire swf, or couldn't extract the bitmapdata.
    Code:
    private function chopImage(cimg:Loader,holder:Sprite):void 
    		{
    			var mainPic:BitmapData = new BitmapData(cimg.width, cimg.height, false);
    			mainPic.draw(cimg,null,null,null,new Rectangle(0, 0, cimg.width, cimg.height));
    			for (var i:int = 0; i < splitv; i++)
    			{
    				for (var j:int = 0; j < splith; j++)
    				{
    					var bmd:BitmapData = new BitmapData(cimg.width / splith, cimg.height / splitv);
    					bmd.copyPixels(mainPic,new Rectangle(j * (cimg.width / splith),i * (cimg.height / splitv),cimg.width / splith, cimg.height / splitv),new Point(0,0));
    					var bm:Bitmap = new Bitmap(bmd);
    					var temp:Sprite = new Sprite();
    					temp.addChild(bm);
    					slide.addChild(temp);
    					temp.x = j * (cimg.width / splith);
    					temp.y = i * (cimg.height / splitv);
    					 );
    				}
    			}
    slide.x = (stage.stageWidth - slide.width) / 2;
    slide.y = (stage.stageHeight - slide.height) / 2;
    Any suggestions?
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  2. #2
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    maybe try setting the container clip's cacheAsBitmap property to true. If you are confident that the swf is completely loaded when you are trying to create your bitmapdata copy.

  3. #3
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    that didn't work. any other suggestions?
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  4. #4
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    can you post a screenshot of these strange lines ? What is in this swf you are loading ? do you have smoothing turned on ? have you tried it with multiple swfs , or just with one ? What steps if any , besides bitmap caching have you taken to try to debug this problem ? Is this swf fully loaded , ie , are you waiting for the Event.COMPLETE event before preforming this bitmap capture on the container sprite or loader ?

  5. #5
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766

    That swf is just a jpg image turned to swf....no animation, no code.
    I have tried with several swfs, and for each the lines appear differently.....so I am guessing I am missing something in my code. The display function is called from Event.COMPLETE, so I don't think that is the problem either....

    I don't have any idea how else I can debug this problem!
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  6. #6
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    add this argument , 0xFFFF00 , to your bitmap data constructor , so :

    Code:
    BitmapData(cimg.width / splith, cimg.height / splitv , 0xFFFF00 )
    if those lines turn yellow , then we know the problem is with your either your syntax and or logic, specifically because the lines are actually the fill color , meaning you are either positioning your pieces incorrectly , or the rectangle used to define the bitmap region is off. copyPixels is not to be used on anything that has been scaled , stretched , etc, so if there is anyway that somehow your loaded swf is being sized , that value will be off. I would also check to make sure the width of your pieces adds up to the width of the loaded swf. Also if you havent already , add mainPic to the display list , so you can see it. If it too shows those lines then we can at least identify that the problem is happening before you cut it up into new pieces.

  7. #7
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    nope mainPic seems just fine, the problem is, i think, with the clipRect property.
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  8. #8
    rabid_Delineator AttackRabbit's Avatar
    Join Date
    Dec 2003
    Location
    Orlando, Florida
    Posts
    481
    i honestly don't really see the need for mainPic at all , or why you are using copyPixels in this case. If i were you i would ditch that , and in your loop just use the draw method and the original display object as the source. And really you could simplify this whole thing by creating a sprite , with X number of sprites with rectangular fill's as children , set it as a mask, and move , tween its children. There's no need to do all these bitmap data conversions , its far more processor intensive then its needs to be.

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