Flashblocks Flash CMS
Welcome, Guest
Please Login or Register.    Lost Password?
Saving a text field value w/o invoking text editor (1 viewing) (1) Guests
Go to bottom Post Reply Favoured: 0
TOPIC: Saving a text field value w/o invoking text editor
#5610
Saving a text field value w/o invoking text editor 2 Months, 2 Weeks ago
I would like to save a value within an "edit-blocked" dynamic text field. The value is not being modified by the text editor, but rather through code (more specifically, a slider I created) in the application. When I modify the value in the text field & try to save, I get the message to "Please Make Changes Before Saving".

My guess is that Flashblocks does not consider the text field itself to be the object that is to be compared/saved, and is looking for a change somewhere else (maybe a temporary xml object that gets saved back to dataFile.xml?) and/or looking for another event.

Could you explain a method where I could save a string from a text field (via an editblock I presume), either on the fly or by having a 'fake' text field present to hold the data (the method I'm using now?) Ideally I'd love to have a way that allowed me to save data without having to worry about an editblock- but I do I understand how they are critical to the process.
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/09/20 01:01 By thinkspring.
  The administrator has disabled public write access.
#5612
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Saving a text field value w/o invoking text editor 2 Months, 2 Weeks ago
You could modify TheData Object directly. But you would need to edit something using an actual editor (like the text editor) before you will be allowed to save.
Code: :

  var fbListen:Object = {}; fb0.addEventListener("complete"fbListen); fbListen.complete = function(obj:Object){     trace(flashblocks.Flashblocks.TheData.fb0.gallery_title1.pre[0].theContent)     flashblocks.Flashblocks.TheData.fb0.gallery_title1.pre[0].theContent "New Title" }


The above example does the following:
1. we wait for the Flashblocks fb0 instance's data file to load.
2. we trace some contents from the data file.
3. we then modify the contents

If you wish to see the entire TheData Object then place this actionscript in the above event listener:
Code: :

 flashblocks.Flashblocks.TraceObject(flashblocks.Flashblocks.TheData)

 
Report to moderator   Logged Logged  
 
Last Edit: 2008/09/20 07:51 By admin.
  The administrator has disabled public write access.
#5614
Re:Saving a text field value w/o invoking text editor 2 Months, 2 Weeks ago
That is helpful, thank you. The real trick is saving the data without opening an editor. Is there a way I could have my slider be treated as an editor? In other words, if it is adjusted, a 'change' is registered- and data could be saved?

I have a feeling the process is more complex than that- but does what I'm trying to do make sense (conceptually at least?)

Thanks!
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5620
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Saving a text field value w/o invoking text editor 2 Months, 2 Weeks ago
You could create your own editor. Open fla source/F8 flashblocks_textInput1.1.fla for a simple working example with comments.

You could also force save by calling:
Code: :

 flashblocks.Flashblocks.Save()



Or tell Flashblocks that the data file has changed by setting the changed attribute where "fb0" is the flashblockID:
Code: :

 flashblocks.Flashblocks.Registered.fb0.changed true

 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5630
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
Thanks, I was able to see the 'manual save request' work, but I am still not able to save the data.

I should be more specific, maybe it will help shed some light on the problem.

Here are the elements I'm working with (using absolute paths for this example)....

The movie clip (a slider) in this case is called 'sliderxcaption0xalpha' (strange variable name, but the x's are delimiters & help determine the mc's purpose).

-The dynamic text field I am changing with a slider is:
loadTarget.sliderxcaption0xalpha.valueText.text

-The edit block that is attached to the dynamic text field is:
loadTarget.sliderxcaption0xalpha.ebValueText

In the application, there can be many objects (sliders) like this. Technically, all of the edit blocks will have the same name within the slider, but their absolute paths will of course be different/unique.

Because of this I wasn't sure that the example you provided would work in my case:

"flashblocks.Flashblocks.Registered.ebValueText.changed = true"

Because it's not as if 'ebValueText' would be a unique value in the app- unless the Registered method within Flashblocks was evaluating the full path from the request- but I'm not sure if it's doing that, or looking for a unique edit block name only.

Maybe I'm not understanding exactly how a change works. If I tell Flashblocks that 'loadTarget.sliderxcaption0xalpha.ebValueText' has changed, does that mean the editblock will automatically save off the value in the dynamic text field which it is attached to? This is what I hope to achieve, anyway!

Thanks in advance.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5638
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
For this simple example I will use a button instead of a slider.

1. Place a text field on stage called myText
2. Drop an Editblock onto myText
3. Place a button symbol on stage called btn
4. drop a Flashblocks component on stage with the flashblockID "fb0"

This actionscript will cause the following:

1. myText will become "TEXT2"
2. The Flashblocks TheData Object will become "TEXT2"
3. The Save option will become active
Code: :

  btn.onPress = function () {     myText.text "TEXT2"     flashblocks.Flashblocks.TheData.fb0.myText.pre[0].theContent "TEXT2"     flashblocks.Flashblocks.Registered.fb0.changed true }



Now you can save and the new "TEXT2" data will be saved to the data file.
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/09/22 21:31 By admin.
  The administrator has disabled public write access.
#5656
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
The test only partially worked for me. I was able to go through the motions of saving the data- the application gave me a 'Success! Data saved", but nothing was actually saved to dataFile.xml & upon loading up again, the text field was blank.

I then edited the text field directly (with the text editor) and saved again. These changes did save (upon loading up again, the text field was repopulated with the saved text from dataFile.xml).

So in the test the only 'valid' way to save data was by using the text editor.

Sorry that we seem to be going around in circles... I think I'm close to being able to save a value without an editor, but there seems to be something critical missing in these steps. That said, I'll go over all of them again and see if anything obvious comes up.

Thanks,

Greg
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5657
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
Shoot me an email and I will send you the fla.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5662
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
Fla sent... The original code only works once you have entered data via the simple text editor. But the fla I sent will work either way. The problem was that the pre (text editor) object was not created. New code:
Code: :

  btn.onPress = function () {     myText.text "TEXT2"     flashblocks.Flashblocks.TheData.fb0.myText.pre = [{theContent:"TEXT2"}]     flashblocks.Flashblocks.Registered.fb0.changed true }

 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5675
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
Thanks Sunny!

Also- correct me if I'm wrong here- but in order to write data via an editblock within a child movie clip, you would do this (let's say the text field "myText" was located inside the movie clip "myClip"):

