A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: Converting AS 2.0 scroller to AS 3.0

  1. #1
    Junior Member
    Join Date
    Sep 2008
    Posts
    24

    Smile Converting AS 2.0 scroller to AS 3.0

    Hi,

    I'm trying to upgrade an AS 2.0 scroller to AS 3.0, but haven't got the first clue when it comes to removing stuff like _root etc.

    My code is:
    PHP Code:
    function parallax (layerspeed)
    {
     var 
    distance=_root._xmouse-Stage.width/2;

      if (
    _xmouse Stage.width/2){     
            
    layer._x -= distance*speed;        
            
        }else{
            
    layer._x += distance*-speed;        
        }
        
        if(
    layer._x <= 0){
            
    layer._x layer._x layer._width/2;        
        }else if(
    layer._x >= layer._width/2){
            
    layer._x layer._x layer._width/2;
        }        
    }


    profiles_mc.onEnterFrame = function() { parallax(this1/40); } 
    Can someone help me to work out how to make it work in AS 3.0, please?

    Cheers.

  2. #2
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    I have no way of testing this to make it work for you but this would be a start:
    PHP Code:
    import flash.display.MovieClip;
    import flash.events.Event;

    profiles_mc.addEventListener(Event.ENTER_FRAMEprofilesEnterFrame);

    function 
    parallax(layer:MovieClipspeed:int):void
    {
        var 
    distance:int = (_root._xmouse - (Stage.width 2));
        
        if (
    mouseX > (stage.stageWidth 2))
        {
            
    layer.-= distance speed;
        }else{
            
    layer.+= distance * -speed;
        }
        
        if (
    layer.<= 0)
        {
            
    layer.layer.layer.width 2;
        }else if(
    layer.>= layer.width 2){
            
    layer.layer.layer.width 2;
        }
    }

    function 
    profilesEnterFrame(e:Event):void
    {
        
    parallax(profiles_mc40);

    If you post your files we can help further.

  3. #3
    Bald By Choice jasondefra's Avatar
    Join Date
    Mar 2008
    Location
    Wisconsin, USA
    Posts
    205
    PHP Code:
    function parallax(layer:Stringspeed:Number):void{
    var 
    distance:Number=stage.mouseX-stage.stageWidth/2;

      if (
    mouseX stage.stageWidth/2){     
            
    this[layer].-= distance*speed;        
            
        }else{
            
    this[layer].+= distance*-speed;        
        }
        
        if(
    this[layer].<= 0){
            
    this[layer].this[layer]._x this[layer].width/2;        
        }else if(
    this[layer].>= this[layer].width/2){
            
    this[layer].this[layer].this[layer].width/2;
        }        

    Follow me on Twitter: http://twitter.com/jasondefra

  4. #4
    Junior Member
    Join Date
    Sep 2008
    Posts
    24

    Smile

    Thanks for your help so far. I will post the files when I get home from work.

  5. #5

  6. #6
    AS3 Mod
    Join Date
    Sep 2007
    Location
    O-H-I-O
    Posts
    2,385
    Paste this code into your actions, works for me:
    PHP Code:
    stop();
    var 
    arthur_mitchell:MovieClip = new MovieClip();

    arthur_mitchell.addEventListener(MouseEvent.MOUSE_OVERmouseOverHandler);
    arthur_mitchell.addEventListener(MouseEvent.MOUSE_OUTmouseOutHandler);
    arthur_mitchell.addEventListener(MouseEvent.MOUSE_DOWNamitchellVideo);

    function 
    mouseOverHandler(e:MouseEvent):void
    {
        
    arthur_mitchell.alpha 0;
    }

    function 
    mouseOutHandler(e:MouseEvent):void
    {
        
    arthur_mitchell.alpha =.4;
    }

    function 
    amitchellVideo(e:MouseEvent):void
    {
        
    gotoAndStop("atkins");
    }

    import flash.display.MovieClip;
    import flash.events.Event;

    profiles_mc.addEventListener(Event.ENTER_FRAMEprofilesEnterFrame);

    function 
    parallax(layer:MovieClipspeed:Number):void
    {
        var 
    distance:Number = (mouseX - (stage.stageWidth 2));
        
        if (
    mouseX > (stage.stageWidth 2))
        {
            
    layer.-= (distance speed);
        }else{
            
    layer.+= distance * -speed;
        }
        
        if (
    layer.<= 0)
        {
            
    layer.layer.layer.width 2;
        }else if(
    layer.>= layer.width 2){
            
    layer.layer.layer.width 2;
        }
    }

    function 
    profilesEnterFrame(e:Event):void
    {
        
    parallax(e.target0.025);


  7. #7
    Junior Member
    Join Date
    Sep 2008
    Posts
    24
    Thank you so much. There is one more issue, if you can help me fix it. I've tried to set the code so that when you click on a face it sends you to a new part on the timeline so that it will play a particular video. I was going to use different frames, but AS 3.0 doesn't like that, so can you suggest a slicker way of going about it...

    Thank you so much again...

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