Solved

Local shared object

Posted on 2009-07-09
13
230 Views
Last Modified: 2013-11-11
I am new to using LSO's.  I have it working for TextFields.  I need to have it work on a movieclip. The movieclip has 4 frames. When the return_btn button is clicked I would like to store the current frame of the mix01 movieclip in the editText01 LSO.  
This works for the TextFields, editText01_so.data.TextField2 = myTextField2.text;
This does not work on the movieclip, editText01_so.data.mix01Frame = mix01.currentFrame;
this.return_btn.onRelease = function() {

	editVuhfPresets_so.data.TextField2 = myTextField2.text;

	editVuhfPresets_so.data.TextField6 = myTextField6.text;

	editVuhfPresets_so.data.TextField8 = myTextField8.text;

	editVuhfPresets_so.data.mix01Frame = mix01.currentFrame;

					gotoAndStop(2);

};

Open in new window

0
Comment
Question by:boblandess
  • 7
  • 6
13 Comments
 
LVL 22

Expert Comment

by:rascalpants
ID: 24817168
what do you get when you trace out...

trace( mix01.currentFrame );


rp
0
 

Author Comment

by:boblandess
ID: 24822334
It returns with "undefined"
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24823761
that be your problem...   :)

you are storing a value that does not exist.

so you scope if probably off...  make sure that you have your paths right


rp
0
 

Author Comment

by:boblandess
ID: 24824061
I am certain that the paths are correct.  I have verified it a couple different ways.  1 using insert target path and the other way using copy and paste from a different line of code that changes the frames of the movieclip mix02 which is inside the movieclip editVuhfScreen01.
I have tried starting the path with _root and this. I have also tried using _currentframe and currentFrame.
Still no luck.

//stores data in editVuhfPresets shared object

this.return_btn.onRelease = function() {

	editVuhfPresets_so.data.TextField2 = myTextField2.text;

	editVuhfPresets_so.data.TextField6 = myTextField6.text;

	editVuhfPresets_so.data.TextField8 = myTextField8.text;

	editVuhfPresets_so.data.mix02Frame = this.editVuhfScreen01.mix02.currentFrame;

		gotoAndStop(2);

};
 

//fills textField data with data from editVuhfPresets shared object

stop();

editVuhfPresets_so = SharedObject.getLocal("editVuhfPresetsScreen");

myTextField2.text = editVuhfPresets_so.data.TextField2

myTextField6.text = editVuhfPresets_so.data.TextField6

myTextField8.text = editVuhfPresets_so.data.TextField8

this.editVuhfScreen01.mix02.currentFrame = editVuhfPresets_so.data.mix02Frame

Open in new window

0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24824518
AS 3 uses no underscore...  looks like you are using AS 2, so you DO need that underscore.


I just created a test project...  it has a button, a movieclip with a dynamic text field, and a movieclip that has a 50 frame animation.

here is the code I use on the button...

btn.onRelease = function(){
   textBox.txt1.text = muv._currentFrame;
};


I compile the SWF and when I click on the button, the text box gives me the current frame of the other movieclip...


so there must be a scoping issue going on...

test the below...

trace( editVuhfScreen01.mix02 );


BTW... by using "this" in the onRelease function, you are actually scoping to the return_btn's function, not the root.  "this" is a keyword that is used to define the current field of scope... in your above code, that scope is within the onRelease function... not the  root of the SWF.


rp
0
 

Author Comment

by:boblandess
ID: 24838802
rascalpants,
Thanks for the info about scope and "this".  I'm not sure I am following your example.  Although the return_btn does affect some textFields my concern is about a 4 frame movieclip and not any of the textFields.  I have the textFields working as desired with the exception that I have posted a question about here, http://www.experts-exchange.com/Software/Photos_Graphics/Web_Graphics/Macromedia_Flash/ActionScript/Q_24557567.html
This is what the trace returnred,  _level0.editVuhfScreen01.mix02.
Below is the code on frame 3.  it's working for the textFields but is not capturing the current frame of the mix02 movieclip.  It may be capturing the current frame data of the mix02 movieclip and not loading it when coming back to frame 3 from frame 2.

//stores data in editVuhfPresets_so shared object and then returns to frame 2
return_btn.onRelease = function() {
 editVuhfPresets_so.data.TextField2 = myTextField2.text;
 editVuhfPresets_so.data.TextField6 = myTextField6.text;
 editVuhfPresets_so.data.TextField8 = myTextField8.text;
 editVuhfPresets_so.data.mix02Frame = editVuhfScreen01.mix02._currentframe;
  gotoAndStop(2);
};

//fills textField data with data from editVuhfPresets_so shared object when coming back to frame 3 from frame 2
stop();
editVuhfPresets_so = SharedObject.getLocal("editVuhfPresetsScreen");
myTextField2.text = editVuhfPresets_so.data.TextField2
myTextField6.text = editVuhfPresets_so.data.TextField6
myTextField8.text = editVuhfPresets_so.data.TextField8
editVuhfScreen01.mix02._currentframe = editVuhfPresets_so.data.mix02Frame

