A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Please help turn AS2 Smoke into AS3 smoke??

Hybrid View

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Posts
    10

    Question Please help turn AS2 Smoke into AS3 smoke??

    hi,

    I found a great smoke tutorial here: www.pixelhivedesign.com

    I have been trying to turn this actionscript 2 into actionscript 3... is that possible?

    // ------------------------------------------------
    // Realistic Smoke Effect - www.pixelhivedesign.com
    // ------------------------------------------------
    fadeSpeed = 1; // Smoke fade speed.
    floatUpSpeed = 2; // Smoke float up speed.
    // Every frame attach a puff of smoke.
    this.onEnterFrame = function(){
    // Get next available depth.
    d = this.getNextHighestDepth();
    // Attach a puff of smoke.
    aPuff = attachMovie('aPuff','aPuff'+d,d);
    // Set initial scale to 10%.
    aPuff._xscale = aPuff._yscale = 10;
    // Put puff where the mouse is. (add small random)
    aPuff._x = Math.random() * 5;
    // Randomizes the starting animation for realism.
    aPuff.gotoAndPlay(Math.round(Math.random()*20));
    // Smoke will animate each frame.
    aPuff.onEnterFrame = function(){
    // Scale smoke up.
    this._xscale = this._yscale += fadeSpeed;
    // Fade smoke.
    this._alpha -= fadeSpeed;
    // Smoke floating up.
    this._y -= floatUpSpeed;
    // When smoke is 100% scale, remove it.
    if(this._xscale >= 100){
    this.removeMovieClip();
    }
    }
    }

    Can anybody help me? at the moment im getting lots of access of undefined movie problems and it also doesnt like Attachmovie...

    Any help would be brilliant, Thanks very much!

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,448
    As a start:

    1. You need to eliminate all the underscores from _y etc.
    2. for attachMovie you need to create a new object.
    3. onEnterFrame function should be replaced by a listener.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    PHP Code:
    const fadeSpeed:int 1// Smoke fade speed.
    const floatUpSpeed:int 2// Smoke float up speed.

    //  every time the stage ticks a new frame, run this:
    addEventListener(Event.ENTER_FRAME, function(e:Event):void{
        
        
    //  create a new aPuff object from the library
        
    var puff:aPuff = new aPuff();

        
    //  set it up
        
    puff.scaleX puff.scaleY .1;
        
    puff.Math.random() * 5;
        
    puff.gotoAndPlay(int(Math.random() * 20) + 1);

        
    //  hook puff up to enterFrame function: puffFrame
        
    puff.addEventListener(Event.ENTER_FRAMEpuffFrame);
    });


    //  this is run every frame for every puff
    function puffFrame(e:Event):void{
        
    e.target.scaleX e.target.scaleY += fadeSpeed;
        
    e.target.alpha -= fadeSpeed;
        
    e.target.-= floatUpSpeed;

        
    //  check for 100% scale
        
    if(e.target.scaleX >= 1){
            
    //  remove from stage
            
    removeChild(e.target);

            
    //  stop updating and allow puff to be garbage collected
            
    e.target.removeEventListener(e.typearguments.callee);
        }


  4. #4
    Member
    Join Date
    Jan 2008
    Posts
    75
    Anyone get this to work?

  5. #5
    Junior Member
    Join Date
    Jul 2009
    Posts
    9

    new smoke tutorial in as3

    hy
    i don't have an answer to your question but i've been lookin for some smoke myself and didnt find one in as3 until......

    http://laclic.net/tutorial/flash/152...realistic.html




    p.s.: first piece of code goes into a class file. second piece in main timeline. third piece if yu want to randomly change the smoke's color. worked for me...

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