A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: Dynamic Scaling?

  1. #1
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155

    Dynamic Scaling?

    Hi Everyone,

    I am trying to make a game with a realistic laser scope in it. What I am looking for is a script that cam be placed on the laser scope MC (which is part of the character MC) that will dynamically adjust it's width to fit in between the character MC and objects such as walls, enemies, etc.

    How would I go about doing this?

    Thanks,

    Mr_Welfare

    Using Flash MX 2004

  2. #2
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    If this isn't possible, could someone please let me know so I can find another method?

  3. #3
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    dont understand the question...make it a bit more clear?maybe draw a diagram explaining it?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  4. #4
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    Ok sorry about being unclear. I hope this quick diagram sums things up well enough.

    http://i108.photobucket.com/albums/n...er/Example.gif

    Mr_Welfare

  5. #5
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    Is it still unclear? Sorry if it is. I can take a little more time on the diagram if you want.

  6. #6
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    If i understand correctly..why not just use the lineTo() method between the movieclips?
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  7. #7
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    I've never heard of it. Could you explain?

    Thanks.

  8. #8
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    its a movieclip method for drawing lines..heres an example i did sometime ago..

    create two movieclips on stage for example square1_mc and square2_mc and use the following code..whenever u drag them a line will be between them..

    Code:
    
    _root.lineStyle(1, 0, 100);
    _root.moveTo(square1_mc._x, square1_mc._y);
    _root.lineTo(square2_mc._x, square2_mc._y);
    
    
    _root.onMouseMove = function() {
    	clear();
    	_root.lineStyle(1, 0, 100);
    	_root.moveTo(square1_mc._x, square1_mc._y);
    	_root.lineTo(square2_mc._x, square2_mc._y);
    	updateAfterEvent();
    };
    
    
    for (var i = 1; i<3; i++) {
    	
    	_root["square"+i+"_mc"].onPress = function() {
    		this.startDrag();
    	};
    	
    	_root["square"+i+"_mc"].onRelease = function() {
    		this.stopDrag();
    	};
    	
    	_root["square"+i+"_mc"].onReleaseOutside = function() {
    		this.stopDrag();
    	};
    }
    Note ive defined the event handlers in a loop so as to prevent code duplication

    also do a search on google for the lineTo() method or look in flash docmentation
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  9. #9
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    Ok. This connects two objects together with a line. How would I go about editing this script so that the line would be "connected" to the front of the characters gun, and so it would be able to fit in between multiple mcs?

  10. #10
    Flashmatics silentweed's Avatar
    Join Date
    Mar 2005
    Location
    London, UK
    Posts
    4,876
    put a tiny invisible movieclip on the tip of the gun and use that as the mc the the line connects to.. or make the tip of the gun the registration point instead.. how exactly do u want it to connect to multiple mcs? maybe draw another diagram? i'll check this post tommorow..anyway im off to sleep dude..amost 1am here lol..
    Flashmatics | Flashmatics Library (free downloads)
    -----------------------------------------------------
    Latest Projects:
    The Dead Room | Are You Smarter | Prison Break (Frame A Friend) | Beck's Fusions | The 24 Experience

    -----------------------------------------------------
    Flash Certified Developer

  11. #11
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    I'm afraid I failed to illustrate how the character rotated.

    http://i103.photobucket.com/albums/m...e/Diagram2.gif

    Here is a better diagram.

    Note: The laser could hit an object at any angle or place.

    Also, the last laser stops a little short (It was offscreen in flash, but not in the photo)

  12. #12
    Flash Game Maker Mr_Welfare's Avatar
    Join Date
    Sep 2005
    Location
    Canada
    Posts
    155
    Well, if this isn't possible, (based on what some other people have told me, I'm starting to think that it isn't.) Does anyone know of a way that could come in any way close to this?

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