Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 7 of 7
  1. #1
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    So yeah. Finally getting into Action Script and DANGIT!!! There's two prominent versions out there.

    So I found this cool perspective code and started tweaking it and messing around and finally figured out that is was coded in AS2 and I couldn't add any AS3 tweaks.

    http://imm.sheridanc.on.ca/imm2003/z...utorial1.shtml

    I was wondering if there were any wonderful people out there that could help me get a similiar effect or help me convert this into AS3.

    Non?
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  2.  

  3. #2
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Won't be extremely simple. AS3 is entirely different than AS2.

    We actually created a complete 3D engine for AS3 here at Transio, but it's about 50 pages of code and wouldn't help you figure out what you're looking to do.

    I think you'd be best served by first reading up on AS3 and learning a bit about the language... again, it's COMPLETELY different than AS2. They totally reworked the langauge.

    Best of luck!

  4. #3
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    I'm working on it right now. I have half the script working but it's not resizing objects to make the illusion of depth yet.
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  5. #4
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    You wouldn't happen to know how to go back to the root and select objects. The code for it. I don't think MovieClip(parent) is right... I keep getting the following error

    Gives me TypeError: Error #1010: A term is undefined and has no properties.
    at perspectivecs4_fla::Box_2/myFunction2()

    My Code

    Code:
    addEventListener(Event.ENTER_FRAME,myFunction2);
    function myFunction2(event:Event) {
    	
    	var xscale = MovieClip(parent).box_mc.scaleX/stage.stageWidth;
    	var yscale = MovieClip(parent).box_mc.scaleY/stage.stageHeight;
    		
    	// scale object
    	z = z++;
    	var scale = MovieClip(parent).box_mc.fl/(MovieClip(parent).box_mc.fl+z);
    
    	// set object's x and y co-ords
    	var offsetx = MovieClip(parent).box_mc.vanishing_pt.x-x;
    	var offsety = MovieClip(parent).box_mc.vanishing_pt.y-y;
    	xscale = x+(offsetx*(1-scale));
    	yscale = y+(offsety*(1-scale)); 
    	
    }
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  6. #5
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    AS3 doesn't work that way. Like I said, it's totally different. You could theoretically pass the root MC to child objects by reference in their constructor, but that's really poor design.

    The way you're supposed to pass calls back to the root in AS3 is using Events and EventListeners. You add a child MC to the root using addChild(). Then you use addEventListener() to register an event listener. Finally, from the child object, you throw an Event using dispatchEvent(), which will be handled by the event listener you set up in the root.

    That way, your child objects are completely modular, which is good, because they are completely independent of their containers, and don't make assumptions as to how they're being used.

  7. #6
    Member webmastercorey's Avatar
    Join Date
    Nov 2005
    Location
    Kansas
    Posts
    49
    Member #
    11909
    So I've been like researching addChild() for awhile now. And I'm having a hard time understanding it. Is there a good example of this somewhere because i'm not finding it. I don't really understand it either.
    "What good will it be for a man if he gains the whole world, yet forfeits his soul?"
    -Matthew 16:26

  8. #7
    WDF Staff smoseley's Avatar
    Join Date
    Mar 2003
    Location
    Boston, MA
    Posts
    9,729
    Member #
    819
    Liked
    205 times
    Ok, in AS3, every movie clip you create is theoretically supposed to be tied to a class. You create classes in their own AS files and reference them from the MovieClip properties window.

    So say you have a MovieClip named "Ball". You could reference a class "Ball", and then create Ball.as, which will contain the AS for the Ball class.

    It'll look something like this:

    Code:
    package {
        import flash.display.MovieClip;
    
        class Ball extends MovieCliip {
            private diameter:int
            public function Ball(diameter:int):void {
                this.diameter = diameter;
                // This is your constructor
            }
            public function doSomething {
                this.dispatchEvent(...);
            }
        }
    }
    Then, in your root, you'll set it up to reference a class like "Main" or something, and then you'll have a Main.as with code like this:


    Code:
    package {
        import flash.display.MovieClip;
    
        class Main extends MovieCliip {
            /**
             * This is your constructor
             */
            public function Main():void {
    
                // Add a ball with diameter of 10
                this.addChild(new Ball(10));
    
                // Listen for an event from the Ball object
                // Read up on how to create custom events to do this...
                this.addEventListener(Ball.CUSTOM_EVENT, "customEventHandler");
            }
    
            /**
             * This is an event handler
             */
            private function customEventHandler {
                // Handle our event here.
            }
        }
    }


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 09:54 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com