A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Can anyone help me out - shared Object

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Posts
    18

    Can anyone help me out - shared Object

    hi all,

    i have built up a code, in which i can store the current animation loaded in a presentation in a list component, just similar to add to favorite one .

    I am using the Local Shared Object one with the list component.

    This is the code so far i developed

    var so:SharedObject;
    var fname:String;

    addFav.onRelease = function()
    {
    so = SharedObject.getLocal("myMovie","/");
    so.data.filePath = loader._url;
    _root.myList.addItem(so.data.filePath);
    _root.so.flush();
    trace(so.flush());
    }

    var listListener:Object = new Object();
    listListener.change = function(evt_obj:Object) {
    fname = evt_obj.target.value;
    loadMovie(fname,"loader");
    }
    myList.addEventListener("change", listListener);


    everything works fine with this code.While clicking the add to fav button, the current animation running (url of the swf) is stored in the list component, and when i click it back it is playing.

    But, when i close and re-open the file, i am not getting the stored names in the list component.

    Even though i am using the flush method, why it is not showing.

    Can anyone put up their knowledge in this code, so that i will complete this.

    thanks in advance


    cheers
    saikiran
    saisen76@hotmail.com

  2. #2
    FK Newb Beater
    Join Date
    Dec 2002
    Location
    Seattle
    Posts
    676
    you need to set a variable to the value of the SO before it can be used.
    Code:
    addFav.onRelease = function ()
    {
    	so = SharedObject.getLocal ("myMovie", "/");
    	if (so.data.filePath)
    	{
    		var url = so.data.filePath;
    		myList.addItem (url);
    	} else
    	{
    		so.data.filePath = loader._url;
    		myList.addItem (so.data.filePath);
    		so.flush ();
    	}
    };
    Just because you changed the code, doesn't mean it's yours

    Most Recent Work:
    Commercial tanning beds website

  3. #3
    Junior Member
    Join Date
    Mar 2006
    Posts
    18

    LSO Prob - Still not resolved

    hi sleeve,

    thank u for ur help. As per ur rep, i changed my code but not getting the desired output.

    But, when i close and re-open the file, i am not getting the stored names in the list component.

    What i want is whenver we play the movie again, i want the urls to be shown to the user.


    but, it is showing empty.

    kindly help me out, as this is my project.

    cheers
    sai
    saisen76@hotmail.com

  4. #4
    FK Newb Beater
    Join Date
    Dec 2002
    Location
    Seattle
    Posts
    676
    The above code assumes the user will click the addFav button to load the previously stored info in the shared object. If you want it to load without user interaction, simply take it out of the onRelease event.
    Code:
    so = SharedObject.getLocal ("myMovie", "/");
    if (so.data.filePath)
    {
        myList.addItem (so.data.filePath);
    }
    this should work but I have not tested it so forgive me if you have to adjust it a bit.
    Just because you changed the code, doesn't mean it's yours

    Most Recent Work:
    Commercial tanning beds website

  5. #5
    Junior Member
    Join Date
    Mar 2006
    Posts
    18
    hi sleeve,

    Once again thank u. i think i am not clearly explained u what i am trying to do.Sorry, let me explain it now properly

    The above code assumes the user will click the addFav button to load the previously stored info in the shared object.
    What i want is not the above quoted one.

    When the movie starts, user is viewing the presentation, and their will be a button called add to favorites.Whenever user presses this button, i want to store the url of the current movie running into a list component.. This part i have got it perfectly.

    Once, u closed the movie and once again re-start it, i want those URLs to be displayed in the List component as it is. This is not happening with me. In this case, whenever i re-start the movie, i am getting a blank List component.

    If i click add to Favorites then once again it get stored in the list component.The shared object is not persisted in my case.

    Can this logic works out:-

    Whenver, i press add to favorite, i will show two options, to the user, one is add and the other one is show.

    when they press add option, it will add and when they press show option, it will show.

    but in this case, what will the code i have to use in the two options ?

    now, i hope i clearly explained to u whats my goal is. (if my english is poor, pardon me)


    cheers
    saikiran

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