|
need help changing AS3 code. MacMenu
|
|
Hi. I hope someone can help me 'cause i don't have any money to hire someone for this (and i guess i am too stupid because AS3 is like chinese for me).
I downloaded marcellosurdi.name/2008/09/14/dock-menu-actionscript-3 DocMenu but the problem is, that i need some of the links open in an iframe 'IFrame1' on my page and some should open as target _self.
Is it alot to change in the code?, because it seems to me that the coder made all the links follow one function (and currently all open in a new window).
Quote:
/*
*************************************
* Flash Mac Menu
* http://www.FlepStudio.org
* Author: Filippo Lughi
* Version 1.0
* Modified by: Marcello Surdi on 14/09/2008
* Web: http://www.marcellosurdi.name/
* Last update: 19/09/2008
*************************************
*/
package org.FlepStudio {
import flash.display.*;
import flash.events.*;
import flash.net.*;
import flash.text.*;
import fl.transitions.*;
import fl.transitions.easing.*;
import fl.transitions.TweenEvent;
public class Main extends MovieClip {
private var icons_array:Array;
private var url_array:Array;
private var border:int = 2;
private var min:int = 32;
private var max:int = 42;
private var unit:Number;
private var outdistancing:Number;
private var speed:Number = 0.15;
private var _V :Number;
private var now:Number = 0;
private var pUnit:Number;
private var center:Array = new Array();
private var weath:Boolean = true;
private var into:Boolean = true;
private var xx:Number = 0;
private var yy:Number = 0;
private var actions:Object;
private var tf:TextField;
private var tw:Tween;
private var tw2:Tween;
private var prevButton:MovieClip;
public function Main() {
addEventListener(Event.ADDED_TO_STAGE,init);
var fla:MovieClip = this;
actions = new Object();
actions.doURL = function(vars):URLRequest {
var ur:URLVariables = new URLVariables(vars);
var requ:URLRequest = new URLRequest(ur.path);
delete(ur.path);
if(ur.toString().length != 0) requ.data = ur;
return requ;
}
actions.doRef = function(path):* {
var arr:Array = path.split('.');
var ref:*;
for(var i:uint = 0; i < arr.length; i++) ref = (!ref)?fla[arr[i]] :ref[arr[i]];
return ref;
}
actions.gotoURL = function(vars) {
var requ:URLRequest = actions.doURL(vars);
navigateToURL(requ);
}
actions.gotoFrame = function(vars) {
var ur:URLVariables = new URLVariables(vars);
var ref:MovieClip = actions.doRef(ur.path);
var conv:uint = uint(ur.frame);
var frame:* = (conv != 0)?conv :ur.frame;
(ur.action == 'gotoAndPlay')?ref.gotoAndPlay(frame) :ref.gotoAndStop(frame);
}
}
private function init(evt:Event):void {
removeEventListener(Event.ADDED_TO_STAGE,init);
stage.frameRate = 31;
icons_array = new Array(
menu_mc.released_2008,
menu_mc.released_2007,
menu_mc.icon_2_mc,
menu_mc.icon_3_mc,
menu_mc.icon_4_mc,
menu_mc.contact);
url_array = new Array(
['gotoURL','path=http://www.marcellosurdi.name/'],
['gotoURL','path=http://www.marcellosurdi.name/'],
['gotoURL','path=http://www.marcellosurdi.name/'],
['gotoURL','path=[http://www.marcellosurdi.name/'],
['gotoURL','path=http://www.marcellosurdi.name/'],
['gotoURL','path=[http://www.marcellosurdi.name/']);
unit = 1 * min;
outdistancing = min + 20;
_V = max - min;
pUnit = Math.PI / unit;
for(var i:int = 0; i < icons_array.length; i++) {
icons_array[i].y = - border;
center[i] = (2 * i - icons_array.length - 1) * outdistancing / 2;
icons_array[i].id = i;
icons_array[i].mouseChildren = false;
if (i > 0) {
icons_array[i].buttonMode = true;
icons_array[i].addEventListener(MouseEvent.MOUSE_DOWN,setDown);
}
else {
executeAction(url_array[0][0],url_array[0][1])
prevButton = icons_array[i];
}
icons_array[i].addEventListener(MouseEvent.ROLL_OVER,setTextLabe l);
}
tf = new TextField();
menu_mc.addChild(tf);
menu_mc.tray.height = min + border * 2;
menu_mc.addEventListener(Event.ENTER_FRAME,moveMen u);
}
private function moveMenu(evt:Event):void {
var low:Number;
var high:Number;
var elevation:Number = min + 2 * border + _V * now;
var _X:Number;
var _F:Number;
var c_F:Number;
var s_F:Number;
var _S:Number;
var _Vcale:Number;
if(now == 0 || now == 1) weath = false;
else weath = true;
if(into) now = Math.min(1,now + 0.2);
else now = Math.max(0,now - 0.2);
if(xx != mouseX || yy != mouseY || weath) {
xx = menu_mc.mouseX;
yy = menu_mc.mouseY;
var xx1 = menu_mc.tray.x;
var xx2 = xx1 + menu_mc.tray.width;
}
if(!weath) {
if(xx < xx1 || xx > xx2 || Math.abs(yy) > elevation) {
into = false;
tf.visible = false;
}
else {
into = true;
tf.visible = true;
tw = new Tween(tf,'x',Regular.easeIn,tf.x,(menu_mc.mouseX - tf.width / 2),3,false);
}
}
for(var i:int = 0; i < icons_array.length; i++) {
low = center[i] - now * unit + 50;
high = center[i] + now * unit + 50;
if(xx <= low) _X = high;
if(xx >= high) _X = low;
if(xx > low && xx < high) {
_F = pUnit * (high - xx);
c_F = Math.cos(_F / 2);
s_F = Math.sin(_F) / 20;
_X = center[i] - now * unit * (c_F+s_F) + 50;
_S = _V * (1-c_F*c_F);
}
else _S = 0;
_Vcale = (min + now * _S) / 128;
icons_array[i].scaleX = icons_array[i].scaleY = _Vcale;
icons_array[i].x = _X;
menu_mc.tray.width = icons_array[icons_array.length-1].x-icons_array[0].x+icons_array[0].width/2+icons_array[icons_array.length-1].width/2+2*border;
menu_mc.tray.x = (icons_array[0].x-icons_array[0].width/2-border);
}
}
private function setTextLabel(e:MouseEvent):void {
tf.text = e.target.name.replace(/_/g,' ').toUpperCase();
tf.y = -8;
tf.autoSize = TextFieldAutoSize.LEFT;
var fm:TextFormat = new TextFormat();
fm.font = 'verdana';
fm.color = 0x999999;
fm.size = 8;
tf.setTextFormat(fm);
}
private function setDown(e:MouseEvent):void {
var ref:MovieClip = e.target as MovieClip
executeAction(url_array[ref.id][0],url_array[ref.id][1]);
enableDisable('disable');
tw2 = new Tween(ref,'y',Elastic.easeOut,ref.y,(ref.y - 25),.5,true);
tw2.addEventListener(TweenEvent.MOTION_FINISH,onTw 2Finish);
prevButton = ref;
}
private function onTw2Finish(e:TweenEvent):void {
e.target.continueTo(0,.5);
e.target.removeEventListener(TweenEvent.MOTION_FIN ISH,onTw2Finish);
e.target.addEventListener(TweenEvent.MOTION_FINISH ,function() { enableDisable(); } );
}
private function enableDisable(what:String = ''):void {
for(var i:uint = 0; i < icons_array.length; i++) {
if(what == 'disable') {
icons_array[i].buttonMode = false;
icons_array[i].removeEventListener(MouseEvent.MOUSE_DOWN,setDown );
}
else {
if(icons_array[i] == prevButton) continue;
icons_array[i].buttonMode = true;
icons_array[i].addEventListener(MouseEvent.MOUSE_DOWN,setDown);
}
}
}
private function executeAction(action,vars):void {
var currAction:String = action;
switch(currAction) {
case 'gotoURL':
actions.gotoURL(vars);
break;
case 'gotoFrame':
actions.gotoFrame(vars);
break;
}
}
}
}
|
|
Last edited by Onsitus; 28-09-08 at 19:05..
|