Flash Advisor logo
:: Desktop Shortcut
:: Flash Help
Advice from Experts

Closed Thread
Results 1 to 2 of 2

Hybrid View

  1. #1

    Default Flash 8, scripted camera

    I am using a scripted camera in a new flash I am putting together.
    And i've used one once before and everything worked fine. This time
    when I copy and pasted the script I get errors. I have tried it in other
    films and it works, so it has something to do with the movie.

    I'll show you both the code and the error I get. Thanks


    Error message:
    Code:
    **Error** Symbol=camFrame, layer=actions, frame=1:Line 1: '{' expected
         function camControl():Void {
    
    **Error** Symbol=camFrame, layer=actions, frame=1:Line 9: Unexpected '}' encountered
         }
    
    Total ActionScript Errors: 2 	 Reported Errors: 2

    Script used:
    Code:
    function camControl():Void {
    	parentColor.setTransform(camColor.getTransform());
    	var scaleX:Number = sX/this._width;
    	var scaleY:Number = sY/this._height;
    	_parent._x = cX-(this._x*scaleX);
    	_parent._y = cY-(this._y*scaleY);
    	_parent._xscale = 100*scaleX;
    	_parent._yscale = 100*scaleY;
    }
    function resetStage():Void {
    	var resetTrans:Object = {ra:100, rb:0, ga:100, gb:0, ba:100, bb:0, aa:100, ab:0};
    	parentColor.setTransform(resetTrans);
    	_parent._xscale = 100;
    	_parent._yscale = 100;
    	_parent._x = 0;
    	_parent._y = 0;
    }
    // make frame invisible
    this._visible = false;
    // Capture stage parameters
    var oldMode:String = Stage.scaleMode;
    Stage.scaleMode = "exactFit";
    var cX:Number = Stage.width/2;
    var cY:Number = Stage.height/2;
    var sX:Number = Stage.width;
    var sY:Number = Stage.height;
    Stage.scaleMode = oldMode;
    // create color instances for color 
    // transforms (if any).
    var camColor:Color = new Color(this);
    var parentColor:Color = new Color(_parent);
    // Make the stage move so that the 
    // v-cam is centered on the
    // viewport every frame
    this.onEnterFrame = camControl;
    // Make an explicit call to the camControl
    // function to make sure it also runs on the
    // first frame.
    camControl();
    // If the v-cam is ever removed (unloaded)
    // the stage, return the stage to the default
    // settings.
    this.onUnload = resetStage;

    Yes, I copied the whole code
    Yes, I have used this same exact code before and it worked
    I am using AS 2.0 / Flash8





    Thanks

  2. # ADS
    Join Date
    Always
    Posts
    Many
     
  3. #2
    Join Date
    May 2004
    Location
    U.S.A.
    Posts
    2,890

    Default

    Hi,

    Try removing the ":Void" from your function declarations. This is a strict naming procedure that often causes code failure in pasted code from one project to another.... depending on version used.

    Regards
    NTD
    A mind once stretched by a new idea never regains its original dimensions.
    - Oliver Wendell Holmes

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Sponsors
Create Speaking Characters for your website and Flash movies. 15 Day Free Trial