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

Closed Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 11
  1. #1

    Default Using getURL with passed data and onRelease

    I have been working on this project for some time. I was able to grab all the info and images I need except for the correct URL data on a button.

    Here is my code:
    Code:
     //Import
    import mx.utils.Delegate;
    import mx.transitions.Tween;
    import mx.transitions.easing.*;
    //Variables
    var numOfItems:Number;
    var radiusX:Number = 250;
    var radiusY:Number = 60;
    var centerX:Number = Stage.width / 2;
    var centerY:Number = 250;
    var speed:Number = 0.003;
    var perspective:Number = 130;
    var home:MovieClip = this;
    theText._alpha = 0;
    URLbtn._alpha = 0;
    myLink = 0;
    
    var tooltip:MovieClip = this.attachMovie("tooltip","tooltip",10000);
    tooltip._alpha = 0;
    //functions
    var xml:XML = new XML();
    xml.ignoreWhite = true;
    
    xml.onLoad = function()
    {
        var nodes = this.firstChild.childNodes;
        numOfItems = nodes.length;
        for(var i=0;i<numOfItems;i++)
        {
            var t = home.attachMovie("item","item"+i,i+1);
            t.angle = i * ((Math.PI*2)/numOfItems);
            t.onEnterFrame = mover;
            t.toolText = nodes[i].attributes.tooltip;
            t.content = nodes[i].attributes.content;
            t.icon.inner.loadMovie(nodes[i].attributes.image);
            t.r.inner.loadMovie(nodes[i].attributes.image);
            t.icon.onRollOver = over;
            t.icon.onRollOut = out;
            t.icon.onRelease = released;
            myLink = nodes[i].attributes.urllink;
            }
            function callGetLink(urllink){
                getURL(myLink);
                trace(myLink);
                };
    
            URLbtn.onRelease = function() {
                callGetLink(urllink);
                trace(myLink);
             };
    
            }
    
    function over()
    {
        //BONUS Section
        var sou:Sound = new Sound();
        sou.attachSound("sover");
        sou.start();
        
        home.tooltip.tipText.text = this._parent.toolText;
        home.tooltip._x = 295;
        home.tooltip._y = 380;
        home.tooltip.onEnterFrame = Delegate.create(this,moveTip);
        home.tooltip._alpha = 100;
    }
    
    function out()
    {
        delete home.tooltip.onEnterFrame;
        home.tooltip._alpha = 0;
    }
    
    function released()
    {
        //BONUS Section
        var sou:Sound = new Sound();
        sou.attachSound("sdown");
        sou.start();
        
        home.tooltip._alpha = 0;
        for(var i=0;i<numOfItems;i++)
        {
            var t:MovieClip = home["item"+i];
            t.xPos = t._x;
            t.yPos = t._y;
            t.theScale = t._xscale;
            delete t.icon.onRollOver;
            delete t.icon.onRollOut;
            delete t.icon.onRelease;
            delete t.onEnterFrame;
            if(t != this._parent)
            {
                var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,0,1,true);
                var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,t._yscale,0,1,true);
                var tw3:Tween = new Tween(t,"_alpha",Strong.easeOut,100,0,1,true);
            }
            else
            {
                var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,t._xscale,100,1,true);
                var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,t._yscale,100,1,true);
                var tw3:Tween = new Tween(t,"_x",Strong.easeOut,t._x,120,1,true);
                var tw4:Tween = new Tween(t,"_y",Strong.easeOut,t._y,300,1,true);
                var tw5:Tween = new Tween(theText,"_alpha",Strong.easeOut,0,100,1,true);
                var tw5:Tween = new Tween(URLbtn,"_alpha",Strong.easeOut,0,100,1,true);
                theText.text = t.content;
                
    
                var s:Object = this;
                tw.onMotionStopped = function()
                {
                    s.onRelease = unReleased;
                }
            }
        }
    }
    
    
    function unReleased()
    {
        //BONUS Section
        var sou:Sound = new Sound();
        sou.attachSound("sdown");
        sou.start();
        
        delete this.onRelease;
        var tw:Tween = new Tween(theText,"_alpha",Strong.easeOut,100,0,0.5,true);
        var tw:Tween = new Tween(URLbtn,"_alpha",Strong.easeOut,100,0,0.5,true);
        for(var i=0;i<numOfItems;i++)
        {
            var t:MovieClip = home["item"+i];
            if(t != this._parent)
            {
                var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,0,t.theScale,1,true);
                var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,0,t.theScale,1,true);
                var tw3:Tween = new Tween(t,"_alpha",Strong.easeOut,0,100,1,true);
            }
            else
            {
                var tw:Tween = new Tween(t,"_xscale",Strong.easeOut,100,t.theScale,1,true);
                var tw2:Tween = new Tween(t,"_yscale",Strong.easeOut,100,t.theScale,1,true);
                var tw3:Tween = new Tween(t,"_x",Strong.easeOut,t._x,t.xPos,1,true);
                var tw4:Tween = new Tween(t,"_y",Strong.easeOut,t._y,t.yPos,1,true);
                tw.onMotionStopped = function()
                {
                    for(var i=0;i<numOfItems;i++)
                    {
                        var t:MovieClip = home["item"+i];
                        t.icon.onRollOver = Delegate.create(t.icon,over);
                        t.icon.onRollOut = Delegate.create(t.icon,out);
                        t.icon.onRelease = Delegate.create(t.icon,released);
                        t.onEnterFrame = mover;
                    }
                }
            }
        }
    }
    
    
    function moveTip()
    {
        home.tooltip._x = 295;
        home.tooltip._y = 380;
    }
    
    xml.load("icons.xml");
    
    
    function mover()
    {
        this._x = Math.cos(this.angle) * radiusX + centerX;
        this._y = Math.sin(this.angle) * radiusY + centerY;
        var s = (this._y - perspective) /(centerY+radiusY-perspective);
        this._xscale = this._yscale = s*100;
        this.angle += this._parent.speed;
        this.swapDepths(Math.round(this._xscale) + 100);
    }
    //loaders
    this.onMouseMove = function()
    {
        speed = (this._xmouse-centerX)/1500;
    }
    I have a feeling that it is something simple. but I just can't get it. it keeps passing the URL value for the last node in the list.

    HELP ME PLEASE!!!!

    Thank You,

    Jon

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

    Default

    Hi,

    The problem appears to be how you have "myLink" defined. Since it is in a for loop, only the last cycle of the for loop is assigned as "myLink". You will probably need to pull that variable out of the for loop and find a way to idenitify each individual link selected. Once the link is identified,you can use it as hard coded or you can then use a for loop to cycle through your array of links to detect a match and proceed from there.

    myLink = nodes[i].attributes.urllink;
    ...will only return the last iteration of the for loop...

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

  4. #3

    Default

    How would I do this then? Could I use "i" as the array identifier or could I rewrite the for loop to be a Global Variable somehow?

  5. #4
    Join Date
    Feb 2008
    Posts
    570

    Default

    and as NTD stated you can "push" these values into an Array

    here are also some other things you can do:

    in this example you could have a button - (instance "URLbtn") inside the attached clip:

    So inside the loop you could do:

    Code:
     
    t.URLbtn.onRelease = function() {
    getURL(nodes[i].attributes.urllink);
    }
    ____________________________________

    you can also set variables to attached clips-

    t.urlLink = nodes[i].attributes.urllink;


    *This is nice because you already have the link associated with the clip for later use.
    you could refer to them by instance name of the clip:
    movieInstance.urlLink

    from inside the movie or a function attached to the clip(s) -
    this.urlLink

    help?
    Last edited by blitzzz; 08-04-2008 at 12:49 AM.

  6. #5

    Default

    I tried this and it doesn't seem to be getting to the URLbtn though.

    Code:
    ........
            t.icon.onRelease = released;
            t.urllink = nodes[i].attributes.urllink;
            t.URLbtn.onRelease = function() {
                getURL(nodes[i].attributes.urllink);
                trace('clicked');
                
            }
            trace(nodes[i].attributes.urllink);
        }
    
        }
    
    function over()
    ........
    Last edited by electrikjesus; 08-04-2008 at 03:31 PM.

  7. #6
    Join Date
    Feb 2008
    Posts
    570

    Default

    I tried this and it doesn't seem to be getting to the URLbtn though.
    is your button inside the movie clip- "item" that is attached?
    Last edited by blitzzz; 08-04-2008 at 07:14 PM.

  8. #7

    Default

    No it isn't. And When I tried to move it to that movie clip. I never got a mouseover when it showed.

    Scene 1
    -----
    Text----
    -Frame 1
    Text1 (theText)
    read more (URLbtn)
    -----
    Actions----
    -Frame 1
    Actions for Frame 1

    Thank You for your help so far

    -

  9. #8
    Join Date
    Feb 2008
    Posts
    570

    Default

    No it isn't. And When I tried to move it to that movie clip. I never got a mouseover when it showed.
    Ok - try this it might give you an understanding:

    you have a movie clip in your library with a "linkage identifier" of "item".

    double click on that movie in the library. it now should open up so you can edit it / add things to it.

    make a button - give it an "instance name" of "URLbtn".
    you add the instance name by selecting the button within/inside the "item" movie clip -
    with the button selected add the instance name in the properties window.
    (note: this is not a "linkage identifier" just a simple instance)

    Code:
    t.urlLink = nodes[i].attributes.urllink;
            t.URLbtn.onRelease = function() {
                  trace(this._parent.urlLink);
            }
    the button(s) should trace the value of the respective url(s)

    note we use this._parent because urlLink is assigned to the movie clip that contains the button..

    __________________________________________________ ____

    you can also assign a variable directily to that button :

    Code:
    t.URLbtn.urlLink = nodes[i].attributes.urllink;
            t.URLbtn.onRelease = function() {
                  trace(this.urlLink);
            }
    and now it can be traced with the target path this. = the current object the function is on..

    understand? help?
    Last edited by blitzzz; 08-05-2008 at 04:14 AM.

  10. #9

    Default

    I have worked at this for hours now to try to get this to work.

    With no luck.

    Will one of you PM me and I can send you the .fla that I am working with.

    Please?

    Thanks.

  11. #10
    Join Date
    Feb 2008
    Posts
    570

    Default

    try this here -

    Code:
     
     
     for(var i=0;i<numOfItems;i++)
        {
            var t = home.attachMovie("item","item"+i,i+1);
            t.angle = i * ((Math.PI*2)/numOfItems);
            t.onEnterFrame = mover;
            t.toolText = nodes[i].attributes.tooltip;
            t.content = nodes[i].attributes.content;
            t.icon.inner.loadMovie(nodes[i].attributes.image);
            t.r.inner.loadMovie(nodes[i].attributes.image);
            t.icon.onRollOver = over;
            t.icon.onRollOut = out;
            t.icon.onRelease = released;
            // *** part to edit below 
            t.URLbtn.urlLink = nodes[i].attributes.urllink;
            t.URLbtn.onRelease = function() {
                    getURL(this.urlLink);
                    }        
            }
    do this below -

    you have a movie clip in your library with a "linkage identifier" of "item".

    double click on that movie in the library. it now should open up so you can edit it / add things to it.

    make a button - give it an "instance name" of "URLbtn".
    you add the instance name by selecting the button within/inside the "item" movie clip -
    with the button selected add the instance name in the properties window.
    (note: this is not a "linkage identifier" just a simple instance)
    understand this part?

    did you get it to work now?

    still need help?
    Last edited by blitzzz; 08-07-2008 at 05:21 PM.

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