Can anyone help create a persistent Widget?

el-codes
by el-codes · 2 posts
3 years ago in Flash
Posted 3 years ago · Author
Don't even know if there are still any Flash devs still around... butttt...

I've created a music player that streams MP3s from dropbox... which works flawless except for one issue. When you step off the dot the widget disappears. The code is still running, and music will continue to play. If you step back on the dot again it loads a new instance. I'm still new to IMVU API, and I figured I needed to load the widget in to the Widget Space with;

Code
this.space.loadWidget(appPath);


However, when stood on the dot this continuously creates new instances of the widget until you step off the dot. So I tried to add a custom boolean to the space.widgets array. This seemed to work better, as you can step off the dot and you have a persistent player that works. However, it caused a new issue of breaking the sync functionality as the other widgets don't seem to hear the fireRemoteEvent() function. Also, this seems to break the close button which was using this.space.unloadWidget(appPath) to close.

I found this forum post;
https://www.imvu.com/groups/group/Flash/read.php?448747,55257809

Which seems to separate the visuals of the widget into a custom object which is then loaded on to the stage... however this seems to be a clumsy work around and I think this will also break the sync functionality. Also, since I used all stock Flash graphics, not really sure how I'd seperate them since technically there is nothing to load.

Anyone got any ideas? I'm rapidly running out of them.... :kat_emoji8:

My code for initWidget:
Code
package {
    import com.imvu.widget.*;
    import com.imvu.widget.WidgetSpace;
    import com.imvu.events.*;
    import flash.events.*;
    import fl.motion.Color;
   import flash.display.*;
   import flash.media.*;
   import flash.net.*;

    public class MusicPlayer extends ClientWidget
   {               
      //global variables declared here. Removed to clean up post.
         
        public function initWidget():void
      {      
         stop();
         if (this.space.widgets.MizMusicPlayer != true)
         {
            //var appPath: String = this.url; // Commented out for testing.
            //this.space.loadWidget(appPath);
            
            //I create arrays here for links. Removed to clean up code
         
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
         
         nowPlayingLabel.text = "Nothing Playing";
         songPlayingLabel.text = "";
      
         var newRow:int = 0;
         var plNum: int = 0;
      
         for each (var listItem:String in plArray)
         {
            newRow++;
            //playlists.push(listItem..playlisttitle);
            playlistDrop.addItem( {label: newRow + ": " + plArray[plNum] });
            plNum++;
         }
         
         populateSonglist(currPlaylist);
      
         //add listeners
         playlistDrop.addEventListener(Event.CHANGE, dropChange);
         songListField.addEventListener(Event.CHANGE, songSelected);
         volControl.addEventListener(Event.CHANGE, changeVol);
         muteButt.addEventListener(MouseEvent.CLICK, muteButtPressed);
         hideButt.addEventListener(MouseEvent.CLICK, hideButtPressed);
         showButt.addEventListener(MouseEvent.CLICK, hideButtPressed);
         SyncButton.addEventListener(MouseEvent.CLICK, syncButtPressed);
         soloButt2.addEventListener(MouseEvent.CLICK, syncButtPressed);
         closeButt.addEventListener(MouseEvent.CLICK, closeButtPressed);
         this.addEventListener("playSong", this.playSong);
         
         showButt.visible = false;
         soloButt2.visible = false;
         setDefaultArtwork();
         this.space.widgets.MizMusicPlayer=true;
            
         }
         else
         {
            return; // This was a test to try and stop it creating multiple instances..... Didn't work.
         }
         
        } // End InitWidget
   
        //Rest of code goes here. Will post if needed. Removed to clean up post.
   
   
Posted 3 years ago
@el-codes


This might help you out; it is my collection of fireRemoteEvent tutorials and issues / solutions:

fireRemoteEvent tuts and issues.zip


I think the issue / solutions discussed in thread number 12593 is exactly what you are looking for.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT
Select a forum Protection     Help & Support     Introductions     Mafia News     IMVU News General Discussion     IMVU Lounge        IMVU Series / Roleplaying        Social Games     Mafia Market     Mafia Tools        Premium IMVU Tools        Off Topic Tools     Off Topic     Contests Creator Corner     Graphics Design        Photoshop        GIMP     Basic Creator Help     Catalog And Product Showcase     3D Meshing        3Ds Max        Sketchup        Blender Gangsters with Connections     White Hat Activities        Google Hacking        Trackers Programming Corner     Coding        Python        .Net (C#, VB, etc)        Flash        JAVA        Autoit        Batch        HTML & CSS        Javascript        PHP        Other        IMVU Homepage Codes           General           About me Panel           Messages Panel           Special Someone Panel           Visitors Panel           New Products Panel           Rankings Panel           Wishlist Panel           My Badges Panel           Outfits Panel           Url Panel           Groups Panel           Slideshow Panel           My Room Panel           Sandbox panel           Layouts     Help & Requests Free Credits     Approved Methods     Submit Methods Free Money     Approved Methods     Submit Methods Adult Corner     Get Mafia AP Here     AP Lounge        AP Social Games        Casual Dating Tips     IMVU Slave Market & Escorts