How to replace movie clip in flash animation via actionscript code - actionscript

For example, I've created in Flash CS a movie clip CampfireMC, which contains child movie clip:
m_fire:FireMC
FireMC is an animation of flame
CampfireMC controls playback of m_fire, for example, last frame of CampfireMC uses action code:
m_fire.gotoAndStop(m_fire.totalFrames)
And the question is how to replace (not delete/add, as m_fire.gotoAndStop(m_fire.totalFrames) will not work in this case) FireMC to another animation FireMC2?
I've tried the following trick, but it doesn't work
var campfire:CampfireMC = new CampfireMC();
campfire.m_fire = new FireMC2();
campfire.gotoAndPlay(0)

not sure if the concept of "replacing" actually exists in Actionscript. changing the reference of m_fire would actually delete the previous reference and add a new one. this is what you do when you assign a new FireMC2 object to the m_fire variable, you delete the previous FireMC instance and add a new FireMC2 object.
the description of your problem seems to suggest that FireMC2 shares some functionality with FireMC , also I wonder if you shouldn't tackle the problem differently. instead of trying to replace one with the other , isn't it possible to encapsulate the extra functionality in a new MovieClip or even a new FireMC method and either add the new MovieClip or call the method , instead of trying to replace FireMC

Related

How to place multiple objects using ARCore

I want to make an ARCore app where you can select what you want to place. Does anyone know how to do this
If you are using the default example, you can change the line:
public GameObject m_andyAndroidPrefab;
to the line:
public List<GameObject> m_Prefabs;
In your Update() method, change the existing Instantiate invocation with this:
var object = Instantiate(m_Prefabs[m_currentObjectIndex],
hit.Point, Quaternion.identity, anchor.transform);
m_currentObjectIndex is an integer that holds the current index of the desired prefab to create. You will need to update this field when the user selects an object in your menu, for example.

RxSwift - Class property's binding

I have an question about binding:
I have an array of objects of my custom class: Array. Every object can be updated (change his properties value) in bg.
Also I have separated Controller, which take and store one object from list as variable and can update it (object still the same, so in list it will be updated too)
Is there any way to bind all object.property -> UILabels on Controller in way, when property changes automatically call label update?
Of course, there are multiple ways how to do it, but from your description I would use some kind of subject (because u said there will be changes in background so you will probably need hot observable )....For example Variable or PublishSubject. So you can crate
let myArrayStream: Variable<[MyObject]> = Variable([])
you can pass this variable as dependency to wherever you want, on one side you can subscribe to it, on the other side you can update it's value.

Modify behaviour of subobjects

Is there any way to modify the behaviour (methods) of a sub-object by redefining them when subclassing a component . e.g I am subclassing Tlistbox , and i want to modify the behaviour of Delete() method of its Items subobject . Is there a formal way to do so ?
Thanks
Based on your comments, you don't actually need to change the behavior of the Items property itself. There are other ways to detect when items are being manipulated in the ListBox so you can update your own internal objects as needed.
When deleting items, the Items.Delete() method simply calls TCustomListBox.DeleteString() passing it the index to delete. DeleteString() can be overridden by a descendant. Simple enough.
When adding/inserting new items, it is not quite so straight forward. Items.Add() sends a LB_ADDSTRING message directly to the ListBox's HWND (unless the ListBox's Style is set to virtual mode, in which case Add() simply exits without doing anything). Same with the Items.Insert() method (LB_INSERTSTRING message). To catch those message, you have to override the ListBox's virtual WndProc() method.
Items.AddObject() calls Items.Add() first, and then uses the Items.Objects[] setter to assign the object to the new item. Same with Items.InsertObject(), calling Items.Insert() instead of Items.Add().
When updating an existing item's string via the Items.Strings[] property, things get a bit complex:
TCustomListBox.InternalGetItemData() (can be overridden) is called to retrieve the item's existing object, if any. By default, InternalGetItemData() calls GetItemData() (which can also be overridden), which by default sends a LB_GETITEMDATA message to the ListBox's HWND.
TCustomListBox.InternalSetItemData() (which can be overridden) is called to set the item's object to nil (in case Delete() in the next step tries to destroy it). By default, InternalSetItemData() calls SetItemData() (which can also be overridden), which by default sends a LB_SETITEMDATA message to the ListBox's HWND.
Items.Delete() is called to remove the item.
Items.InsertObject() is called to insert the new string with a nil object
TCustomListBox.InternalSetItemData() is called to restore the original object to the new item.
When updating an existing item's object via the Items.Objects[] property, if the ListBox's Style is not set to virtual mode then TCustomListBox.SetItemData() is called.
When moving items around using the Items.Exchange() method, if the ListBox's Style is set to virtual mode then Exchange() simply exits without doing anything. Otherwise, it uses the Items.Strings[] property to swap the two item strings, and calls Internal(Get/Set)ItemData() to swap the two item objects.
So, basically, everything you need to manage internal objects boils down to overriding these methods:
TCustomListBox.DeleteString()
TCustomListBox.WndProc() to handle LB_(ADD/INSERT)STRING, and maybe LB_(GET/SET)ITEMDATA.
TCustomListBox.Internal(Get/Set)ItemData() or TCustomListBox.(Get/Set)ItemData()

