dcsimg
A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: three mc's to the highest depth/level?

  1. #1
    Senior Member
    Join Date
    Aug 2006
    Posts
    293

    three mc's to the highest depth/level?

    hi all,

    still wrestling wildly with as3 - i 'do' think it will be worth the migration - but at the moment am trying to get my head around even the simplest of tasks!


    okay if i have three mc's on my stage named sprite1 sprite2 sprite3 and i want them to sit above the image wall created by this script how do i do it?

    PHP Code:
    /*
    Created by Min Thu
        http://www.flashmo.com
        
    AS3 References and Credits
        http://blog.papervision3d.org/
        http://theflashblog.com/?p=306
        http://www.gotoandlearn.com/
        http://www.onerutter.com/
        http://labs.blitzagency.com/
        http://vilebody.wordpress.com/2007/11/29/3d-papervision-plane-events/
    */
    import org.papervision3d.scenes.*;
    import org.papervision3d.cameras.*;
    import org.papervision3d.objects.*;
    import org.papervision3d.materials.*;
    import fl.transitions.Tween;
    import fl.transitions.easing.*;
    import flash.display.Sprite;
    import flash.events.MouseEvent;


    var 
    container:Sprite = new Sprite();
    container.400;
    container.300;
    addChild(container);

    var 
    scene:Scene3D = new MovieScene3D(container);
    var 
    cam:Camera3D = new Camera3D();
    cam.zoom 6;

    tn_title.text "";
    tn_desc.text "";
    tn_url.text "";

    var 
    p_dict:Dictionary=new Dictionary();
    var 
    pc:Plane = new Plane();
    pc.visible false;
    cam.target pc;

    var 
    numOfRotations:Number 3;
    var 
    yPos:Number 0;
    var 
    angle:Number 0;

    var 
    filename_list = new Array();
    var 
    url_list = new Array();
    var 
    url_target_list:Array = new Array();
    var 
    title_list = new Array();
    var 
    description_list = new Array();
    var 
    folder:String "thumbnails/";

    var 
    i:Number;
    var 
    j:Number 0;
    var 
    k:Number 0;
    var 
    l:Number 0;
    var 
    m:Number 0;
    var 
    total:Number;
    var 
    flashmo_xml:XML = new XML();
    var 
    loader:URLLoader = new URLLoader();
    loader.load(new URLRequest("thumbnail_list_3.xml"));
    loader.addEventListener(Event.COMPLETEcreate_thumbnail);

    function 
    create_thumbnail(e:Event):void 
    {
        
    flashmo_xml XML(e.target.data);
        
    total flashmo_xml.thumbnail.length();
        var 
    anglePer:Number = ((Math.PI*2) * numOfRotations) / total;
        
        for( 
    0totali++ )
        {
            
    url_list.pushflashmo_xml.thumbnail[i].@url.toString() );
            
    url_target_list.pushflashmo_xml.thumbnail[i].@target.toString() );
            
    title_list.pushflashmo_xml.thumbnail[i].@title.toString() );
            
    description_list.pushflashmo_xml.thumbnail[i].@description.toString() );
            
            var 
    bfm:BitmapFileMaterial = new BitmapFileMaterial(
                
    folder flashmo_xml.thumbnail[i].@filename.toString());
            
    bfm.oneSide false;
            
    bfm.smooth true;
            var 
    p:Plane = new Plane(bfm14010522);
            
    scene.addChild(p);
            var 
    p_container:Sprite p.container;
            
    p_container.name "flashmo_" i;
            
    p_dict[p_container] = p;
            
    p_container.buttonMode true;
            
    p_container.addEventListenerMouseEvent.ROLL_OVERp_rollover );
            
    p_container.addEventListenerMouseEvent.ROLL_OUTp_rollout );
            
    p_container.addEventListenerMouseEvent.CLICKp_click );
            
            
    p.rotationY = (-i*anglePer) * (180/Math.PI) + 90;
            
    p.Math.cos(anglePer) * 480;
            
    p.Math.sin(anglePer) * 480;
            
    p.yPos;

            if( (
    i+1) % 20 == )
            {
                 
    yPos += 115;
            }
        }
    }

    function 
    p_rollover(me:MouseEvent
    {
        var 
    sp:Sprite me.target as Sprite;
        var 
    tw:Tween = new Tween(sp'alpha'Strong.easeOut10.50.6true);
        var 
    s_no:Number parseInt(sp.name.slice(8,10));
        
    tn_title.text title_list[s_no];
        
    tn_desc.text description_list[s_no];
        
    tn_url.text url_list[s_no];
    }
    function 
    p_rollout(me:MouseEvent
    {
        var 
    sp:Sprite me.target as Sprite;
        var 
    tw:Tween = new Tween(sp'alpha'Strong.easeOut0.510.6true);
        
    tn_title.text "";
        
    tn_desc.text "";
        
    tn_url.text "";
    }
    function 
    p_click(me:MouseEvent
    {
        var 
    sp:Sprite me.target as Sprite;
        var 
    s_no:Number parseInt(sp.name.slice(8,10));
        
    navigateToURL(new URLRequest(url_list[s_no]), url_target_list[s_no]);
    }

    addEventListener(Event.ENTER_FRAMErender);

    function 
    render(e:Event):void
    {
        var 
    dist2:Number = ((stage.mouseX) - 400) * 0.0001;
        
    angle += dist2;
        
    cam.= - Math.cos(angle) * 150;
        
    cam.Math.sin(angle) * 150;
        var 
    new_zoom 5
        
    cam.zoom += ( new_zoom cam.zoom ) * 0.06;
        
    scene.renderCamera(cam);

    that script creates a scrolling image wall but the wall sits above the three mc's and not at a lower depth.

    do i need to create each mc dynamically? something like

    sprite1 = newsprite etc...

    or can i just say that sprite 1,2,3 should appear at depth 10,11,12?

    i also need the mc's to act as a navigation - so if sprite1 is clicked the swf timeline will go to frame2 - and if sprite2 is clicked goto frame3

    how do i do these things in as3? i would be able to do it in as2 but i can't work it out for as3 - some much is different! - anyone shed some light for me? please?

  2. #2
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    PHP Code:
    setChildIndex(sprite1numChildren 1);
    setChildIndex(sprite2numChildren 1);
    setChildIndex(sprite3numChildren 1); 
    That will place your three sprites at the top of the z-ordering.

    Setting up buttons would look like this:

    PHP Code:
    sprite1.addEventListener(MouseEvent.CLICKgoOne);
    sprite2.addEventListener(MouseEvent.CLICKgoTwo);
    sprite3.addEventListener(MouseEvent.CLICKgoThree);

    function 
    goOne(e:MouseEvent):void{
        
    gotoAndStop(1);
    }

    function 
    goTwo(e:MouseEvent):void{
        
    gotoAndStop(2);
    }

    function 
    goThree(e:MouseEvent):void{
        
    gotoAndStop(3);


  3. #3
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...great stuff! thanks for the quick response - appreciate it

    is there anywhere in particular i need to put those bits of code?
    or can i just strip it in at the end of the existing script?

    sorry for asking such a dumb question - but my head is spinning from all this newness!

  4. #4
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    It needs to be in the same scope as your sprites - so I'm assuming they're on the main timeline so you could just put it into a frame there.

  5. #5
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...ahh - okay - separate from the code that i initially posted.

    good stuff - thanks for the help.

    i'll give it a go

  6. #6
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...well there you go!!!
    it works a treat!

    thanks for that - much easy when someone holds your hand.

    **does a little dance**

  7. #7
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...now i have a slightly different question - on the three different frames that the buttons take me to - i want to create the same environment only i want it use a different .xml doc for the actual thumbnails and links.

    so i tried replicating that code in my initial post that creates the carousel - and put it on each frame - which (of course) it didn't work!

    i also tried to trim it down by getting rid of the imports at the start - but that didn't work either.

    do i need to make these extra carousel/walls on the first frame or is it just a case of calling them
    PHP Code:
    addChild(container); 
    and then on frame2
    PHP Code:
    addChild(container2); 
    is that what i should do?

  8. #8
    Senior Member
    Join Date
    Aug 2006
    Posts
    293
    ...or do i just need to tell it to change the xml doc it is reading from?

    ...and if so - how do i do that?

  9. #9
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    Frames are a little tricky in AS3 - they exist in the same code scope but they reset the display-list between them...so in your first frame you're creating a bunch of variables and objects (all that 3D stuff) and then in the second frame all of that history is still around and causing trouble when you try and make new stuff.

    For your specific project, I'd recommend moving that third-party code into a MC on stage so it gets properly cleared between each frame and trying to get it working that way.

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