Results 1 to 4 of 4

Thread: Using arrays to display objects

  1. #1
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default Using arrays to display objects

    typically I have been doing stuff like this
    //This adds a custom cursor quick and dirty
    circle_mc.addEventListener(MouseEvent.CLICK,showThis);
    function showThis(evt:MouseEvent):void
    {
    var circ:MovieClip = new Circ ();
    addChild (circ);
    Mouse.hide();
    circ.x=mouseX
    circ.y=mouseY
    circ.startDrag(true);

    }


    }
    to display mcs on events

    now I really want to make the jump to arrays big time.

    This code is a trainwreck but I hope I can demostrate what I'm trying to do in AS 3
    var cursorSwap:String = new String();
    var i:Number;
    var cursorArray:Array = new Array(

    [my_mc.circle, "circle"],
    [my_mc.circle, "square"],
    [my_mc.circle, "diamond"])

    circle_mc.addEventListener(MouseEvent.CLICK,circleSwap);
    square_mc.addEventListener(MouseEvent.CLICK,squareSwap);
    diamond_mc.addEventListener(MouseEvent.CLICK,diamondSwap);

    function circleSwap(evt:MouseEvent):void
    {Mouse.hide();
    //cursors.circle.startDrag();
    for(i=0; i<cursorArray.length; i++);
    cursorSwap = cursorArray[this.id][1];
    circle.x =mouseX;
    circle.y =mouseY;



    }
    What I really want to learn how to do is call items either from the library,
    a frame in a movieclip and either just diplay them or drag them around as with a cursor.

    Most demos I see handle DATA, or just return a string using "trace" I get that but I wish I could see stuf that is more visual.
    Last edited by evan; 07-28-2008 at 10:02 PM. Reason: correction

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

    Default

    Are you trying to do something similar to my very first example -- but in AS3?

  3. The Following User Says Thank You to Medyman For This Useful Post:

    evan (07-29-2008)

  4. #3
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    Somewhat,


    because:
    var circ:MovieClip = new Circ ();
    addChild (circ);
    circ.x=-100
    circ.y=-100

    circle_mc.addEventListener(MouseEvent.CLICK,showIt, false, 0, true);
    function showIt(evt:MouseEvent):void
    {

    pad.addEventListener(MouseEvent.ROLL_OVER,showThis, false, 0, true);

    }



    function showThis(evt:MouseEvent):void
    {
    Mouse.hide();
    circ.alpha=(1);
    circ.x=mouseX
    circ.y=mouseY
    circ.startDrag(true);

    pad.addEventListener(MouseEvent.ROLL_OUT,hideThis, false, 0, true);
    function hideThis(evt:MouseEvent):void
    {
    Mouse.show();
    circ.alpha=0;
    }


    }
    works well -but 12 times or so -not cool

    such is why I ask.


    So, I'm also revisiting "wise words".


    and looking at some postings here having to do with xml.

    If you have the time though -yeah it would be cool to see a demo of the way that array called mc from frames of another mc -in AS3.

    Any sugested links or tutorials also?
    Last edited by evan; 07-29-2008 at 04:18 PM.

  5. #4
    Join Date
    Jan 2008
    Location
    Near Chicago
    Posts
    247
    Thanks
    105
    Thanked 2 Times in 2 Posts

    Default

    Are you trying to do something similar to my very first example -- but in AS3?

    Mendyman,
    If you have the time to show me a "mini-version" of how the cursor change code works in AS3 it would be huge.

    I DO have an AS3 version that works -just without the arrays -all it means is that I have separate functions for each button to target a frame in the "cursor" mc. It works. but it's not as cool.

    using one mc to store all the icons is the best way
    there are other ways like swap out mcs with booleans and else if statements but it's not as straight forward.
    Last edited by evan; 07-30-2008 at 06:17 PM. Reason: Simplified

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
  •