A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: bitmapdata problem

  1. #1
    Member
    Join Date
    Jun 2003
    Posts
    76

    bitmapdata.scroll problem

    i don't know why my line width doesn't decrease after my fertig flag is set to 1

    here's what it looks like:
    http://ize.badne.ws/meh/worm.swf

    and the fla:
    http://ize.badne.ws/meh/worm.fla

    if thickness is above 70 it sets the fertig flag to 1 and then SHOULD decrease the line width again... it doesn't though.... i have no idea why because the thickness variable IS decreased

    the (crappy) code:
    Code:
    //when fertig is 1 and thickness is still over 10 it should decrease the width again...
    //it doesn't tho :(
    
    var worm:Sprite = new Sprite();
    addChild(worm);
    worm.graphics.lineStyle(3,0xff0000);
    worm.x=300;
    worm.y=0;
    
    var ypos:int=0;
    var xpos:int=0;
    var thickness:Number=1;
    
    var bmap=new flash.display.BitmapData(600,400,true,0x00000000);
    
    var fertig:Boolean=0;
    
    var myMatrix:Matrix = new Matrix ();
    
    var tempBitmap:Bitmap=new Bitmap(bmap);
    stage.addChild(tempBitmap);
    
    myMatrix.translate(300-(thickness/2),0);
    
    var myRandom:Number;
    
    stage.addEventListener(Event.ENTER_FRAME, gameloop);
    function gameloop(myevent:Event):void {
        myRandom=5*Math.random();
        worm.cacheAsBitmap=true;
        tempBitmap.cacheAsBitmap=true;
        if (fertig!=1) {
            worm.graphics.lineStyle(2,0x00ffff);
            worm.graphics.lineTo(xpos+thickness+myRandom,ypos);
            
            thickness+=0.5;
            trace(thickness);
            bmap.draw(worm,myMatrix);
            myMatrix.translate(-myRandom+2.25,0);
            bmap.scroll(0,1);
        } else {
            if (thickness>10) {
                trace(thickness)
                worm.graphics.lineStyle(2,0x00ff00);
                worm.graphics.lineTo(xpos+thickness+myRandom,ypos);
                thickness-=0.5;
                bmap.draw(worm,myMatrix);
                myMatrix.translate(-myRandom+2.25,0);
                bmap.scroll(0,1);
            } else {
                tempBitmap.y+=1;
            }
        }
        
        if (thickness>70) {
            fertig=1;
        }
        
        worm.graphics.clear();
    }
    Last edited by NoSkills; 12-27-2008 at 09:36 AM.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You are giving a Boolean var a numerical value. You have to give it the value false or true.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Member
    Join Date
    Jun 2003
    Posts
    76
    0 means false in boolean
    1 means true
    so my code is correct in that part

  4. #4
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    not in Flash. You get a warning. But you are right, fixing that does not solve the problem.
    Last edited by cancerinform; 12-27-2008 at 01:41 PM.
    - The right of the People to create Flash movies shall not be infringed. -

  5. #5
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    I have played around with that script. I think what is happening is that once the line has a certain length like 70 px or 100 px it stays that way and is not cleared.
    - The right of the People to create Flash movies shall not be infringed. -

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