Flash CS3 - Flash CS4

Free tutorials and scripts for all.
Actionscript 3.0

need help changing AS3 code. MacMenu

This is a discussion on need help changing AS3 code. MacMenu within the HELP free utilities forums, part of the Flash CS3 eng category; Hi. I hope someone can help me 'cause i don't have any money to hire someone for this (and ...


Go Back   Forum Flash CS3 Flash CS4 > English Forums > Flash CS3 eng > HELP free utilities

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  5 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 28-09-08, 05:28
Junior Member
 
Join Date: Sep 2008
Posts: 3
Rep Power: 0
Huo_Yang is on a distinguished road
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;
}
}
}
}
Attached Files
File Type: as Main.as (7.1 KB, 5 views)
File Type: fla main.fla (148.0 KB, 10 views)


Last edited by Onsitus; 28-09-08 at 19:05..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #2 (permalink)  
Old 28-09-08, 15:53
marcellosurdi's Avatar
Junior Member
 
Join Date: May 2008
Location: Palermo
Posts: 7
Rep Power: 0
marcellosurdi is on a distinguished road
Re: need help changing AS3 code. MacMenu

You simply need to assign an gotoURL action to buttons and then you must write in this way on line 70

HTML Code:
navigateToURL(requ,'IFrame1');
I've prepared an example to see:
http://www.marcellosurdi.name/wordpress/wp-content/uploads/2008/09/main3.html
and a zip file to download:
http://www.marcellosurdi.name/wordpress/wp-content/uploads/2008/09/MacMenu3.zip

Bye

Last edited by Onsitus; 28-09-08 at 19:07..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #3 (permalink)  
Old 28-09-08, 17:45
Junior Member
 
Join Date: Sep 2008
Posts: 3
Rep Power: 0
Huo_Yang is on a distinguished road
Re: need help changing AS3 code. MacMenu

wow, thanks marcellosurdi!

but then all links open in the iframe, is there a way to sepperate it, so some links will open as _self ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #4 (permalink)  
Old 28-09-08, 23:51
Junior Member
 
Join Date: Sep 2008
Posts: 3
Rep Power: 0
Huo_Yang is on a distinguished road
Re: need help changing AS3 code. MacMenu

don't worry, i just let all links open in same window. But now, how can i turn off the automatic execution of the first link?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

  #5 (permalink)  
Old 30-09-08, 01:05
marcellosurdi's Avatar
Junior Member
 
Join Date: May 2008
Location: Palermo
Posts: 7
Rep Power: 0
marcellosurdi is on a distinguished road
Re: need help changing AS3 code. MacMenu

You have to comment the line 119
HTML Code:
// executeAction(url_array[0][0],url_array[0][1])
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

Flash Multi Gallery
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads

Thread Thread Starter Forum Replies Last Post
MacMenu Flep Utilità di FlepStudio 49 16-10-08 15:21
Actionscript 3 Changing TextField text color on programmatic textfields Pherankh Actionscript 3.0 newbies 1 16-08-08 02:26
Actionscript 3 code problem? alboman Actionscript 3.0 newbies 0 11-08-08 15:51
Actionscript 2 what is this as2 code? indo4web Flash CS3 eng 0 27-06-08 14:20
Not As3.0 Code! theuprock Actionscript 3.0 newbies 9 26-12-07 16:57


All times are GMT. The time now is 18:03.


Powered by vBulletin versione 3.7.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC4
Forum SiteMap


FlepStudio
by Filippo Lughi
P.IVA 03605860406