Dynamic Tag Management - Storing

We're in the process of moving to DTM implementation. We have several variables that are being defined on page. I understand I can make these variables available in DTM through data elements. Can I simply set up a data elem
So set data elements
%prop1% = s.prop1
%prop2% = s.prop2
etc
And then under global rules set
s.prop1 = %s.prop1%
s.prop2 = %s.prop2%
etc
for every single evar, sprop, event, product so they populate whenever they are set on a particular page. Good idea or terrible idea? It seems like a pretty bulky approach which raises some alarm bells. Another option would be to write something that pushes everything to the datalayer, but that seems like essentially the same approach with a redundant step when they can be grabbed directly.
Basically I want DTM to access any and all variables that are currently being set with on-page code, and my understanding is that in order to do that they must be stored in a data element first. Does anyone have any insight into this?
I use this spec for setting up data layers: Data Layer Standard
We create data elements for each key that we use from the standard data layer. For example, page name is stored here
digitalData.page.pageInfo.pageName
We create a data element and standardize the names to this format "page.pageInfo.pageName"
Within each variable field, you access it with the %page.pageInfo.pageName% notation. Also, within javascript of rule tags, you can use this:
_satellite.getVar('page.pageInfo.pageName')
It's a bit unwieldy at times but it allows you to separate the development of the data layer and tag manager tags completely.
One thing to note, make sure your data layer is complete and loaded before you call the satellite library.
If you are moving from a legacy s_code implementation to DTM, it is a good best practice to remove all existing "on page" code (including the reference to the s_code file) and create a "data layer" that contains the data from the eVars and props on the page. Then DTM can reference the object on the page and you can create data elements that map to variables.
Here's an example of a data layer:
<script type="text/javascript">
DDO = {} // Data Layer Object Created
DDO.specVersion = "1.0";
DDO.pageData = {
"pageName":"My Page Name",
"pageSiteSection":"Home",
"pageType":"Section Front",
"pageHier":"DTM Test|Home|Section Front"
},
DDO.siteData = {
"siteCountry":"us",
"siteRegion":"unknown",
"siteLanguage":"en",
"siteFormat":"Desktop"
}
</script>
The next step would be to create data elements that directly reference the values in the object. For example, if I wanted to create a data element that mapped to the page name element in my data layer I would do the following in DTM:
Create a new data element called "pageName"
Select the type as "JS Object"
In the path field I will reference the path to the page name in my data layer example above - DDO.pageData.pageName
Save the data element
Now this data element can be referenced in any variable field within any rule by simply typing a '%'. DTM will find any existing data elements and you can select them.
I also wrote about a simple script you can add to your implementation to help with your data layer validation.Validate your DTM Data Layer with this simple script
Hope this helps.

Why DAC class is not saved in Acumatica?

Let's say I have following code:
DacClass cl = new DacClass();
//init fields of DacClass()
this.Persist();
but when I run this code in any graph, I'm getting different errors. Why?
You can't create DAC item in db in current graph. As mentioned in T200 manual you should create instance of graph and in created instance to call method persist. Another option is to use method PXDataBase.Insert. The first option is preferable for case if you need insertion with graph logic. The second option is preferable for cases if you need perfomance.

Resources