Knowledge Base |
Important! All new questions are usually answered within the next business day.
Accordion Panel V3
(views: 12965)
Accordion Panel V3 is a professional accordion component that loads movies and movieclips and supports both horizontal and vertical orientation, it supports customized tweens, states and visual styles. Here are all known issues for Accordion Panel V3. If you have any questions that you think we should discuss here please let us know.
Load new content without XML
(2009-02-25 - views: 1414)
Q: Is there a way to load new content into a single panel, without having to refresh the entire accordion panel with a new xml ?
A: Yes, there is a workaround. This example contains a function that will load new content into the specified panel and also can set a new title and a new content size. This is the AS3 version of the AS2 example which was previously created.
So for this to work, all you have to do is set up the fla file with the accordion panel component and two buttons, just like the AS2 example (with the same instance names) and add the following AS3 code:
So for this to work, all you have to do is set up the fla file with the accordion panel component and two buttons, just like the AS2 example (with the same instance names) and add the following AS3 code:
loader0_btn.addEventListener(MouseEvent.CLICK, loadInPanel0);
loader2_btn.addEventListener(MouseEvent.CLICK, loadInPanel2);
function loadInPanel0(evt:MouseEvent):void {
changePanelData(acPanel, 0, "New Title", "images/jmp01.jpg", 100);
}
function loadInPanel2(evt:MouseEvent):void {
changePanelData(acPanel, 2, "New Image", "images/jmp03.jpg");
}
/*
This function loads a new content in the specified panel and sets a new title and content size.
IMPORTANT:
By using this function, it is possible that other attributes of the accordion panel component instance
(like size) will not get updated. This function can be used only for the specified actions. All other
attributes/properties of the component will probably remain in the state they had before applying this
function.
parameters:
acpInstance - the reference to the AccordionPanelV3AS3 component, into which the new conten will load
panelIndex:int - the 0 based index of the panel into which the new content will load
newTitle:String - a new title for the panel header
newContent:String - the url for the new content
newContentSize:Number - the new size for tha panel. If there is a new size for the content, the panel
will resize but the panel should be closed and then opened again to have the size of the
accordion panel component updated
*/
function changePanelData(acpInstance:AccordionPanelV3AS3, panelIndex:int, newTitle:String, newContent:String, newContentSize:Number = 0):void {
if (acpInstance == null) return;
if (isNaN(panelIndex)) return;
if (panelIndex >= acpInstance.items.length) return;
// set the new size for the panel
if ((!isNaN(newContentSize)) && (newContentSize > 0)) {
acpInstance.items[panelIndex].contentSize = newContentSize;
acpInstance.items[panelIndex].setSize(newContentSize, "false");
}
// set the new title for the header
if (newTitle != null) {
acpInstance.items[panelIndex]._header.accText.text = newTitle;
acpInstance.items[panelIndex]._header.changeTextFormat(acpInstance.items[panelIndex].styleObj.textFormat);
acpInstance.items[panelIndex].title = newTitle;
}
// load the new content into the panel
if (newContent != null) {
acpInstance.items[panelIndex].load(newContent);
//acpInstance.items[panelIndex].source = newContent;
}
acpInstance.invalidate();
}
Login to post your comment


