...

View Full Version : XML navigation trying to load external movieclips into an empty movieclip



cassisdesign
12-10-2008, 01:22 AM
Ok so I have an XML navigation menu that has dynamic created buttons:

//source code for source.xml
<menu>

<item name = "about" color = "CC3300" link="#"></item>

<item name = "contact" color = "CC3300" link="#"></item>

<item name = "expertise" color = "CC3300" link="#"></item>

<item name = "interactive" color = "CC3300" link="#"></item>
<item name = "logotypes" color = "CC3300" link="#"></item>

<item name = "print" color = "CC3300" link="#"></item>

</menu>

I can easily have the buttons open a url, however I want each button to load its specified external movieclip(swf) into an empty movieclip loader that I have created in my main.swf. Main.swf loads everything externally even the navigation.

Here is the actionscript 2.0 code that I have in the navigation movieclip. I am only able to load one external movieclip called "print2.swf". I understand why it is only opening that one external movieclip. But how do I make each button open its specified external swf? :


// On roll over turns over=true
area.onRollOver = function(){

over = true

}
// On roll out turns over=false
area.onRollOut = function(){

over = false

}
// get the urlturns over=true
area.onPress=function(){
_root.clipLoader.loadClip("print2.swf", _root.swfHolder);


}


this.onEnterFrame = function(){
// The scale is equal to the target size
this._xscale += (targetSize - this._xscale)/3

this._yscale = this._xscale


// over = true
if (over){

// resizes to the max scale
targetSize = maxScale

// Shows the color
if (txtColor._alpha < 100){

txtColor._alpha += 12

}
// over = false
} else {

// Goes to the regular size
targetSize = minScale

// Hides the color
if (txtColor._alpha > 0){

txtColor._alpha -= 12


}

}

}

gnomeontherun
12-10-2008, 10:42 AM
Well the button right now is only registering the container movieClip, how are you loading the buttons into the 'area' container? Do you have this code?

You may need to do a hit test, to find if the button click is over a certain button or not, and then pass that to the function.

cassisdesign
12-11-2008, 06:10 PM
Jeremy sorry it took so long for me to respond! Here is how I load the xml menu into my main.swf.

//create external movie clip holder for navigation
var navigationLoader:MovieClipLoader = new MovieClipLoader();
this.createEmptyMovieClip("navHolder", this.getNextHighestDepth());
// initial movie load when application begins
function initNavigation(){
navigationLoader.loadClip("XML Menu 4 - main_flashCS3.swf", navHolder);
navHolder._x = 470;
navHolder._y = -25;
}
initNavigation();

gnomeontherun
12-11-2008, 06:50 PM
Can you post the files? Is this related to your other post?

Honestly I don't quite understand what you are doing/trying to do, so examples would be beneficial.

cassisdesign
12-11-2008, 07:48 PM
yes jeremy this is actually the same post. Sorry I wasn't clear on what I am trying to do. OK I have an actionscript/xml menu that I want to use to load external movieclips into the main.swf. The menu is dynamic and I'm trying to figure out how to open each buttons specified movieclip.

Here is the source.xml:
<settings>

<centered>true</centered>

<max>250</max>

</settings>



<menu>

<item name = "about" color = "CC3300" callFunction="loadClip(about.swf)"></item>

<item name = "contact" color = "CC3300" callFunction="loadClip(contact.swf)"></item>

<item name = "expertise" color = "CC3300" callFunction="loadClip(about.swf)"></item>

<item name = "interactive" color = "CC3300" callFunction="loadClip(interactive.swf)"></item>

<item name = "logotypes" color = "CC3300" callFunction="loadClip(logotypes.swf)"></item>

<item name = "print" color = "CC3300" clip="print2.swf"></item>

</menu>

the actionscipt for the menu:
//-----------------------------------------------------
// SETTINGS
//-----------------------------------------------------

// If true, the text will expand from the center, else, will expand left-aligned
centered = false

// The scale % that will expand the text
maxScale=125

// If true, the text will repositionate in the _x with the value in shufflePositions[]
shufflePosition = true

// If true, the text will resze the value in shufflePositions[]
shuffleScale = true

// The positions of the buttons if shufflePos = true
shufflePositions = [-10, 15, 2, 20, 12, -9]

// The scales of the buttons if shuffleScale = true
shuffleScales = [70, 120, 90, 160, 100, 75]


//-----------------------------------------------------



// List of the buttons
var itemList = []


// The xml data
var xmlSource:XML = new XML

// Gives to each button their respective sposition
function shufflePos(){

for (i=1; i<=total; i++){

// Shuffle positions
itemList[i-1].shufflePosition = shufflePositions[i-1]

}

}

