Results 1 to 4 of 4

Thread: Passing Parameters in functions

  1. #1
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default Passing Parameters in functions

    Hi, I need help in AS 3. My code looks like this:
    Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    
    var hover:Array = new Array("car1", "car2", "car3", "car4", "car5", "car6");
    
    addEventListener(Event.ENTER_FRAME, applyEffect);
    
    function applyEffect(e:Event):void
    {
    	for(var i:Number = 0; i < (hover.length); i++){
    		(hover[i]).addEventListener(MouseEvent.MOUSE_OVER, makeBigger);
    	}
    }
    function makeBigger(MouseEvent):void
    {
    	var tweenW:Tween = new Tween(hover[i], width, Strong.easeOut, hover[i].width, hover[i].width*2, 1);
    	var tweenH:Tween = new Tween(hover[i], height, Strong.easeOut, hover[i].height, hover[i].height*2, 1);
    }
    But I'm getting these errors (highlighted whats wrong too).

    1120: Access of undefined property i.
    1067: Implicit coercion of a value of type Number to an unrelated type String.
    1120: Access of undefined property i.
    1120: Access of undefined property i.
    1120: Access of undefined property i.
    1067: Implicit coercion of a value of type Number to an unrelated type String.
    1120: Access of undefined property i.
    1120: Access of undefined property i.
    I know why, but I don't know how to fix it. I'm making a sort of gallery thing, here's a screen shot.


    Edit:
    Changed my code to this:
    Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    
    var hover:Array = new Array("car1", "car2", "car3", "car4", "car5", "car6");
    
    addEventListener(Event.ENTER_FRAME, applyEffect);
    
    function applyEffect(e:Event):void
    {
    	for(var i:Number = 0; i < (hover.length); i++){
    		(hover[i]).addEventListener(MouseEvent.MOUSE_OVER, makeBigger);
    	}
    }
    function makeBigger(MouseEvent):void
    {
    	var tweenW:Tween = new Tween(this, "width", Strong.easeOut, this.width, (this.width)*2, 1);
    	var tweenH:Tween = new Tween(this, "height", Strong.easeOut, this.height, (this.height)*2, 1);
    }
    But when I go to Debug Movie, I get:
    http://localhostr.com/files/511c7b/capture.png

    Edit:
    I tried using parameters, but it didn't work either. I'm guessing it has something to do with the array.



    Edit:
    OK, I solved part of my problem, here's my code:
    Code:
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    
    var hover:Array = new Array(car1, car2, car3, car4, car5, car6);
    
    addEventListener(Event.ENTER_FRAME, applyEffect);
    
    function applyEffect(e:Event):void
    {
    	for(var i:Number = 0; i < (hover.length); i++){
    		(hover[i]).addEventListener(MouseEvent.MOUSE_OVER, makeBigger(i));
    	}
    }
    function makeBigger(num:Number):void
    {
    	var tweenW:Tween = new Tween(hover[num], "width", Strong.easeOut, hover[num].width, hover[num].width*2, 1, true);
    	var tweenH:Tween = new Tween(hover[num], "height", Strong.easeOut, hover[num].height, hover[num].height*2, 1, true);
    }
    Here's an example: http://unlinkthis.net/examples/flash...ry/gallery.swf
    HELP
    Last edited by Nile; 05-28-2009 at 07:15 PM.
    Jeremy | jfein.net

  2. #2
    Join Date
    Mar 2007
    Location
    Currently: New York/Philadelphia
    Posts
    2,735
    Thanks
    3
    Thanked 519 Times in 507 Posts

    Default

    Can you summarize where you are at the moment and what errors, if any, you're getting? Also, what is your desired end result?

  3. #3
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    I want this:
    When I hover over the image, it enlarges, mouse out, it gets smaller.

    I don't know why the yellow car gets larger with out me hovering it, but I do know why it keeps enlarging.

    This is what hapens when I click debug -> debug mvoie:


    If you wish to download the files, download them here (tar format).
    Jeremy | jfein.net

  4. #4
    Join Date
    Jan 2008
    Posts
    4,168
    Thanks
    28
    Thanked 628 Times in 624 Posts
    Blog Entries
    1

    Default

    No body? Been more than a day.
    Jeremy | jfein.net

Tags for this Thread

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
  •