View Full Version : Working with Flash 8.0 +
Centauri Soldier
09-18-2010, 12:15 AM
Does anyone know how to tell which button from this flash file has been clicked? I'm swimming the help manual and not doing a very good job of staying afloat. I don't get what action I'm supposed to call.
http://h1.flashvortex.com/display.php?id=3_1284790484_32926_283_12866_167_38 9_9_45
mystica
09-20-2010, 02:50 AM
Well, I just decompiled that to get a look at its ActionScript. Was hoping to ID each button's assigned flash-variable so you could call them from AMS and work them into a series of if/then statements. But that's a very complex piece of flash you've generated there. It uses dozens of files of action-script (40 in total) in a complex array that's way beyond me. To give you some idea, the main timeline looks like this:
package 8_fla
{
import flash.display.*;
import flash.events.*;
import flash.net.*;
import vortex.components.*;
import vortex.events.*;
import vortex.utils.*;
dynamic public class MainTimeline extends MovieClip
{
public var totalItems:Number;
public var itemsText:Array;
public var myWindow:SWindow;
public var subMenusSpeed:Number;
public var id:Number;
public var mainButtonsWidth:Number;
public var menuText:Array;
public var myMenu:SAccordionMenu;
public var menuTextTemp:String;
public var windowTitle:String;
public var skinXml:Skin_Xml;
public var displayWindow:Boolean;
public var sep:String;
public var i:Number;
public var finalStageHeight:Number;
public var menuLinkTemp:String;
public var subMenusButtonsVSpacing:Number;
public var content:Sprite;
public var mainButtonsVSpacing:Number;
public var subMenusWidth:Number;
public var subMenusTopPadding:Number;
public var style:String;
public var finalStageWidth:Number;
public var menuPadding:Number;
public var itemsTarget:Array;
public var myLink:LinkBack;
public var subMenusDynamics:String;
public var menuTarget:Array;
public var menuTargetTemp:String;
public var subMenusLeftPadding:Number;
public var itemsLink:Array;
public var myResizer:Resizer;
public var menuLink:Array;
public function MainTimeline()
{
addFrameScript(0, frame1, 1, frame2);
return;
}// end function
function frame2()
{
sep = String.fromCharCode(13);
menuTextTemp = rTrim("Home\rServices\r-Design\r-Construction\r-Exploration\r-Coding\r-Cleaning\r-Security\rProducts\r-Computers\r-Phones\r-Cameras\r-Books\r-Tables\r-Speakers\rMembers\r-James\r-Mary\r-John\r-Patricia\r-Michael\rLinks\r-Google\r-Yahoo\r-Facebook\r-Youtube\rHelp\r-Tutorials\r-FAQ\r-Support\r-Forums\rContact-Us\r-Email\r-Phone\r-Chat");
menuLinkTemp = rTrim("");
menuTargetTemp = rTrim("");
menuText = menuTextTemp.split(sep);
menuLink = menuLinkTemp.split(sep);
menuTarget = menuTargetTemp.split(sep);
mainButtonsWidth = isNaN(parseInt("120")) ? (120) : (parseInt("120"));
mainButtonsVSpacing = isNaN(parseInt("2")) ? (2) : (parseInt("2"));
subMenusTopPadding = isNaN(parseInt("2")) ? (2) : (parseInt("2"));
subMenusLeftPadding = isNaN(parseInt("5")) ? (5) : (parseInt("5"));
subMenusWidth = isNaN(parseInt("120")) ? (120) : (parseInt("120"));
subMenusButtonsVSpacing = isNaN(parseInt("2")) ? (2) : (parseInt("2"));
subMenusSpeed = isNaN(parseInt("150")) ? (150) : (parseInt("150"));
menuPadding = isNaN(parseInt("2")) ? (2) : (parseInt("2"));
windowTitle = "Menu";
subMenusDynamics = "regular";
displayWindow = parseInt("1") == 1 ? (true) : (false);
style = "simultaneous";
i = 0;
id = 0;
totalItems = menuText.length;
itemsText = new Array();
itemsLink = new Array();
itemsTarget = new Array();
while (i < totalItems)
{
itemsText[id] = new Object();
itemsLink[id] = new Object();
itemsTarget[id] = new Object();
itemsText[id].mainButtonText = menuText[i];
itemsLink[id].mainButtonLink = menuLink[i];
itemsTarget[id].mainButtonTarget = menuTarget[i];
var _loc_2:* = i + 1;
i = _loc_2;
if (menuText[i] != undefined && menuText[i].charAt(0) == "-")
{
itemsText[id].subButtonsText = new Array();
itemsLink[id].subButtonsLink = new Array();
itemsTarget[id].subButtonsTarget = new Array();
while (menuText[i] != undefined && menuText[i].charAt(0) == "-")
{
itemsText[id].subButtonsText.push(menuText[i].substr(1));
itemsLink[id].subButtonsLink.push(menuLink[i]);
itemsTarget[id].subButtonsTarget.push(menuTarget[i]);
var _loc_2:* = i + 1;
i = _loc_2;
}
}
var _loc_2:* = id + 1;
id = _loc_2;
}
myMenu = new SAccordionMenu(itemsText, skinXml.skin);
myMenu.mainButtonsWidth = mainButtonsWidth;
myMenu.mainButtonsVSpacing = mainButtonsVSpacing;
myMenu.subMenusTopPadding = subMenusTopPadding;
myMenu.subMenusLeftPadding = subMenusLeftPadding;
myMenu.subMenusWidth = subMenusWidth;
myMenu.subMenusButtonsVSpacing = subMenusButtonsVSpacing;
myMenu.subMenusDynamics = subMenusDynamics;
myMenu.subMenusSpeed = subMenusSpeed;
myMenu.style = style;
myMenu.maxHeightSprite = true;
myMenu.addEventListener(MenuEvent.ITEM_SELECTED, itemSelected);
myMenu.draw();
myLink = new LinkBack(this);
myLink.dataString = "0_283_126";
if (displayWindow == true)
{
content = new Sprite();
content.addChild(myMenu);
content.addChild(myLink);
myLink.yPosition = myMenu.y + myMenu.maxMenuHeight + 2;
myLink.xPosition = Math.floor(myMenu.width / 2 - myLink.width / 2);
if (myLink.x < 0)
{
myLink.x = 0;
}
myWindow = new SWindow();
myWindow.setSkin(skinXml.skin);
myWindow.title = windowTitle;
myWindow.height = -1;
myWindow.width = -1;
myWindow.content = content;
myWindow.contentPadding = menuPadding;
myWindow.x = 0;
myWindow.y = 0;
myWindow.draw();
addChild(myWindow);
finalStageWidth = new Number(myWindow.width);
finalStageHeight = new Number(myWindow.height);
}
else
{
this.addChild(myMenu);
this.addChild(myLink);
myMenu.x = menuPadding;
myMenu.y = menuPadding;
myLink.yPosition = myMenu.y + myMenu.maxMenuHeight + 2;
myLink.xPosition = myMenu.x + Math.floor((myMenu.width - myLink.width) / 2);
if (myLink.x < 0)
{
myLink.x = 0;
}
finalStageWidth = new Number(menuPadding + myMenu.width + menuPadding);
finalStageHeight = new Number(myLink.y + myLink.height + menuPadding);
}
myResizer = new Resizer(stage);
myResizer.newWidth = finalStageWidth;
myResizer.newHeight = finalStageHeight;
myResizer.resize();
stop();
return;
}// end function
function frame1()
{
skinXml = new Skin_Xml();
return;
}// end function
public function rTrim(param1:String) : String
{
var _loc_2:int = 0;
_loc_2 = param1.length - 1;
while (param1.charCodeAt(_loc_2) < 32)
{
param1 = param1.substring(0, _loc_2);
_loc_2 = _loc_2 - 1;
}
return param1;
}// end function
public function itemSelected(event:Event) : void
{
var _loc_2:String = null;
var _loc_3:String = null;
var _loc_4:Number = NaN;
var _loc_5:Number = NaN;
var _loc_6:URLRequest = null;
_loc_4 = event["mainButtonIndex"];
_loc_5 = event["subButtonIndex"];
if (_loc_5 == -1)
{
_loc_2 = itemsLink[_loc_4].mainButtonLink;
_loc_3 = itemsTarget[_loc_4].mainButtonTarget;
}
else
{
_loc_2 = itemsLink[_loc_4].subButtonsLink[_loc_5];
_loc_3 = itemsTarget[_loc_4].subButtonsTarget[_loc_5];
}
_loc_6 = new URLRequest(_loc_2);
if (_loc_3 == null)
{
_loc_3 = "";
}
navigateToURL(_loc_6, _loc_3);
return;
}// end function
}
}
And then you've got another 39 files of actionscript to wade through. If you can make sense of all that, then you're doing better than me. I know it's not exactly a "professional" solution, but wouldn't it be easier to just assign a series of Hotspots over each button and use those to determine whether each button's been pressed? (Either that, or use a flash menu with simpler ActionScript?)
Centauri Soldier
09-20-2010, 04:22 AM
Yes, I decompiled it too and spent about two hours trying to figure it out before I posted here for help. I couldn't seem to find any variables that could be referenced by AMS. The simpler flash menus I use, use the variable "click" but these accordion ones do not.
mystica
09-20-2010, 05:07 AM
It's possible each button's assigned flash-variable has only been referenced in the Properties tab of the frame for each button in question. If that's the case, you won't find it in the actionscript. Instead, you need the original .fla source from which the SWF was compiled, and it has to be opened from within Adobe Flash to get it. Does FlashVortex let you have a copy of the .fla source for the files its site generates? If so, it'd at least give you the option of checking.
Centauri Soldier
09-20-2010, 11:41 AM
No, they don't offer the source but they said they plan on allowing custom FSCommands soon. I guess I'll just have to wait.
mystica
09-20-2010, 07:20 PM
Here, I've worked up a solution (unless you're really attached to that FlashVortex file). It's much easier to manipulate flash-menus like the one you've got, if you produce something in SwishMax instead. If you have a copy of Swish, you'll find it dead easy to call the relevant variables from AMS in order to do what you want. The bonus is that there's hundreds of free swish-produced Flash menus about and you can customize them to your liking.
And there's quite a few (yes, accordian-style included) that are much nicer than the one you have ... no offence, LOL. ;)
1. Check out (this link) (http://www.swishzone.com/index.php?area=resources&tab=movies&do=page&cat_id=8&nh=2&mh=25) for free menu templates until you find something close to what you want.
You'll find heaps more via google under "free swishmax menus".
2. Open it in SwishMax and customize it to how you want it to look.
3. While still in SwishMax, add the following code to each menu-button:
(add it at the end of whatever code already exists in each button)
on (press) {
fscommand("sVariable");
}
-- nb. Choose a string-variable that reflects the name of the menu-button (eg. sHome, sServices, etc ...)
4. Publish your SWF from SwishMax, drop it into AMS, and then add the following code to the On FSCommand event:
if (e_FSCommand == "sVariableA") then
Dialog.Message("Notice", "Menu #1 clicked", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
if (e_FSCommand == "sVariableB") then
Dialog.Message("Notice", "Menu #2 clicked", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end
-- etc, etc ....
Here's an example that id's when each menu-button is clicked (and which gives an idea of the kind of free flash-menu templates about). That should do it, yeh?
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.