0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 

Author Comment

by:boblandess
ID: 24840460
I have moved the mix02 movieclip to the top level and when doing a trace it now returns a frame number.  I still can not seem to get it to save the frame number to the LSO when clicking on the return_btn button which takes the user to the previous frame (2).  If it is saving the info to the LSO it is not loading when going back to the frame 3.  The code below is on frame 3.
//change the frame of the mix02 movieclip
mix_btn.onPress = function(){
if (mix02._currentframe < 4) {mix02.nextFrame();
}
else{mix02.gotoAndStop(1);
}
}

 
//stores data in editVuhfPresets shared object and goes back to frame 2
return_btn.onRelease = function() {
 editVuhfPresets_so.data.mix02 = mix02._currentframe;
 trace (mix02._currentframe);
  gotoAndStop(2);
};

//fills textField data with data from editVuhfPresets shared object
stop();
editVuhfPresets_so = SharedObject.getLocal("editVuhfPresetsScreen");
mix02._currentframe = editVuhfPresets_so.data.mix02
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24841586
I think your issue that is causing all of the problems is that you have code on multiple frames, and I was assuming everything was on one frame that controlled eveything...  this is normally the standard practive for framescripting.

you are probably loosing scope by having code in multiple frames that do not span across all frames that need to use the code.


rp
0
 

Author Comment

by:boblandess
ID: 24841956

That may be true although I am very skeptical.  
Why does it work exactly as needed for text  fields doing the same thing as I want to do with capturing and retrieving current frame data?  In fact for the text fields it works when I go back and forth between scenes as well as frames?   Using an LSO should eliminate the reason you give,  especially when you consider that  you can pass LSO data between completely different swf files.


In the previous post I removed the lines with the text field codes for clarity.  They are included below. 

this.return_btn.onPress = function(){
 editHfPresets_so.data.TextField2 = myTextField2.text;
 editHfPresets_so.data.TextField4 = myTextField4.text;
 editHfPresets_so.data.TextField6 = myTextField6.text;
 editHfPresets_so.data.TextField8 = myTextField8.text;
        editHfPresets_so.data.usbAme01 = usbAme01._currentframe;
 trace( usbAme01._currentframe );
 gotoAndStop("dat", 28);
}


//fills textField data with data from editHfPresets shared object
stop();
editHfPresets_so = SharedObject.getLocal("editHfPresets_so");
myTextField2.text = editHfPresets_so.data.TextField2
myTextField4.text = editHfPresets_so.data.TextField4
myTextField6.text = editHfPresets_so.data.TextField6
myTextField8.text = editHfPresets_so.data.TextField8
       usbAme01._currentframe = editHfPresets_so.data.usbAme01
0
 
LVL 22

Expert Comment

by:rascalpants
ID: 24843210
oh, I thought you said it wasn't working when you switch between the frames... I misunderstood then...

if you have access, maybe you should post your FLA somewhere and post the link


rp
0
 

Assisted Solution

by:boblandess
boblandess earned 0 total points
ID: 24858456
I got it to work using the following code.

//this captures the current frame data
editVuhfPresets_so.data.frame = mix02._currentframe

//this loads the current frame data
mix02.gotoAndStop(editVuhfPresets_so.data.frame);

The below is all the code that the above two lines of code are used with.

//stores data in editVuhfPresets shared object
return_btn.onRelease = function() {
 editVuhfPresets_so.data.TextField2 = myTextField2.text;
 editVuhfPresets_so.data.TextField6 = myTextField6.text;
 editVuhfPresets_so.data.TextField8 = myTextField8.text;
 editVuhfPresets_so.data.frame = mix02._currentframe
  gotoAndStop(2);
};

//loads shared object data with from editVuhfPresets shared object
stop();
var editVuhfPresets_so:SharedObject = SharedObject.getLocal("editVuhfPresetsScreen");
myTextField2.text = editVuhfPresets_so.data.TextField2
myTextField6.text = editVuhfPresets_so.data.TextField6
myTextField8.text = editVuhfPresets_so.data.TextField8
mix02.gotoAndStop(editVuhfPresets_so.data.frame);
 
0
 
LVL 22

Accepted Solution

by:
rascalpants earned 250 total points
ID: 24859260
that is pretty funny how you allocated the points...  you could have just accepted any comment as an acceptable answer... would have taken you less time  :)

Also, for future reference, you can select the "Accept Multiple Solutions" or the "Accept as Solution" options, instead of using the close/delete system.  It takes less resources.

if you want me to fix this for you, just le me know...


rp
0
 

Author Comment

by:boblandess
ID: 24859472
If you would fix it I would appreciate it.  Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now