// Gives to each button their respective size
function shuffleTheScales(){

for (i=1; i<=total; i++){

if (shuffleScale){

itemList[i-1].minScale = shuffleScales[i-1]

} else {

itemList[i-1].minScale = 100

}

itemList[i-1].maxScale = itemList[i-1].minScale + maxScale
}

}

// Loading the xml
xmlSource.onLoad = function(success:Boolean):Void {

// When the load finishs...
if (success) {

// Settings
xmlSettings = xmlSource.firstChild

// The first node of the xml
xmlRoot = xmlSource.childNodes[1]

// The item nodes
xmlItems = xmlRoot.childNodes

// The total of items
total = xmlItems.length

// Creating the buttons
for (i=0; i<total; i++){

// Attachs thee buttos
holder.attachMovie("button", "button" + i, i)
// Inserts the button in the array
itemList[i] = holder["button" + i]
// Puts the text
itemList[i].txt.text = itemList[i].txtColor.text = xmlItems[i].attributes.name
// Resizes the textbox
itemList[i].txt.autoSize = true
// Centers the text
itemList[i].txt._y = itemList[i].txtColor._y = 0
// Shuffle positions
itemList[i].shufflePosition = shufflePositions[i]
// Resizes the color text
itemList[i].txtColor.autoSize = true
// Resizes the area
itemList[i].area._width = itemList[i].txt._width
// Resizes the area
itemList[i].area._height = itemList[i].ref.mask._height = itemList[i].txt._height
// Centers the area
itemList[i].area._y = itemList[i].txt._y
// Centers the area
itemList[i].area._x = itemList[i].txt._x
// Hides the color
itemList[i].txtColor._alpha = 0
// Sets the color
itemList[i].txtColor.textColor = itemList[i].ref.mcReflect.txtColor.textColor = "0x"+xmlItems[i].attributes.color
// Links
itemList[i].link = xmlItems[i].attributes.link
// Scale

// Menu Height
menuHeight = holder._height
// Starts centering the menu
Start = true

if (shuffleScale){

itemList[i].minScale = shuffleScales[i]

} else {

itemList[i].minScale = 100

}

itemList[i].maxScale = itemList[i].minScale + maxScale

}

}

}

// ignore white
xmlSource.ignoreWhite = true;
// Loads the .xml file
xmlSource.load("source.xml");


holder.onEnterFrame=function(){

holder._y += ((menuHeight -holder._height/2 + menuHeight) - holder._y)/2

// Starts centering
if (Start){

// Does this to all the buttons
for (i=1; i<=total; i++){

// Makes it button be below the other
itemList[i]._y = itemList[i-1]._y + itemList[i-1]._height

if (shufflePosition){

//Shuffles the text
itemList[i-1]._x += (itemList[i-1].shufflePosition-itemList[i-1]._x)/3

} else {

//Shuffles the text
itemList[i-1]._x += (0-itemList[i-1]._x)/3

}

if (centered){

itemList[i-1].txt._x = itemList[i-1].txtColor._x += (-itemList[i-1].txt._width/2 - itemList[i-1].txt._x)/3

} else {

itemList[i-1].txt._x = itemList[i-1].txtColor._x += (0 - itemList[i-1].txt._x)/3

}

itemList[i-1].area._x = itemList[i-1].txt._x
}

}

}

here is the button moviclip code that controls each button in the menu:


// On roll over turns over=true
area.onRollOver = function(){

over = true

}
// On roll out turns over=false
area.onRollOut = function(){

over = false

}
// get the urlturns over=true
area.onPress=function(){

over = true


}


this.onEnterFrame = function(){
// The scale is equal to the target size
this._xscale += (targetSize - this._xscale)/3

this._yscale = this._xscale


// over = true
if (over){

// resizes to the max scale
targetSize = maxScale

// Shows the color
if (txtColor._alpha < 100){

txtColor._alpha += 12

}
// over = false
} else {

// Goes to the regular size
targetSize = minScale

// Hides the color
if (txtColor._alpha > 0){

txtColor._alpha -= 12


}

}

}

gnomeontherun
12-12-2008, 12:36 AM
I think a way would be to have a hittest (http://www.adobe.com/support/flash/action_scripts/actionscript_dictionary/actionscript_dictionary534.html) which you will have to apply to the menu movieclip 'area'.

http://www.senocular.com/flash/tutorials/buttoncapturing/

The problem lies in that you cannot really access the individual buttons since they are all contained in 'area'. So the link above has some options and ideas.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum