A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: Pointless flash, anyone?

  1. #1
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927

    Pointless flash, anyone?

    I mean, let's get like 400x400 bitmapdata-or-whatever based flash movie doing something not fancy at all, like drawing random rectangle, and then someone will add something to it, and then another one, etc..........
    who is this? a word of friendly advice: FFS stop using AS2

  2. #2
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    Get it started, I'm sure more will contribute as time goes by. I'll do something after you. All AS driven? And, AS2 or 3?
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  3. #3
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    well, what would it take to start? something like this:
    Code:
    import flash.display.BitmapData;
    
    var b:BitmapData = new BitmapData (Stage.width, Stage.height, true, 0);
    _root.attachBitmap (b, 1);
    
    function onEnterFrame () {
    	b.setPixel32 (b.width * Math.random (), b.height * Math.random (),
    		0xFF000000 + Math.floor (256 * 256 * 256 * Math.random ()) );
    }
    more people know as2 so let's stick with it.
    who is this? a word of friendly advice: FFS stop using AS2

  4. #4
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    A little more lengthy, but definitely pointless:

    PHP Code:
    import flash.display.BitmapData;

    var 
    i:Number 0;

    var 
    b:BitmapData = new BitmapData (Stage.widthStage.heighttrue0);
    this.attachBitmap (b1);

    this.onEnterFrame = function(){
        
    b.setPixel32 (b.width Math.random (), b.height Math.random (),
            
    0xFF000000 Math.floor (256 256 256 Math.random ()) );
    }

    var 
    mList:Object = new Object()
    mList.onMouseMove = function(){
        
    i++
        var 
    rect:MovieClip createRectangle(50400xFF0000 Math.floor (256 256 256 Math.random ()));
        
    rect._y _ymouse -20;
        
    rect._x _xmouse -25;
        
    rect._alpha=50
        removeMovieClip
    ('mc_'+(i-10))
    }
    Mouse.addListener(mList);

    function 
    createRectangle(width:Numberheight:Numbercolor:Number):MovieClip {
        var 
    depth:Number this.getNextHighestDepth();
        var 
    mc:MovieClip this.createEmptyMovieClip("mc_" depthdepth);
        
    mc.beginFill(color);
        
    mc.lineTo(0height);
        
    mc.lineTo(widthheight);
        
    mc.lineTo(width0);
        
    mc.lineTo(00);
        return 
    mc;

    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  5. #5
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    ok, here goes quick mod of above:
    Code:
    import flash.display.BitmapData; 
    
    var i:Number = 0; 
    
    var b:BitmapData = new BitmapData (Stage.width, Stage.height, true, 0); 
    this.attachBitmap (b, 1); 
    
    this.onEnterFrame = function(){ 
        b.setPixel32 (b.width * Math.random (), b.height * Math.random (), 
            0xFF000000 + Math.floor (256 * 256 * 256 * Math.random ()) ); 
    } 
    
    var mList:Object = new Object() 
    mList.onMouseMove = function(){ 
        i++ 
        var poly:MovieClip = createPolygon(50, 40, 0xFF0000 + Math.floor (256 * 256 * 256 * Math.random ())); 
        poly._y = _ymouse -20; 
        poly._x = _xmouse -25; 
        poly._alpha=50 
        removeMovieClip('mc_'+(i-10)) 
    } 
    Mouse.addListener(mList); 
    
    var polyParameter:Number = 0;
    function createPolygon(width:Number, height:Number, color:Number):MovieClip { 
        polyParameter += 1e-2; if (polyParameter > 2 * Math.PI) polyParameter -= 2 * Math.PI;
        var depth:Number = this.getNextHighestDepth(); 
        var mc:MovieClip = this.createEmptyMovieClip("mc_" + depth, depth); 
        mc.beginFill(color); 
    	var n = 3 + 6 * (1 + Math.sin (polyParameter));
    	for (var i = 0; i < n; i++)
    	{
    		var xx = Math.sin (i * 2 * Math.PI / n) * width;
    		var yy = Math.cos (i * 2 * Math.PI / n) * height;
    		if (i < 1) mc.moveTo (xx, yy); else mc.lineTo (xx, yy);
    	}
        return mc; 
    }
    p.s.: never knew pv3d needed any support...
    who is this? a word of friendly advice: FFS stop using AS2

  6. #6
    Developing For Dunkets mneil's Avatar
    Join Date
    Mar 2007
    Location
    Lincoln City
    Posts
    2,156
    I centered the objects. Not really a change, but it bugged me. I'll hopefully let someone else go:

    PHP Code:
    import flash.display.BitmapData

    var 
    i:Number 0

    var 
    b:BitmapData = new BitmapData (Stage.widthStage.heighttrue0); 
    this.attachBitmap (b1); 

    this.onEnterFrame = function(){ 
        
    b.setPixel32 (b.width Math.random (), b.height Math.random (), 
            
    0xFF000000 Math.floor (256 256 256 Math.random ()) ); 


    var 
    mList:Object = new Object() 
    mList.onMouseMove = function(){ 
        
    i++ 
        var 
    poly:MovieClip createPolygon(50400xFF0000 Math.floor (256 256 256 Math.random ())); 
        
    poly._y _ymouse
        
    poly._x _xmouse
        
    poly._alpha=50 
        removeMovieClip
    ('mc_'+(i-10)) 

    Mouse.addListener(mList); 

    var 
    polyParameter:Number 0;
    function 
    createPolygon(width:Numberheight:Numbercolor:Number):MovieClip 
        
    polyParameter += 1e-2; if (polyParameter Math.PIpolyParameter -= Math.PI;
        var 
    depth:Number this.getNextHighestDepth(); 
        var 
    mc:MovieClip this.createEmptyMovieClip("mc_" depthdepth); 
        
    mc.beginFill(color); 
        var 
    * (Math.sin (polyParameter));
        for (var 
    0ni++)
        {
            var 
    xx Math.sin (Math.PI n) * width;
            var 
    yy Math.cos (Math.PI n) * height;
            if (
    1mc.moveTo (xxyy); else mc.lineTo (xxyy);
        }
        return 
    mc

    Of course papervision needs support. It has plenty now, but it could always use more. And, the as2 user group definitely needs help. There is 12 of us on a google group, and little support from the pv3d team- as far as mods and updates go. We're trying to get access so we can maintain it. Not so much me personally, but I'm trying to contribute.
    http://code.mneilsworld.com/
    Text Effects | Bubbles | Dynamic Resize
    4 weeks , 20 papers ... thats 2 dollars .....Caassshhh!

  7. #7
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    I havent played around with AS in a while. Ill contribute my little tweak with fading shapes

    PHP Code:
    import flash.display.BitmapData;
    var 
    i:Number 0;
    var 
    b:BitmapData = new BitmapData(Stage.widthStage.heighttrue0);
    this.attachBitmap(b1);
    this.onEnterFrame = function() {
        
    b.setPixel32(b.width*Math.random(), b.height*Math.random(), 0xFF000000+Math.floor(256*256*256*Math.random()));
        
    };
    var 
    mList:Object = new Object();
    mList.onMouseMove = function() {
        
    i++;
        var 
    poly:MovieClip createPolygon(50400xFF0000+Math.floor(256*256*256*Math.random()));
        
    poly._y _ymouse;
        
    poly._x _xmouse;
        
    poly._alpha 50;
        
    _root['mc_'+i].onEnterFrame fadeOut
    };
    function 
    fadeOut() {
        
    this._alpha -= 3;
        if (
    this._alpha<0) {
            
    this.removeMovieClip();
        }
    }
    Mouse.addListener(mList);
    var 
    polyParameter:Number 0;
    function 
    createPolygon(width:Numberheight:Numbercolor:Number):MovieClip {
        
    polyParameter += 1e-2;
        if (
    polyParameter>2*Math.PI) {
            
    polyParameter -= 2*Math.PI;
        }
        var 
    depth:Number this.getNextHighestDepth();
        var 
    mc:MovieClip this.createEmptyMovieClip("mc_"+depthdepth);
        
    mc.beginFill(color);
        var 
    3+6*(1+Math.sin(polyParameter));
        for (var 
    0i<ni++) {
            var 
    xx Math.sin(i*2*Math.PI/n)*width;
            var 
    yy Math.cos(i*2*Math.PI/n)*height;
            if (
    i<1) {
                
    mc.moveTo(xxyy);
            } else {
                
    mc.lineTo(xxyy);
            }
        }
        return 
    mc;


  8. #8
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    made it grayscaled:
    PHP Code:
    import flash.display.BitmapData
    var 
    i:Number 0
    var 
    b:BitmapData = new BitmapData(Stage.widthStage.heighttrue0); 
    this.attachBitmap(b1); 
    this.onEnterFrame = function() { 
        
    b.setPixel32(b.width*Math.random(), b.height*Math.random(), 0xFF000000+Math.floor(256*256*256*Math.random())); 
         
    }; 
    var 
    mList:Object = new Object(); 
    mList.onMouseMove = function() { 
        
    i++;
        var 
    0.1 i; while (2*Math.PI-= 2*Math.PI;
        var 
    Math.floor(128 * (Math.sin (t)));
        var 
    poly:MovieClip createPolygon(50400xFF000000 256 65536 s); 
        
    poly._y _ymouse
        
    poly._x _xmouse
        
    poly._alpha 50
        
    _root['mc_'+i].onEnterFrame fadeOut 
    }; 
    function 
    fadeOut() { 
        
    this._alpha -= 3
        if (
    this._alpha<0) { 
            
    this.removeMovieClip(); 
        } 

    Mouse.addListener(mList); 
    var 
    polyParameter:Number 0
    function 
    createPolygon(width:Numberheight:Numbercolor:Number):MovieClip 
        
    polyParameter += 5e-2
        if (
    polyParameter>2*Math.PI) { 
            
    polyParameter -= 2*Math.PI
        } 
        var 
    depth:Number this.getNextHighestDepth(); 
        var 
    mc:MovieClip this.createEmptyMovieClip("mc_"+depthdepth); 
        
    mc.beginFill(color); 
        var 
    3+2*(1+Math.sin(polyParameter)); 
        for (var 
    0i<ni++) { 
            var 
    xx Math.sin(i*2*Math.PI/n)*width
            var 
    yy Math.cos(i*2*Math.PI/n)*height
            if (
    i<1) { 
                
    mc.moveTo(xxyy); 
            } else { 
                
    mc.lineTo(xxyy); 
            } 
        } 
        return 
    mc

    who is this? a word of friendly advice: FFS stop using AS2

  9. #9
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    red menace.
    PHP Code:
    import flash.display.BitmapData
    var 
    i:Number 0
    var 
    b:BitmapData = new BitmapData(Stage.widthStage.heighttrue0); 
    this.attachBitmap(b1); 
    this.onEnterFrame = function() { 
        
    b.setPixel32(b.width*Math.random(), b.height*Math.random(), 0xFF000000+Math.floor(256*256*256*Math.random())); 
          
    }; 
    var 
    mList:Object = new Object(); 
    mList.onMouseMove = function() { 
        
    i++; 
        var 
    0.1 i; while (2*Math.PI-= 2*Math.PI
        var 
    Math.floor(128 * (Math.sin (t))); 
        var 
    poly:MovieClip createPolygon(30200xFF000000 /*+ s + 256 * s*/ 65536 s); 
        
    poly._y _ymouse
        
    poly._x _xmouse
        
    poly._alpha 50
        
    _root['mc_'+i].onEnterFrame fadeOut 
    }; 
    function 
    fadeOut() { 
        
    this._alpha -= 3
        if (
    this._alpha<0) { 
            
    this.removeMovieClip(); 
        } 

    Mouse.addListener(mList); 
    var 
    polyParameter:Number 0
    function 
    createPolygon(width:Numberheight:Numbercolor:Number):MovieClip 
        
    polyParameter += 5e-2
        if (
    polyParameter>2*Math.PI) { 
            
    polyParameter -= 2*Math.PI
        } 
        var 
    depth:Number this.getNextHighestDepth(); 
        var 
    mc:MovieClip this.createEmptyMovieClip("mc_"+depthdepth); 
        
    mc.beginFill(color); 
        var 
    3+4*(1+Math.sin(polyParameter)); 
        for (var 
    0i<ni++) {
            var 
    ss 2*(i%2);
            var 
    xx Math.sin(i*2*Math.PI/n)*ss*width
            var 
    yy Math.cos(i*2*Math.PI/n)*ss*height
            if (
    i<1) { 
                
    mc.moveTo(xxyy); 
            } else { 
                
    mc.lineTo(xxyy); 
            } 
        } 
        return 
    mc

    who is this? a word of friendly advice: FFS stop using AS2

  10. #10
    Senior Member Dricciotti's Avatar
    Join Date
    Aug 2002
    Posts
    2,988
    I dig the new changes realMC. I changed it so the polygon moves on its own instead of with the mouse. For some reason though the polygon bounces off the right side of the screen very early. Maybe it has to do with Stage.width of poly._width

    PHP Code:
    import flash.display.BitmapData;
    polySpeed 5;
    polyDirX 1;
    polyDirY 1;
    polyX 300;
    polyY 300;
    var 
    i:Number 0;
    var 
    b:BitmapData = new BitmapData(Stage.widthStage.heighttrue0);
    this.attachBitmap(b1);
    this.onEnterFrame = function() {
        
    b.setPixel32(b.width*Math.random(), b.height*Math.random(), 0xFF000000+Math.floor(256*256*256*Math.random()));
    };
    var 
    mList:Object = new Object();
    //mList.onMouseMove = function() {
    _root.onEnterFrame = function() {
        
    i++;
        var 
    0.1*i;
        while (
    t>2*Math.PI) {
            
    -= 2*Math.PI;
        }
        var 
    Math.floor(128*(1+Math.sin(t)));
        var 
    poly:MovieClip createPolygon(30200xFF000000+65536*s);
        
    poly._y polyX;
        
    poly._x polyY;
        
    polyX += polySpeed*polyDirX;
        
    polyY += polySpeed*polyDirY;
        if (
    polyX<0) {
            
    polyDirX Math.random()+1;
            
    polyX 1;
        } else if (
    polyX>Stage.width-poly._width) {
            
    polyDirX = -1*(Math.random()+1);
            
    polyX Stage.width-poly._width-1;
        }
        if (
    polyY<0) {
            
    polyDirY Math.random()+1;
            
    polyY 1;
        } else if (
    polyY>Stage.height-poly._height) {
            
    polyDirY = -1*(Math.random()+1);
            
    polyY Stage.height-poly._height-1;
        }
        
    poly._alpha 50;
        
    _root['mc_'+i].onEnterFrame fadeOut;
    };
    function 
    fadeOut() {
        
    this._alpha -= 3;
        if (
    this._alpha<0) {
            
    this.removeMovieClip();
        }
    }
    Mouse.addListener(mList);
    var 
    polyParameter:Number 0;
    function 
    createPolygon(width:Numberheight:Numbercolor:Number):MovieClip {
        
    polyParameter += 5e-2;
        if (
    polyParameter>2*Math.PI) {
            
    polyParameter -= 2*Math.PI;
        }
        var 
    depth:Number this.getNextHighestDepth();
        var 
    mc:MovieClip this.createEmptyMovieClip("mc_"+depthdepth);
        
    mc.beginFill(color);
        var 
    3+4*(1+Math.sin(polyParameter));
        for (var 
    0i<ni++) {
            var 
    ss 1+2*(i%2);
            var 
    xx Math.sin(i*2*Math.PI/n)*ss*width;
            var 
    yy Math.cos(i*2*Math.PI/n)*ss*height;
            if (
    i<1) {
                
    mc.moveTo(xxyy);
            } else {
                
    mc.lineTo(xxyy);
            }
        }
        return 
    mc;


  11. #11
    Senior Member realMakc's Avatar
    Join Date
    Oct 2002
    Posts
    927
    very weird, in fact... it bounces off the right side here:
    Code:
    } else if (polyY>Stage.height-poly._height) { 
            polyDirY = -1*(Math.random()+1); 
            polyY = Stage.height-poly._height-1; 
        }
    I'm puzzled... maybe this bit has to do with it:
    Code:
        poly._y = polyX; 
        poly._x = polyY;
    also, you killed random pixel thing, so I guess we can omit it from now on...
    who is this? a word of friendly advice: FFS stop using AS2

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