btn.onPress = function () {
myText.text = "TEXT2"
flashblocks.Flashblocks.TheData.fb0.myClip_myText.pre = [{theContent:"TEXT2"}]
flashblocks.Flashblocks.Registered.fb0.changed = true
}

An underscore should replace the typical dot syntax when specifying movie clip paths that will be written to dataFile.xml.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5680
admin ()
User Online Now Click here to see the profile of this user
Flashblocks Birthdate: 2005-02-14
 
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
Yes, that is correct - the text field "myText" located inside the movie clip with the instance name "myClip" would cause the Editblock attached to "myText" to have the editblockID of "myClip_myText"

Of course you may instead choose to enter an editblockID through the component inspector if you do not wish to have one created for you.
 
Report to moderator   Logged Logged  
  The administrator has disabled public write access.
#5684
Re:Saving a text field value w/o invoking text editor 2 Months, 1 Week ago
Something is amiss, still, in my application. Your example .fla works, in that it will create a 'div' from scratch- every time it is run, even if there is no dataFile.xml at first (or if it is empty)- and works perfectly.

As you can imagine, the app I'm making is more complex than the example. In theory I guess that shouldn't matter, but what happens when I move your example code into my app is really confounding me right now.

The code to write data will not work (because the div is never created)- unless I actually enter a text editor, and then save from there. Once I do that- a div like the one below is created within dataFile.xml- and all is well in the world.

Code: :

  (Flashblocks) (div id="myText")     (pre)TEXT2(/pre) (/div) (/Flashblocks)



The problem is, unless I use an editor to edit the text field first- that div never gets created. Once it's there though, I can edit to my heart's content with your code sample- and every update is saved. But basically, the app will not write an update unless the div already exists!

Why your example will successfully write the div to the file every time, but refuse to write anything in my app unless the div is created by an editor process (or manually entered) is driving me crazy.... aaaaaagghh! :O
 
Report to moderator   Logged Logged  
 
Last Edit: 2008/09/25 23:50 By thinkspring.
  The administrator has disabled public write access.
Go to top Post Reply
get the latest posts directly to your desktop

Thank you