_ymouse help
I have created a simple website in flash and I have given it
a Macosx dock style navigation bar at the bottom of the screen. The
problem I am having is that I want the dock to stop working when
the mouse is over the page itself (any where below y=600 pixels) I
came up with a simple piece of code and applied it to the movieclip
to get around this problem, but it dosen't work and I can't see
why.
onClipEvent (load) {
if (_ymouse>600) {
_root.dock.gotoAndPlay("work");
} else {
_root.dock.gotoAndPlay("break");
when the clip loads it calculates they position of the mouse
and adjusts the "dock" accordingly either making it "broken" or
"working" all my labels and targets are correct and as far as I can
tell the coding is correct aswell. I added a dynamic text box and
linked in the script "_root.tester=_ymouse;" to see if I got my
values wrong but this box only gives me the value of where my mouse
was when the page was loaded and does not change when the mouse is
moved. I'm sure It's something simple that I'm overlooking here but
it's really frustrating me. any help or comments would be greatly
appreciated.
Sam
use the attach code option to display code in this forum. and
i don't seen any handlers, but you can use a hitTest() between your
scrolling movieclip and the mouse to determine if you want to
scroll.
Similar Messages
-
Need help with xml video gallery
Hello everyone
I recently bought a xml video gallery. I'm loading the movie externally into another movie. When the xml gallery loads, it cancels all sounds.
I need to figure out where in the actionscription can i reverse the cancellation of sounds. Can anyone help? if possible, I can email, whomever is willing to help, the xml gallery to see if theres another reason the sound is being canceled.
Also, the sound of the gallery doesn't work til you click the volume scroller.
Here are two parts of actionscript included in the gallery:
part one:
// Import filter classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Set flash variables
var xmlFileUrl:String = "playlist.xml";
var auto_play:String = "true";
// Set xml file URL
if (_root.xmlfile) {
xmlFileUrl = _root.xmlfile;
var V_SRC;
var thuArray:Array = new Array();
var currentVideo:Number = 0;
var totalItems;
var numOfItems:Number;
var itemDistance:Number = 120+5;
var itemHeight:Number = 80+2;
var Value:Number = 1;
var boundry:Number = 1;
var ratio:Number = 1;
var diff:Number = 1;
var collectionWidth:Number = 1;
var buffer:Number = 135*2;
this.createEmptyMovieClip("video_txt",this.getNextHighestDepth());
video_txt.createTextField("theText",video_txt.getNextHighestDepth(),0,0,584,36);
video_txt.theText.selectable = false;
video_txt.theText.autoSize = "left";
//The Format
myFormat = new TextFormat();
myFormat.font = _root.font_format;
myFormat.size = _root.font_size;
myFormat.color = _root.font_color;
myFormat.align = "center";
video_txt.theText.setNewTextFormat(myFormat);
// Create a new movieclip to load the thumbs
var thumbLoader:MovieClipLoader = new MovieClipLoader();
var thumbListener:Object = new Object();
thumbLoader.addListener(thumbListener);
thumbListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number)
new Tween(target_mc, "_alpha", Regular.easeOut, 0, 100, 1, true);
target_mc._parent.preloader_mc._alpha = 0;
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = xmlLoaded;
xml.load(xmlFileUrl);
// Load the xml file into the player
function xmlLoaded(b:Boolean) {
if (b) {
auto_play = this.firstChild.firstChild.attributes.auto_play;
scrollSpeed = parseInt(this.firstChild.firstChild.attributes.scrollSpeed);
totalItems = this.firstChild.firstChild.childNodes;
numOfItems = totalItems.length;
for (j=0; j<numOfItems; j++) {
var i = player_mc.main_mc.collection_mc.attachMovie("mc_Thumb", "thumb_"+j, j);
i._x = itemDistance*j;
thumbLoader.loadClip(totalItems[j].attributes.thumb,i.loader_mc);
i.id = j;
i.videoTitle = totalItems[j].attributes.title;
i.videoUrl = totalItems[j].attributes.src;
// Create an event for thumb rollover
i.onRollOver = iRoll;
i.onRollOut = i.onReleaseOutside=iOut;
i.onRelease = iRelease;
thuArray[j] = i;
// default first video
collectionWidth = player_mc.main_mc.collection_mc._width;
currentVideo = 0;
V_SRC = thuArray[0].videoUrl;
changeVideo();
//scope._alpha = 100;
new Tween(scope, "_alpha", Regular.easeOut, 0, 100, 0.5, true);
else
trace("Error! xml file not loaded");
// onRollOver Events
function iRoll() {
player_mc.mc_title.title_txt.htmlText = totalItems[this.id].attributes.title;
this.light_mc.play();
function iRelease() {
currentVideo = this.id;
changeVideo();
function changeVideo() {
V_SRC = thuArray[currentVideo].videoUrl;
player_mc.loadVideo();
currentThumb();
player_mc.mc_title.title_txt.htmlText = thuArray[currentVideo].videoTitle;
video_txt.theText.text = totalItems[currentVideo].attributes.title;
player_mc.so.getVolume();
player_mc.playStatus = 1;
player_mc.checkStatus();
function nextVideo() {
if (currentVideo<(numOfItems-1)) {
currentVideo++;
} else {
currentVideo = 0;
changeVideo();
function currentThumb() {
for (i=0; i<thuArray.length; i++) {
if (i == currentVideo) {
thuArray[i].enabled = true;
// Mouse movement on rollover
this.onMouseMove = function() {
collectionWidth = player_mc.main_mc.collection_mc._width;
boundry = player_mc.main_mc.area_mc._width;
if ((player_mc.main_mc._ymouse>0) && (player_mc.main_mc._ymouse<itemHeight)) {
if ((player_mc.main_mc._xmouse>0) && (player_mc.main_mc._xmouse<boundry)) {
ratio = player_mc.main_mc._xmouse/boundry;
diff = (collectionWidth-boundry)+buffer;
Value = Math.floor((-ratio)*diff)+(buffer/2);
updateAfterEvent();
this.onEnterFrame = function() {
// Define movement area and speed
if (player_mc.main_mc.collection_mc._width>player_mc.main_mc.area_mc._width) {
player_mc.main_mc.collection_mc._x = Math.round((player_mc.main_mc.collection_mc._x)+((Value-player_mc.main_mc.collection_mc._ x)/scrollSpeed));
if (player_mc.main_mc.collection_mc._x>0) {
player_mc.main_mc.collection_mc._x = 0;
} else if (player_mc.main_mc.collection_mc._x<(player_mc.main_mc.area_mc._width-(player_mc.main_mc. collection_mc._width))) {
player_mc.main_mc.collection_mc._x = Math.round(player_mc.main_mc.area_mc._width-(player_mc.main_mc.collection_mc._width));
} else {
player_mc.main_mc.collection_mc._x = 0;
updateAfterEvent();
part two:
// Define flash variables
var video_url:String = "";
var tempx:Number = this._parent._x;
var tempy:Number = this._parent._y;
var timeCounter:Number = 0;
var timeInSeconds:Number = _root.time_counter;
// Object to listen to onStage Event
videoObj = vid.videoObj;
// Setting up the connection
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
// Buffer time
ns.setBufferTime (10);
videoObj.attachVideo (ns);
function loadVideo () {
video_url = _parent.V_SRC;
trace(video_url);
ns.play (video_url);
function checkStatus()
if (playStatus == 1)
controls_mc.playPause.gotoAndStop("pause");
mc_playAgain._visible = false;
thumbs_out = false;
title_out = false;
else
controls_mc.playPause.gotoAndStop("play");
mc_playAgain._visible = true;
} // end else if
if (so.getVolume() == 0)
controls_mc.mute_mc.gotoAndStop("mute");
else
controls_mc.mute_mc.gotoAndStop("on");
}; // End of the function
mc_playAgain._visible = false;
// Check Status of video
ns.onStatus = function (info)
if (info.code == "NetStream.Buffer.Empty")
mc_buffer._visible = true;
else if (info.code == "NetStream.Buffer.Full")
mc_buffer._visible = false;
else if (info.code == "NetStream.Play.Stop")
ns.seek(0);
if (playStatus == 1)
ns.pause();
playStatus = 0;
else
trace;
} // end else if
mc_playAgain._visible = true;
mc_buffer._visible = false;
thumbs_out = true;
title_out = true;
checkStatus();
} // end else if
// Get info about video
ns.onMetaData = function(infoObject:Object)
FLVduration = infoObject["duration"];
relationshipW = infoObject.height / infoObject.width;
relationshipH = infoObject.width / infoObject.height;
if (Stage["displayState"] == "fullScreen")
largeSize ();
else
regularSize ();
if (_parent.auto_play == "false")
ns.seek(0);
if (playStatus == 1)
ns.pause();
playStatus = 0;
mc_buffer._visible = false;
controls_mc.playPause.gotoAndStop("play");
mc_playAgain._visible = true;
thumbs_out = true;
title_out = true;
_parent.auto_play = "true";
}// end else if
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded;
var duration;
// videoStatus on load Event
function videoStatus()
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
controls_mc.mc_progress.mc_buff._width = amountLoaded * 250;
controls_mc.mc_progress.mc_played._x = ns.time / duration * 250;
controls_mc.mc_progress.mc_played._xscale = Math.round(ns.time*100/FLVduration);
}; // End of the function
function scrubIt()
ns.seek(Math.floor(controls_mc.mc_progress.mc_played._x / 250 * duration));
}; // End of the function
// video time
var time_interval:Number = setInterval(checkTime, 500, ns);
function checkTime(ns:NetStream) {
//current time
var ns_seconds:Number = ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60);
sec = seconds;
min = minutes;
if (sec<10) {
sec = "0"+sec;
if (min<10) {
min = "0"+min;
controls_mc.time_txt.time_1.text = min+":"+sec;
//total time
var minutes2:Number = Math.floor(FLVduration/60);
var seconds2 = Math.floor(FLVduration%60);
sec2 = seconds2;
min2 = minutes2;
if (sec2<10) {
sec2 = "0"+sec2;
if (min2<10) {
min2 = "0"+min2;
controls_mc.time_txt.time_2.text = min2+":"+sec2;
if (controls_mc.time_txt.time_2.text == "NaN:NaN") {
controls_mc.time_txt.time_2.text = "00:00";
setStage ();
// Object to listen onStage Event
var stageL:Object = new Object ();
// function respnsible for content alignment
function setStage ()
if (Stage["displayState"] == "fullScreen") {
tempx = this._parent._x;
tempy = this._parent._y;
this._parent._x = 0;
this._parent._y = 0;
vidBg_mc._x = 0;
vidBg_mc._y = 0;
mc_title._x = 0;
mc_title._y = -30;
slide_me._x = 0;
slide_me._y = 0;
vidBg_mc._width = Stage.width;
vidBg_mc._height = Stage.height;
mc_title._width = Stage.width;
mc_title._height = Stage.height / 20;
slide_me._width = Stage.width;
slide_me._height = Stage.height / 20;
vid._x = vid._y = 0;
largeSize ();
controls_mc._x = Math.round ((Stage.width / 2) - (controls_mc._width / 2));
controls_mc._y = Math.round (Stage.height - 36);
mc_playAgain._x = Math.round ((Stage.width / 2) - (mc_playAgain._width / 2));
mc_playAgain._y = Math.round (Stage.height - 572);
thumbs_mc._x = Math.round ((Stage.width / 2) - (thumbs_mc._width / 2));
thumbs_mc._y = Math.round (Stage.height - 115);
main_mc._x = Math.round ((Stage.width / 2) - (controls_mc._width / 2));;
hide_mc.onEnterFrame = function () {
timeCounter = timeCounter + 1;
if (timeCounter >= timeInSeconds * 30) {
timeCounter = 0;
controls_mc._alpha = 0;
this.onMouseMove = function () {
timeCounter = 0;
controls_mc._alpha = 100;
else
delete hide_mc.onEnterFrame;
delete this.onMouseMove;
controls_mc._alpha = 100;
this._parent._x = tempx;
this._parent._y = tempy;
vidBg_mc._width = 600;
vidBg_mc._height = 360;
mc_title._width = 600;
mc_title._height = 30;
slide_me._width = 600;
slide_me._height = 30;
vidBg_mc._x = vid._x = 0;
vidBg_mc._y = vid._y = 35;
mc_title._x = vid._x = 0;
mc_title._y = vid._x = -30;
slide_me._x = vid._x = 0;
slide_me._y = vid._y = 35;
regularSize ();
controls_mc._x = 0;
controls_mc._y = 395;
mc_playAgain._x = 243;
mc_playAgain._y = 158;
thumbs_mc._x = 0;
thumbs_mc._y = 316;
main_mc._x = 0;
main_mc._y = 406;
mc_buffer._x = Math.round (vidBg_mc._x + (vidBg_mc._width / 2));
mc_buffer._y = Math.round (vidBg_mc._y + (vidBg_mc._height / 2));
// to apply when stage (browser window) is resized or modified
stageL.onResize = function () {
setStage ();
// attaching object to the stage
Stage.addListener (stageL);
MovieClip.prototype.slide = function(yPos) {
this._y -= (this._y-yPos)/5;
// tilte actions
mc_title.onEnterFrame = function()
if (Stage["displayState"] == "normal" && title_out == false)
this.slide(5);
else if (Stage["displayState"] == "normal" && title_out == true)
this.slide(35);
if (Stage["displayState"] == "fullScreen" && title_out == false)
this._y -= (this._y+106)/5;
else if (Stage["displayState"] == "fullScreen" && title_out == true)
this.slide(0);
// thumbs actions
main_mc.onEnterFrame = function()
if (Stage["displayState"] == "normal" && thumbs_out == false)
this.slide(406);
else if (Stage["displayState"] == "normal" && thumbs_out == true)
this.slide(299);
if (Stage["displayState"] == "fullScreen" && thumbs_out == false)
this._y = Math.round (Stage.height - 0);
else if (Stage["displayState"] == "fullScreen" && thumbs_out == true)
this._y = Math.round (Stage.height - 133);
// Playlist button
controls_mc.playlist_mc.onRollOver = function ()
this.gotoAndStop("playlistOver");
controls_mc.playlist_mc.onRollOut = controls_mc.playlist_mc.onReleaseOutside = function ()
this.gotoAndStop("playlist");
// Toggle playlist button
controls_mc.playlist_mc.onRelease = function ()
if (thumbs_out == false)
thumbs_out = true;
title_out = true;
else if (thumbs_out == true)
thumbs_out = false;
title_out = false;
} // end if else
// Define hit area for playPause button
vid.onPress = controls_mc.playPause.onRelease = function ()
ns.pause();
if (playStatus == 1)
controls_mc.playPause.gotoAndStop("play")
playStatus = 0;
checkStatus();
else if (playStatus == 0)
controls_mc.playPause.gotoAndStop("pause");
playStatus = 1;
checkStatus();
// playPause button
controls_mc.playPause.onRollOver = function ()
if (playStatus == 1)
this.gotoAndStop("pauseOver");
else
this.gotoAndStop("playOver");
} // end else if
controls_mc.playPause.onRollOut = controls_mc.playPause.onReleaseOutside = function ()
if (playStatus == 1)
this.gotoAndStop("pause");
else
this.gotoAndStop("play");
} // end else if
// Toggle playPause button
controls_mc.playPause.onRelease = function ()
ns.pause();
if (playStatus == 1)
this.gotoAndStop("play");
playStatus = 0;
checkStatus();
else if (playStatus == 0)
this.gotoAndStop("pause");
playStatus = 1;
checkStatus();
controls_mc.skip_mc.onRollOver = function ()
this.gotoAndStop("skipOver");
controls_mc.skip_mc.onRollOut = controls_mc.skip_mc.onReleaseOutside = function ()
this.gotoAndStop("skip");
controls_mc.skip_mc.onRelease = function ()
_parent.nextVideo()
// Play Again button
mc_playAgain.onRollOver = function ()
this.gotoAndStop("playAgainOver");
mc_playAgain.onRollOut = mc_playAgain.onReleaseOutside = function ()
this.gotoAndStop("playAgain");
// Toggle Play Again button
mc_playAgain.onRelease = function ()
this._visible = false;
ns.pause();
playStatus = 1;
checkStatus();
// make the seek bar clickable
controls_mc.mc_progress.mc_buff.onPress = function()
xpos = controls_mc.mc_progress._xmouse;
percent = Math.round(xpos/controls_mc.mc_progress._width*100);
seekTime = percent/100*FLVduration;
seekTime = Math.round(seekTime*100)/100;
ns.seek(seekTime);
// Set volume level
var s:Sound = new Sound();
s.setVolume(_root.volume_value);
controls_mc.mc_soundLevel.mc_volume._xscale = _root.volume_value;
// Volume control
controls_mc.mc_soundLevel.onPress = function()
volumeTo = (this._xmouse / this._width)*100;
this.mc_volume._xscale = volumeTo;
s.setVolume(volumeTo);
// Volume
_parent.createEmptyMovieClip("vSound", _parent.getNextHighestDepth());
vSound.attachAudio(ns);
var so = new Sound(vSound);
so.setVolume(_root.volume_value);
// Mute button
controls_mc.mute_mc.onRollOver = function ()
if (so.getVolume() >= 1)
this.gotoAndStop("onOver");
else
this.gotoAndStop("muteOver");
} // end else if
controls_mc.mute_mc.onRollOut = controls_mc.mute_mc.onReleaseOutside = function ()
if (so.getVolume() >= 1)
this.gotoAndStop("on");
else
this.gotoAndStop("mute");
} // end else if
// Toggle mute button
controls_mc.mute_mc.onRelease = function ()
if (so.getVolume() >= 1)
controls_mc.mc_soundLevel.mc_volume._xscale = 0;
so.setVolume(0);
this.gotoAndStop("muteOver");
else
controls_mc.mc_soundLevel.mc_volume._xscale = 70;
so.setVolume(_root.volume_value);
this.gotoAndStop("onOver");
} // end else if
// Resize video proportionaly
function regularSize ()
videoObj._width = 600;
videoObj._height = videoObj._width * relationshipW;
if (videoObj._height > 360)
videoObj._height = 360;
videoObj._width = videoObj._height * relationshipH;
videoObj.smoothing = true;
//var scale:Number;
videoObj._x = (600 - videoObj._width) / 2;
videoObj._y = (360 - videoObj._height) / 2;
function largeSize ()
videoObj._width = Stage.width;
videoObj._height = videoObj._width * relationshipW;
if (videoObj._height > Stage.height)
videoObj._height = Stage.height;
videoObj._width = videoObj._height * relationshipH;
videoObj.smoothing = true;
//var scale:Number;
videoObj._x = (Stage.width - videoObj._width) / 2;
videoObj._y = (Stage.height - videoObj._height) / 2;
// Fullscreen button
controls_mc.fullscreen_mc.onRollOver = function ()
if (Stage["displayState"] == "normal")
this.gotoAndStop("fullOver");
else
this.gotoAndStop("fullCloseOver");
} // end else if
controls_mc.fullscreen_mc.onRollOut = controls_mc.fullscreen_mc.onReleaseOutside = function ()
if (Stage["displayState"] == "normal")
this.gotoAndStop("full");
else
this.gotoAndStop("fullClose");
} // end else if
// Toggle fullscreen button
controls_mc.fullscreen_mc.onRelease = function ()
if (Stage["displayState"] == "normal")
Stage["displayState"] = "fullscreen";
_parent.video_txt.theText._visible = false;
else
Stage["displayState"] = "normal";
_parent.video_txt.theText._visible = true;if you mean sound works well when the gallery is tested without being loaded into another swf but fails when loaded, change the highlighted line:
// Import filter classes
import mx.transitions.Tween;
import mx.transitions.easing.*;
// Set flash variables
var xmlFileUrl:String = "playlist.xml";
var auto_play:String = "true";
// Set xml file URL
if (_root.xmlfile) {
xmlFileUrl = _root.xmlfile;
var V_SRC;
var thuArray:Array = new Array();
var currentVideo:Number = 0;
var totalItems;
var numOfItems:Number;
var itemDistance:Number = 120+5;
var itemHeight:Number = 80+2;
var Value:Number = 1;
var boundry:Number = 1;
var ratio:Number = 1;
var diff:Number = 1;
var collectionWidth:Number = 1;
var buffer:Number = 135*2;
this.createEmptyMovieClip("video_txt",this.getNextHighestDepth());
video_txt.createTextField("theText",video_txt.getNextHighestDepth(),0,0,584,36);
video_txt.theText.selectable = false;
video_txt.theText.autoSize = "left";
//The Format
myFormat = new TextFormat();
myFormat.font = _root.font_format;
myFormat.size = _root.font_size;
myFormat.color = _root.font_color;
myFormat.align = "center";
video_txt.theText.setNewTextFormat(myFormat);
// Create a new movieclip to load the thumbs
var thumbLoader:MovieClipLoader = new MovieClipLoader();
var thumbListener:Object = new Object();
thumbLoader.addListener(thumbListener);
thumbListener.onLoadInit = function(target_mc:MovieClip, httpStatus:Number)
new Tween(target_mc, "_alpha", Regular.easeOut, 0, 100, 1, true);
target_mc._parent.preloader_mc._alpha = 0;
var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = xmlLoaded;
xml.load(xmlFileUrl);
// Load the xml file into the player
function xmlLoaded(b:Boolean) {
if (b) {
auto_play = this.firstChild.firstChild.attributes.auto_play;
scrollSpeed = parseInt(this.firstChild.firstChild.attributes.scrollSpeed);
totalItems = this.firstChild.firstChild.childNodes;
numOfItems = totalItems.length;
for (j=0; j<numOfItems; j++) {
var i = player_mc.main_mc.collection_mc.attachMovie("mc_Thumb", "thumb_"+j, j);
i._x = itemDistance*j;
thumbLoader.loadClip(totalItems[j].attributes.thumb,i.loader_mc);
i.id = j;
i.videoTitle = totalItems[j].attributes.title;
i.videoUrl = totalItems[j].attributes.src;
// Create an event for thumb rollover
i.onRollOver = iRoll;
i.onRollOut = i.onReleaseOutside=iOut;
i.onRelease = iRelease;
thuArray[j] = i;
// default first video
collectionWidth = player_mc.main_mc.collection_mc._width;
currentVideo = 0;
V_SRC = thuArray[0].videoUrl;
changeVideo();
//scope._alpha = 100;
new Tween(scope, "_alpha", Regular.easeOut, 0, 100, 0.5, true);
else
trace("Error! xml file not loaded");
// onRollOver Events
function iRoll() {
player_mc.mc_title.title_txt.htmlText = totalItems[this.id].attributes.title;
this.light_mc.play();
function iRelease() {
currentVideo = this.id;
changeVideo();
function changeVideo() {
V_SRC = thuArray[currentVideo].videoUrl;
player_mc.loadVideo();
currentThumb();
player_mc.mc_title.title_txt.htmlText = thuArray[currentVideo].videoTitle;
video_txt.theText.text = totalItems[currentVideo].attributes.title;
player_mc.so.getVolume();
player_mc.playStatus = 1;
player_mc.checkStatus();
function nextVideo() {
if (currentVideo<(numOfItems-1)) {
currentVideo++;
} else {
currentVideo = 0;
changeVideo();
function currentThumb() {
for (i=0; i<thuArray.length; i++) {
if (i == currentVideo) {
thuArray[i].enabled = true;
// Mouse movement on rollover
this.onMouseMove = function() {
collectionWidth = player_mc.main_mc.collection_mc._width;
boundry = player_mc.main_mc.area_mc._width;
if ((player_mc.main_mc._ymouse>0) && (player_mc.main_mc._ymouse<itemHeight)) {
if ((player_mc.main_mc._xmouse>0) && (player_mc.main_mc._xmouse<boundry)) {
ratio = player_mc.main_mc._xmouse/boundry;
diff = (collectionWidth-boundry)+buffer;
Value = Math.floor((-ratio)*diff)+(buffer/2);
updateAfterEvent();
this.onEnterFrame = function() {
// Define movement area and speed
if (player_mc.main_mc.collection_mc._width>player_mc.main_mc.area_mc._width) {
player_mc.main_mc.collection_mc._x = Math.round((player_mc.main_mc.collection_mc._x)+((Value-player_mc.main_mc.colle ction_mc._x)/scrollSpeed));
if (player_mc.main_mc.collection_mc._x>0) {
player_mc.main_mc.collection_mc._x = 0;
} else if (player_mc.main_mc.collection_mc._x<(player_mc.main_mc.area_mc._width-(player_m c.main_mc.collection_mc._width))) {
player_mc.main_mc.collection_mc._x = Math.round(player_mc.main_mc.area_mc._width-(player_mc.main_mc.collection_mc._w idth));
} else {
player_mc.main_mc.collection_mc._x = 0;
updateAfterEvent();
part two:
// Define flash variables
var video_url:String = "";
var tempx:Number = this._parent._x;
var tempy:Number = this._parent._y;
var timeCounter:Number = 0;
var timeInSeconds:Number = _root.time_counter;
// Object to listen to onStage Event
videoObj = vid.videoObj;
// Setting up the connection
var nc:NetConnection = new NetConnection();
nc.connect(null);
var ns:NetStream = new NetStream(nc);
// Buffer time
ns.setBufferTime (10);
videoObj.attachVideo (ns);
function loadVideo () {
video_url = _parent.V_SRC;
trace(video_url);
ns.play (video_url);
function checkStatus()
if (playStatus == 1)
controls_mc.playPause.gotoAndStop("pause");
mc_playAgain._visible = false;
thumbs_out = false;
title_out = false;
else
controls_mc.playPause.gotoAndStop("play");
mc_playAgain._visible = true;
} // end else if
if (so.getVolume() == 0)
controls_mc.mute_mc.gotoAndStop("mute");
else
controls_mc.mute_mc.gotoAndStop("on");
}; // End of the function
mc_playAgain._visible = false;
// Check Status of video
ns.onStatus = function (info)
if (info.code == "NetStream.Buffer.Empty")
mc_buffer._visible = true;
else if (info.code == "NetStream.Buffer.Full")
mc_buffer._visible = false;
else if (info.code == "NetStream.Play.Stop")
ns.seek(0);
if (playStatus == 1)
ns.pause();
playStatus = 0;
else
trace;
} // end else if
mc_playAgain._visible = true;
mc_buffer._visible = false;
thumbs_out = true;
title_out = true;
checkStatus();
} // end else if
// Get info about video
ns.onMetaData = function(infoObject:Object)
FLVduration = infoObject["duration"];
relationshipW = infoObject.height / infoObject.width;
relationshipH = infoObject.width / infoObject.height;
if (Stage["displayState"] == "fullScreen")
largeSize ();
else
regularSize ();
if (_parent.auto_play == "false")
ns.seek(0);
if (playStatus == 1)
ns.pause();
playStatus = 0;
mc_buffer._visible = false;
controls_mc.playPause.gotoAndStop("play");
mc_playAgain._visible = true;
thumbs_out = true;
title_out = true;
_parent.auto_play = "true";
}// end else if
var videoInterval = setInterval(videoStatus, 100);
var amountLoaded;
var duration;
// videoStatus on load Event
function videoStatus()
amountLoaded = ns.bytesLoaded / ns.bytesTotal;
controls_mc.mc_progress.mc_buff._width = amountLoaded * 250;
controls_mc.mc_progress.mc_played._x = ns.time / duration * 250;
controls_mc.mc_progress.mc_played._xscale = Math.round(ns.time*100/FLVduration);
}; // End of the function
function scrubIt()
ns.seek(Math.floor(controls_mc.mc_progress.mc_played._x / 250 * duration));
}; // End of the function
// video time
var time_interval:Number = setInterval(checkTime, 500, ns);
function checkTime(ns:NetStream) {
//current time
var ns_seconds:Number = ns.time;
var minutes:Number = Math.floor(ns_seconds/60);
var seconds = Math.floor(ns_seconds%60);
sec = seconds;
min = minutes;
if (sec<10) {
sec = "0"+sec;
if (min<10) {
min = "0"+min;
controls_mc.time_txt.time_1.text = min+":"+sec;
//total time
var minutes2:Number = Math.floor(FLVduration/60);
var seconds2 = Math.floor(FLVduration%60);
sec2 = seconds2;
min2 = minutes2;
if (sec2<10) {
sec2 = "0"+sec2;
if (min2<10) {
min2 = "0"+min2;
controls_mc.time_txt.time_2.text = min2+":"+sec2;
if (controls_mc.time_txt.time_2.text == "NaN:NaN") {
controls_mc.time_txt.time_2.text = "00:00";
setStage ();
// Object to listen onStage Event
var stageL:Object = new Object ();
// function respnsible for content alignment
function setStage ()
if (Stage["displayState"] == "fullScreen") {
tempx = this._parent._x;
tempy = this._parent._y;
this._parent._x = 0;
this._parent._y = 0;
vidBg_mc._x = 0;
vidBg_mc._y = 0;
mc_title._x = 0;
mc_title._y = -30;
slide_me._x = 0;
slide_me._y = 0;
vidBg_mc._width = Stage.width;
vidBg_mc._height = Stage.height;
mc_title._width = Stage.width;
mc_title._height = Stage.height / 20;
slide_me._width = Stage.width;
slide_me._height = Stage.height / 20;
vid._x = vid._y = 0;
largeSize ();
controls_mc._x = Math.round ((Stage.width / 2) - (controls_mc._width / 2));
controls_mc._y = Math.round (Stage.height - 36);
mc_playAgain._x = Math.round ((Stage.width / 2) - (mc_playAgain._width / 2));
mc_playAgain._y = Math.round (Stage.height - 572);
thumbs_mc._x = Math.round ((Stage.width / 2) - (thumbs_mc._width / 2));
thumbs_mc._y = Math.round (Stage.height - 115);
main_mc._x = Math.round ((Stage.width / 2) - (controls_mc._width / 2));;
hide_mc.onEnterFrame = function () {
timeCounter = timeCounter + 1;
if (timeCounter >= timeInSeconds * 30) {
timeCounter = 0;
controls_mc._alpha = 0;
this.onMouseMove = function () {
timeCounter = 0;
controls_mc._alpha = 100;
else
delete hide_mc.onEnterFrame;
delete this.onMouseMove;
controls_mc._alpha = 100;
this._parent._x = tempx;
this._parent._y = tempy;
vidBg_mc._width = 600;
vidBg_mc._height = 360;
mc_title._width = 600;
mc_title._height = 30;
slide_me._width = 600;
slide_me._height = 30;
vidBg_mc._x = vid._x = 0;
vidBg_mc._y = vid._y = 35;
mc_title._x = vid._x = 0;
mc_title._y = vid._x = -30;
slide_me._x = vid._x = 0;
slide_me._y = vid._y = 35;
regularSize ();
controls_mc._x = 0;
controls_mc._y = 395;
mc_playAgain._x = 243;
mc_playAgain._y = 158;
thumbs_mc._x = 0;
thumbs_mc._y = 316;
main_mc._x = 0;
main_mc._y = 406;
mc_buffer._x = Math.round (vidBg_mc._x + (vidBg_mc._width / 2));
mc_buffer._y = Math.round (vidBg_mc._y + (vidBg_mc._height / 2));
// to apply when stage (browser window) is resized or modified
stageL.onResize = function () {
setStage ();
// attaching object to the stage
Stage.addListener (stageL);
MovieClip.prototype.slide = function(yPos) {
this._y -= (this._y-yPos)/5;
// tilte actions
mc_title.onEnterFrame = function()
if (Stage["displayState"] == "normal" && title_out == false)
this.slide(5);
else if (Stage["displayState"] == "normal" && title_out == true)
this.slide(35);
if (Stage["displayState"] == "fullScreen" && title_out == false)
this._y -= (this._y+106)/5;
else if (Stage["displayState"] == "fullScreen" && title_out == true)
this.slide(0);
// thumbs actions
main_mc.onEnterFrame = function()
if (Stage["displayState"] == "normal" && thumbs_out == false)
this.slide(406);
else if (Stage["displayState"] == "normal" && thumbs_out == true)
this.slide(299);
if (Stage["displayState"] == "fullScreen" && thumbs_out == false)
this._y = Math.round (Stage.height - 0);
else if (Stage["displayState"] == "fullScreen" && thumbs_out == true)
this._y = Math.round (Stage.height - 133);
// Playlist button
controls_mc.playlist_mc.onRollOver = function ()
this.gotoAndStop("playlistOver");
controls_mc.playlist_mc.onRollOut = controls_mc.playlist_mc.onReleaseOutside = function ()
this.gotoAndStop("playlist");
// Toggle playlist button
controls_mc.playlist_mc.onRelease = function ()
if (thumbs_out == false)
thumbs_out = true;
title_out = true;
else if (thumbs_out == true)
thumbs_out = false;
title_out = false;
} // end if else
// Define hit area for playPause button
vid.onPress = controls_mc.playPause.onRelease = function ()
ns.pause();
if (playStatus == 1)
controls_mc.playPause.gotoAndStop("play")
playStatus = 0;
checkStatus();
else if (playStatus == 0)
controls_mc.playPause.gotoAndStop("pause");
playStatus = 1;
checkStatus();
// playPause button
controls_mc.playPause.onRollOver = function ()
if (playStatus == 1)
this.gotoAndStop("pauseOver");
else
this.gotoAndStop("playOver");
} // end else if
controls_mc.playPause.onRollOut = controls_mc.playPause.onReleaseOutside = function ()
if (playStatus == 1)
this.gotoAndStop("pause");
else
this.gotoAndStop("play");
} // end else if
// Toggle playPause button
controls_mc.playPause.onRelease = function ()
ns.pause();
if (playStatus == 1)
this.gotoAndStop("play");
playStatus = 0;
checkStatus();
else if (playStatus == 0)
this.gotoAndStop("pause");
playStatus = 1;
checkStatus();
controls_mc.skip_mc.onRollOver = function ()
this.gotoAndStop("skipOver");
controls_mc.skip_mc.onRollOut = controls_mc.skip_mc.onReleaseOutside = function ()
this.gotoAndStop("skip");
controls_mc.skip_mc.onRelease = function ()
_parent.nextVideo()
// Play Again button
mc_playAgain.onRollOver = function ()
this.gotoAndStop("playAgainOver");
mc_playAgain.onRollOut = mc_playAgain.onReleaseOutside = function ()
this.gotoAndStop("playAgain");
// Toggle Play Again button
mc_playAgain.onRelease = function ()
this._visible = false;
ns.pause();
playStatus = 1;
checkStatus();
// make the seek bar clickable
controls_mc.mc_progress.mc_buff.onPress = function()
xpos = controls_mc.mc_progress._xmouse;
percent = Math.round(xpos/controls_mc.mc_progress._width*100);
seekTime = percent/100*FLVduration;
seekTime = Math.round(seekTime*100)/100;
ns.seek(seekTime);
// Set volume level
var s:Sound = new Sound(this);
s.setVolume(_root.volume_value);
controls_mc.mc_soundLevel.mc_volume._xscale = _root.volume_value;
// Volume control
controls_mc.mc_soundLevel.onPress = function()
volumeTo = (this._xmouse / this._width)*100;
this.mc_volume._xscale = volumeTo;
s.setVolume(volumeTo);
// Volume
_parent.createEmptyMovieClip("vSound", _parent.getNextHighestDepth());
vSound.attachAudio(ns);
var so = new Sound(vSound);
so.setVolume(_root.volume_value);
// Mute button
controls_mc.mute_mc.onRollOver = function ()
if (so.getVolume() >= 1)
this.gotoAndStop("onOver");
else
this.gotoAndStop("muteOver");
} // end else if
controls_mc.mute_mc.onRollOut = controls_mc.mute_mc.onReleaseOutside = function ()
if (so.getVolume() >= 1)
this.gotoAndStop("on");
else
this.gotoAndStop("mute");
} // end else if
// Toggle mute button
controls_mc.mute_mc.onRelease = function ()
if (so.getVolume() >= 1)
controls_mc.mc_soundLevel.mc_volume._xscale = 0;
so.setVolume(0);
this.gotoAndStop("muteOver");
else
controls_mc.mc_soundLevel.mc_volume._xscale = 70;
so.setVolume(_root.volume_value);
this.gotoAndStop("onOver");
} // end else if
// Resize video proportionaly
function regularSize ()
videoObj._width = 600;
videoObj._height = videoObj._width * relationshipW;
if (videoObj._height > 360)
videoObj._height = 360;
videoObj._width = videoObj._height * relationshipH;
videoObj.smoothing = true;
//var scale:Number;
videoObj._x = (600 - videoObj._width) / 2;
videoObj._y = (360 - videoObj._height) / 2;
function largeSize ()
videoObj._width = Stage.width;
videoObj._height = videoObj._width * relationshipW;
if (videoObj._height > Stage.height)
videoObj._height = Stage.height;
videoObj._width = videoObj._height * relationshipH;
videoObj.smoothing = true;
//var scale:Number;
videoObj._x = (Stage.width - videoObj._width) / 2;
videoObj._y = (Stage.height - videoObj._height) / 2;
// Fullscreen button
controls_mc.fullscreen_mc.onRollOver = function ()
if (Stage["displayState"] == "normal")
this.gotoAndStop("fullOver");
else
this.gotoAndStop("fullCloseOver");
} // end else if
controls_mc.fullscreen_mc.onRollOut = controls_mc.fullscreen_mc.onReleaseOutside = function ()
if (Stage["displayState"] == "normal")
this.gotoAndStop("full");
else
this.gotoAndStop("fullClose");
} // end else if
// Toggle fullscreen button
controls_mc.fullscreen_mc.onRelease = function ()
if (Stage["displayState"] == "normal")
Stage["displayState"] = "fullscreen";
_parent.video_txt.theText._visible = false;
else
Stage["displayState"] = "normal";
_parent.video_txt.theText._visible = true; -
Help needed to rewrite code so main menus move down to make way for subs
Can anybody please help me (slightly) alter some code.
I am working on a vertical menu with sub's and need to alter the AS so that when a sub menu is selected, the main menus below it move down to accommodate the new sub menu.
This is the code I am currently using is
GenerateMenu = function(container, name, x, y, depth, node_xml) {
// variable declarations
var curr_node;
var curr_item;
var curr_menu = container.createEmptyMovieClip(name, depth);
// for all items or XML nodes (items and menus)
// within this node_xml passed for this menu
for (var i=0; i<node_xml.childNodes.length; i++) {
// movieclip for each menu item
curr_item = curr_menu.attachMovie("menuitem","item"+i+"_mc", i);
curr_item._x = x;
curr_item._y = y + i*curr_item._height;
curr_item.trackAsMenu = true;
// item properties assigned from XML
curr_node = node_xml.childNodes[i];
curr_item.action = curr_node.attributes.action;
curr_item.variables = curr_node.attributes.variables;
curr_item.name.text = curr_node.attributes.name;
// item submenu behavior for rollover event
if (node_xml.childNodes[i].nodeName == "menu"){
// open a submenu
curr_item.node_xml = curr_node;
curr_item.onRollOver = curr_item.onDragOver = function(){
var x = this._x + this._width -76;
var y = this._y + 55;
GenerateMenu(curr_menu, "submenu_mc", x, y, 10, this.node_xml);
// show a hover color
var col = new Color(this.background);
col.setRGB(0xf4faff);
}else{ // nodeName == "item"
curr_item.arrow._visible = false;
// close existing submenu
curr_item.onRollOut = curr_item.onDragOut = function(){
// restore color
var col = new Color(this.background);
col.setTransform({ra:100,rb:0,ga:100,gb:0,ba:100,bb:0});
// any item, menu opening or not can have actions
curr_item.onRelease = function(){
Actions[this.action](this.variables);
CloseSubmenus();
} // end for loop
// create the main menu, this will be constantly visible
CreateMainMenu = function(x, y, depth, menu_xml){
// generate a menu list
GenerateMenu(this, "mainmenu_mc", x, y, depth, menu_xml.firstChild);
// close only submenus if visible durring a mouseup
// this main menu (mainmenu_mc) will remain
mainmenu_mc.onMouseUp = function(){
if (mainmenu_mc.submenu_mc && !mainmenu_mc.hitTest(_root._xmouse, _root._ymouse, true)){
CloseSubmenus();
// closes all submenus by removing the submenu_mc
// in the main menu (if it exists)
CloseSubmenus = function(){
mainmenu_mc.submenu_mc.removeMovieClip();
// This actions object handles methods for actions
// defined by the XML called when a menu item is pressed
Actions = Object();
Actions.gotoURL = function(urlVar){
getURL(urlVar, "_blank");
Actions.message = function(msg){
message_txt.text = msg;
Actions.newMenu = function(menuxml){
menu_xml.load(menuxml);
// load XML, when done, run CreateMainMenu to interpret it
menu_xml = new XML();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function(ok){
// create main menu after successful loading of XML
if (ok){
CreateMainMenu(10, 10, 0, this);
message_txt.text = "message area";
}else{
message_txt.text = "error: XML not successfully loaded";
// load first XML menu
menu_xml.load("menu1.xml");
Any help/feed back - even if its just to tell me Im asking for too much, would be incredibly appriciated.onclipevent(load)
total=_root.getbytestotal();
onclipevent(enterframe)
loaded=_root.getbytesloaded();
current=int(loaded/total*100);
p=""+current+"%";
if(loaded==total)
gotoandplay("Scene 2",1);
sorry for getting the code and coment mixed up. -
Filmstrip Magnify Effect, need help...
Heya,
So if you visit
http://www.hookmedia.biz/cabinet_source/v4_f
then you'll see that on the gallery page there is an area for a
filmstrip. This filmstrip works great except that I need the images
to magnify a little when you mouseover them. Can anyone help?
Thanks!Hey thanks for the reply, but unfortunately I couldn't get
that to work. I should have mentioned that in the first frame is
the following AS:
function loadXML(loaded) {
if (loaded) {
xmlNode = this.firstChild;
image = [];
description = [];
thumbnails = [];
total = xmlNode.childNodes.length;
for (i=0; i<total; i++) {
image
= xmlNode.childNodes.childNodes[0].firstChild.nodeValue;
description
= xmlNode.childNodes.childNodes[1].firstChild.nodeValue;
thumbnails
= xmlNode.childNodes.childNodes[2].firstChild.nodeValue;
thumbnails_fn(i);
firstImage();
} else {
content = "file not loaded!";
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("images.xml");
listen = new Object();
listen.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
prevImage();
} else if (Key.getCode() == Key.RIGHT) {
nextImage();
Key.addListener(listen);
previous_btn.onRelease = function() {
prevImage();
next_btn.onRelease = function() {
nextImage();
p = 0;
this.onEnterFrame = function() {
filesize = picture.getBytesTotal();
loaded = picture.getBytesLoaded();
preloader._visible = true;
if (loaded != filesize) {
preloader.preload_bar._xscale = 100*loaded/filesize;
} else {
preloader._visible = false;
if (picture._alpha<100) {
picture._alpha += 10;
function nextImage() {
if (p<(total-1)) {
p++;
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
function prevImage() {
if (p>0) {
p--;
picture._alpha = 0;
picture.loadMovie(image[p], 1);
desc_txt.text = description[p];
picture_num();
function firstImage() {
if (loaded == filesize) {
picture._alpha = 0;
picture.loadMovie(image[0], 1);
desc_txt.text = description[0];
picture_num();
function picture_num() {
current_pos = p+1;
pos_txt.text = current_pos+" / "+total;
function thumbNailScroller() {
// thumbnail code!
this.createEmptyMovieClip("tscroller", 1000);
scroll_speed = 10;
tscroller.onEnterFrame = function() {
if ((_root._ymouse>=thumbnail_mc._y) &&
(_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
if ((_root._xmouse>=(hit_right._x-40)) &&
(thumbnail_mc.hitTest(hit_right))) {
thumbnail_mc._x -= scroll_speed;
} else if ((_root._xmouse<=(hit_left._x+40)) &&
(thumbnail_mc.hitTest(hit_left))) {
thumbnail_mc._x += scroll_speed;
} else {
delete tscroller.onEnterFrame;
function thumbnails_fn(k) {
thumbnail_mc.createEmptyMovieClip("t"+k,
thumbnail_mc.getNextHighestDepth());
tlistener = new Object();
tlistener.onLoadInit = function(target_mc) {
target_mc._x = hit_left._x+(target_mc._width+5)*k;
target_mc.pictureValue = k;
target_mc.onRelease = function() {
p = this.pictureValue-1;
nextImage();
target_mc.onRollOver = function() {
this._alpha = 50;
thumbNailScroller();
target_mc.onRollOut = function() {
this._alpha = 100;
image_mcl = new MovieClipLoader();
image_mcl.addListener(tlistener);
image_mcl.loadClip(thumbnails[k], "thumbnail_mc.t"+k); -
I need help understanding how this works. AS 2.0
Its my first time here and i only started learning flash today. I aint too great with maths and i was showed this piece of code that makes a triangles point follow the cursor. It involved mathimatical things ( which i aint so great at) and the guy said "You dont need to know how it works, just how to use it." well i copied his code and it worked, but i have no idea how to use it in other rotation apart from the one he taught us. I dont even understand how to redo his code i saved it to a word document and anytime i wanted to make something rotate something in that fashion i would refer to that. But i dont want to have to do that, i want to know how to use it, dont have to understand it, but use it for other rotation matters. If you are going to help, please try to be a bit simmple i explaining it, cause im new. Dont get me wrong i aint thick but i can find it a bit hard to follow some things, that is i my current problem.
here is the rotation code:
onEnterFrame = function()
hero._rotation = getmouse(hero);
getmouse = function(mc:MovieClip):Number
dy = _ymouse-mc._y;
dx = _xmouse-mc._x;
rad = Math.atan2(dy,dx);
rotate = rad*180/Math.PI
return rotate+90
also if it helps, here is the video i was watching: http://www.youtube.com/watch?v=w3OfrpbNhHs
please if you can, explain how the entire thing works.
thanks for any help given in advance.Hi,
Here's a short primer. It may not be sufficient but here goes.
1st, move the closing bracket at the end and put it on the third line. This makes the code more efficient
onEnterFrame = function(){ // this causes Flash to repeatedly
execute the next line at the
frame rate you selected
for your document
hero._rotation = getmouse(hero); // this tells Flash to rotate a
movie clip (named hero) based
on the function getmouse()
}; // putting the }; here makes the
code more efficient and readable
getmouse = function(mc:MovieClip):Number{ // This is the function called with
mc referring to hero that was
passed from the second line.
dy = _ymouse-mc._y; // dy means delta y which subtracts
the y position of the movieclip
from the mouses y position
dx = _xmouse-mc._x; // dx = delta x (same as above line
but on the x axis)
// once you have the x and y sides
you male a triangle.
Now use trig to find the angle
rad = Math.atan2(dy,dx); // the computer works in radians
the arc tangent atan2 will give the
angle in radians
rotate = rad*180/Math.PI // you want to convert the radians to
degrees, that's what this line does
return rotate+90 // this returns the value of rotate back
to the calling function in line 2.
the +90 determines which part
// of the hero movie clip is facing the
mouse.
If you put the mouse cursor over any of the green reserved words above in the Actions panel you will get a desctription of what these do.
hope that helps. -
Help! Convert simple Flash AS2 code to AS3
Hi everyone,
I'm a Flash beginner and followed a tutorial: http://www.webwasp.co.uk/tutorials/018/tutorial.php ... to learn how to make a "live paint/draw" effect. I didn't realize that if I made something in AS2, I wouldn't be able to embed it (and have it work) into my root AS3 file, where I've got a bunch of other stuff going on. I've tried following tips on how to change AS2 code to AS3, but it just doesn't work. I know it's simple code, and that some genius out there can figure it out, but I'm at a loss. Please help!
Here's the AS2 code:
_root.createEmptyMovieClip("myLine", 0);
_root.onMouseDown = function() {
myLine.moveTo(_xmouse, _ymouse);
ranWidth = Math.round((Math.random() * 10)+2);
myLine.lineStyle(ranWidth, 0xff0000, 100);
_root.onMouseMove = function() {
myLine.lineTo(_xmouse, _ymouse);
_root.onMouseUp = function() {
_root.onMouseMove = noLine;
Thanks in advance!
Signed,
Nicolle
Flash DesperadoConsidering the code is on timeline:
var myLine:Sprite = new Sprite();
addChild(myLine);
var g:Graphics = myLine.graphics;
addEventListener(MouseEvent.MOUSE_DOWN, onMouseDown);
function onMouseDown(e:MouseEvent):void {
var ranWidth:Number = Math.round((Math.random() * 10) + 2);
g.clear();
g.lineStyle(ranWidth, 0xFF0000, 1);
addEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
addEventListener(MouseEvent.MOUSE_UP, onMouseUp);
function onMouseMove(e:MouseEvent):void {
g.lineTo(mouseX, mouseY);
function onMouseUp(e:MouseEvent):void {
removeEventListener(MouseEvent.MOUSE_MOVE, onMouseMove);
removeEventListener(MouseEvent.MOUSE_UP, onMouseUp); -
Xml gallery alignment, help
I am making an XML gallery with thumbnails. It is working fine, but I have a problem with alignment of the images. All the large images are loading into the top left corner. I would like them to load with center alignment for all images. I don't know anything about Action Script. The way I made this website was to use already made sample of some one else. Can you help me to figure out this alignment problem? Again, I am very bad at Action Script, so it would be great if you can show me the actual coding for this to work.
Here is the sample gallery: http://www.chimeddorj.com
Here goes the Sript>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
RemoveAllThumbs.onLoad = function(){
removeAllThumbs()
//init global variables and properties
Stage.scaleMode = "noscale";
import gs.TweenFilterLite;
import gs.TweenLite;
XML LOADING
//handle loading of external images..
var slide:XML = new XML();
slide.ignoreWhite = true;
var largeImageUrl:Array = new Array();
var thumbUrl:Array = new Array();
var captions:Array = new Array();//not used
var p:Number = 0;//tracks position in arrays
/*!!!!if you want to load in another XML file, make sure you clear the existing thumbnails
by calling the removeAllThumbs() function first!*/
slide.onLoad = function() {
largeImageUrl = [];
thumbUrl = [];
captions = [];
xmlNode = this.firstChild;
var images:Array = this.firstChild.childNodes;
for (i=0; i<images.length; i++) {
thumbUrl[i] = xmlNode.childNodes[i].childNodes[0].firstChild.nodeValue;
largeImageUrl[i] = xmlNode.childNodes[i].childNodes[1].firstChild.nodeValue;
captions[i] = xmlNode.childNodes[i].childNodes[2].firstChild.nodeValue;
p = 0;//reset p for different gallery loading
//create a bg clip for the thumbsTrack. Enables padding between images to work correctly
thumbMask_mc.thumbBox_mc.createEmptyMovieClip("thumbTrackBg",1);
thumbMask_mc.thumbBox_mc.thumbTrackBg.beginFill(0x000000,20);
thumbMask_mc.thumbBox_mc.thumbTrackBg.moveTo(thumbMask_mc.thumbBox_mc._x,thumbMask_mc.thum bBox_mc._y);
thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo(thumbMask_mc.thumbBox_mc._x+thumbMask_mc.thum bBox_mc._width,thumbMask_mc.thumbBox_mc._y);
thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo(thumbMask_mc.thumbBox_mc._x+thumbMask_mc.thum bBox_mc._width,thumbMask_mc.thumbBox_mc._y+thumbMask_mc.thumbBox_mc._height);
thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo(thumbMask_mc.thumbBox_mc._x,thumbMask_mc.thum bBox_mc._y+thumbMask_mc.thumbBox_mc._height);
thumbMask_mc.thumbBox_mc.thumbTrackBg.lineTo(thumbMask_mc.thumbBox_mc._x,thumbMask_mc.thum bBox_mc._y);
thumbMask_mc.thumbBox_mc.thumbTrackBg.endFill();
//load the thumbs
loadThumbs();
Mouse.removeListener(mouseListener);//kill the mouselistener if it is added
slide.load("paintings.xml");//load xml
var imageWidth:Number = 0;//default x position of our movieclips relative to containing movieclip
var buffer:Number = 20;//padding between images
var thumbsToShow:Number = 5//
LOAD THUMBNAILS, ADD ACTIONS & PADDING TO THUMBS
//here we load in our thumbnails
function loadThumbs() {
//remove the movieclip loade listener on each iteration of this function
Clip.removeListener(mclListener);
//attach and associate with a variable a MC to hold each loaded movieClip
var container:MovieClip = thumbMask_mc.thumbBox_mc.attachMovie("thumbBox", "thumbBox"+p, thumbMask_mc.thumbBox_mc.getNextHighestDepth(), {_x:imageWidth, _y:0});
//create a movieclip loader
var Clip:MovieClipLoader = new MovieClipLoader();
var mclListener:Object = new Object();
mclListener.onLoadStart = function(target_mc:MovieClip) {
target_mc._alpha = 0;//set thumb alpha to be zero
//handle loading progress - simple counter here
mclListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
//use this if you want to indicate loading of your thumbnails etc...
//loadTxt.captions_txt.text = Math.floor(bytesLoaded/bytesTotal*100)+"%";
mclListener.onLoadInit = function(target_mc:MovieClip) {
//here we can access our loaded clips properties!
//here is where we attach functions to our clip so that we can dynamically create rollovers etc.
//make our thumbnails visible again
TweenLite.to(target_mc, 2, {_alpha:100});
//based off image width this places our thumbs next to each other
imageWidth = (imageWidth+target_mc._width)+buffer;
//associate a variable here with our p value, we use this later to load in large images
target_mc.pictureValue = p;
//handle image rollovers these are active only on the thumb image!!! Watch the US spelling!
target_mc.onRollOver = function() {
TweenFilterLite.to(target_mc,.4,{type:"Color", brightness:1.5, ease:None.easeOut});
target_mc.onRollOut = function() {
TweenFilterLite.to(target_mc,4,{type:"Color", brightness:1, ease:None.easeOut});
//handle a click on a thumbnail
target_mc.onRelease = function() {
//load large images
mcLoader.loadClip(largeImageUrl[target_mc.pictureValue],largeImage_mc);
caption.text = captions[target_mc.pictureValue];;
p++;//increment value to cycle through array
if (p<thumbUrl.length) {
loadThumbs();//create loop
if (p == thumbUrl.length) {
/*we set this variable here because this is where we know the length of our thumbnails containing mc.
After we have loaded all content in. Makes sense really!*/
mcWidth = thumbMask_mc.thumbBox_mc._width;
//adjust the width and height of the thumbstrack bg clip
thumbMask_mc.thumbBox_mc.thumbTrackBg._width = mcWidth;
thumbMask_mc.thumbBox_mc.thumbTrackBg._height = thumbMask_mc.thumbBox_mc._height
/*add the mouse listener object to the thumbnail mask. We do this element of our script here so
we do not enable scrolling of our mc before the images have all loaded in. As this can look a little funny*/
Mouse.addListener(mouseListener);
//load in the next thumb
Clip.addListener(mclListener);
Clip.loadClip(thumbUrl[p],container);
REMOVE ALL THUMBS METHOD
//Use to clear old thumbs if you are going to add in a new set of thumbs
function removeAllThumbs():Void {
for (var i in thumbMask_mc.thumbBox_mc) {
if (typeof (thumbMask_mc.thumbBox_mc[i]) == "movieclip") {
removeMovieClip(thumbMask_mc.thumbBox_mc.getInstanceAtDepth(thumbMask_mc.thumbBox_mc[i].ge tDepth()));
thumbMask_mc.thumbBox_mc._width = thumbMask_mc._width
/*sampleRemoveAllButton.onRelease = function(){
removeAllThumbs()
LOAD LARGE IMAGES MOVIECLIP LOADER FUNCTION
/*generic load object here we handle loading in external images etc
this block of code loads the large images into the bright blue mc
for instance, you could fade in/out big images or make a progress indicator
using this block of script*/
var mcLoader:MovieClipLoader = new MovieClipLoader();
var listener:Object = new Object();
listener.onLoadStart = function(target_mc:MovieClip) {
//empty
listener.onLoadProgress = function(target:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
//amountLoaded = Math.floor((bytesLoaded/bytesTotal)*100);//calulate a loading percentage!
listener.onLoadInit = function(target:MovieClip):Void {
//empty
mcLoader.addListener(listener);
MOUSE LISTENER
//this handles the panning of the thumbnails
mouseListener = new Object();
mouseListener.onMouseMove = function() {
if (thumbMask_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
maskOver();//call the scroll function
SCROLLER FUNCTION
var scrollSpeed:Number = 5;
var halfMaskWidth:Number = thumbMask_mc._width/2;
var npixels:Number;
var mcWidth:Number = thumbMask_mc.thumbBox_mc._width;
var maskWidth:Number = Math.floor(thumbMask_mc._width);
function slideThumbs() {
// stop scrolling if we are off the mask and delete the enterframe event
if (!thumbMask_mc.thumbBox_mc.hitTest(_root._xmouse, _root._ymouse, true)) {
delete this.onEnterFrame;
// mouse over left half of slider:
if (thumbMask_mc._xmouse>0 && thumbMask_mc._xmouse<thumbMask_mc._x+halfMaskWidth) {
npixels = (halfMaskWidth-thumbMask_mc._xmouse)/halfMaskWidth*scrollSpeed;
thumbMask_mc.thumbBox_mc._x += npixels;
//stop sliding too far to the left
if (thumbMask_mc.thumbBox_mc._x>=0) {
thumbMask_mc.thumbBox_mc._x = 0;
delete this.onEnterFrame;
// mouse over right half of slider:
if (thumbMask_mc._xmouse>halfMaskWidth && thumbMask_mc._xmouse<thumbMask_mc._x+thumbMask_mc._width) {
npixels = (thumbMask_mc._xmouse-halfMaskWidth)/halfMaskWidth*scrollSpeed;
thumbMask_mc.thumbBox_mc._x -= npixels;
//stop sliding too far to the right
if (thumbMask_mc.thumbBox_mc._x<=-(mcWidth-maskWidth)) {
thumbMask_mc.thumbBox_mc._x = -(mcWidth-maskWidth);
delete this.onEnterFrame;
//function to do the scrolling man!
function maskOver() {
this.onEnterFrame = function() {
slideThumbs();I am using Flash CS 4, like I mentioned earlier, I am making this site on some one's pre-made flash file. There is a movie symbol for loading the large images (called largeImage_mc). I resized this movie clip to 550x450 px (landscape). And positioned it at X=200 Y=0 (top left corner registration point or the anchor point).
The movie clip could be dragged to any position. But images that are loaded into this bo is always aligning to the top left corner of this movie symbol.
If I calculate the actual center of this image loading area (regarding its position on the window), it would be x=425, y=225.
I hope my writing makes sence.
actual site: www.chimeddorj.com -
I'm trying to help a friend with the Flash Banner Rotator
She needs to make the image clickable and pop up the scroll text box item exactly like when you rollOver the title and the scroll text box pops up.
She wants the image to trigger the text box to open and close onRelease and onRollOut from the image.
Here's the swf live:
http://bgehome.com/index3.php
Any help would be great
This AS opens the Text Box
textMc.scrolltxt.bg.onRollOver = function(){ // pop up scrolltxt
mainContent["tex" + newPos]._y = thumbHeight - textMc.scrolltxt.bg._height;
isReading = true;
textMc.scrolltxt.bg.onRollOut = textMc.scrolltxt.bg.onReleaseOutside = function(){ // pop down scrolltxt
if(!mainContent["tex" + newPos].scrolltxt.bg.hitTest(_root._xmouse, _root._ymouse, true)){
mainContent["tex" + newPos]._y = thumbHeight - textMc.imtext._height;
isReading = false;
Full AS
thumb.useHandCursor=false;
// Thumb/ Banner Rotator //
///Initialisation //
var bgmask:MovieClip = bckgrnd.duplicateMovieClip("bgmask"); // Create a mask to place on top of mainContent, which contains the images
var contentWidth:Number = bgmask._width;
bgmask._width = contentWidth;
var XMLContent = new XML(); // Create a new XML object
XMLContent.ignoreWhite = true;
XMLContent.load("Banner.xml"); // Load the XML content from Banner.xml (which is the name of the xml file) in XMLContent variable
//XMLContent.load("Thumbnail.xml");
var cssStyle = new TextField.StyleSheet(); // Create a new StyleSheet object
// Create Containers
var mainContent:MovieClip = this.createEmptyMovieClip("mainContent",this.getNextHighestDepth()); // Contains thumbs
leftBtn.swapDepths(mainContent); // Make sure leftBtn ...
rightBtn.swapDepths(leftBtn.getDepth + 1); // and rightBtn is on top of the mainContent
var pieMc:MovieClip = this.createEmptyMovieClip("pie", this.getNextHighestDepth()); // Create movieClip which contains the pieLoader
var format = new TextFormat(); // Make a new TextFormat
format.font = "arial"; // with font PF Ronda Seven, if you want to change the font, do it here
format.size = 18; // Font size, for pixel fonts use 8
var mclListener:Object = new Object(); // Make event listener object
var clipLoader = new MovieClipLoader(); // Make a MovieCLipLoader to load the images
clipLoader.addListener(mclListener); // The event listener is added to the MovieClipLoader object
var iniNum:Number = 0; // initional relative number for thumb/banner positioning
var thumbHeight:Number; // see xml document
var thumbWidth:Number; // see xml document
var thumbSpace:Number; // see xml document
var contentPos_Y:Number; // see xml document
var thumbDir:String; // see xml document
var dispThumbNumber:Number; // see xml document
var linkDestiny:String; // see xml document
var shiftTime:Number; // see xml document
var fadeInTime:Number; // see xml document
var easeSpeed:Number; // see xml document
var imagesTotal:Number; // amount of thumbs
var dwLoader:Number = 0; // pie segment angle
var arcVal:Number = 0; // total pie angle
var isReading:Boolean = false; // boolean: set true when reading. When true the pieLoader will stop
var prevXPosition:Number = 0; // previous absolute x position
var nextXPosition:Number = 0; // next absolute x position
var images; // image array
// XML, CSS Loading //
cssStyle.load("ThumbBannerRotator.css");
XMLContent.onLoad = function() { // Couple xml parameters with program variables
iniNum = 0;
nextXPosition = 0;
prevXPosition = 0;
dwLoader = 0;
arcVal = 0;
// images = array with images and titles and webUrls
images = XMLContent.firstChild.childNodes[0].childNodes;
imagesTotal = images.length;
// Other parameters
thumbHeight = XMLContent.firstChild.attributes.thumbHeight;
thumbWidth = XMLContent.firstChild.attributes.thumbWidth;
startPos = XMLContent.firstChild.attributes.startPos;
easeSpeed = XMLContent.firstChild.attributes.easeSpeed;
linkDestiny = XMLContent.firstChild.attributes.linkDestiny;
thumbDir = XMLContent.firstChild.attributes.thumbDir;
dispThumbNumber = XMLContent.firstChild.attributes.dispThumbNumber;
shiftTime = XMLContent.firstChild.attributes.shiftTime;
fadeInTime = XMLContent.firstChild.attributes.fadeInTime;
// Calculate the other program variables
contentPos_Y = (bckgrnd._height - Number(thumbHeight))/2
thumbSpace = (contentWidth - dispThumbNumber*thumbWidth)/(Number(dispThumbNumber) +1);
dwLoader = 100 * 3.6 / (Number(shiftTime) * 24);
mainContent._y = contentPos_Y; // Position form top
bgmask._height = thumbHeight;
bgmask._y = contentPos_Y;
mainContent.setMask(bgmask);
// Load the first images
for(var i = 0; i < dispThumbNumber ; i++){
loadImage(i,0,"load");
loadText(i,0,"load");
function shiftPic(direction:String){
if (isReading == false){
callPic(direction);
function callPic(direction:String) { // Call images, captions and titles and add them to containers: mainContent
if(direction == "left"){
var newPos:Number = (iniNum -1) % imagesTotal; // Calculate the relative position off the new image, this number corresponds with the index number from the image-array
var remPos:Number = (iniNum+( Number(dispThumbNumber) - 1)) % imagesTotal; // Calculate the relative position off the image that needs to be removed
var prevPos:Number = iniNum % imagesTotal; // Calculate the relative position off the images before the new image
nextXPosition = prevXPosition + Number(thumbSpace) + Number(thumbWidth); // Calculate the absolute x position = previous position + thumbSpace and thumbWidth, used in ease function
prevXPosition = nextXPosition; // Update prevPosition
iniNum = iniNum - 1; // Substract the iniNumber
if(direction == "right"){
var remPos:Number = iniNum % imagesTotal; // Calculate the relative position off the new image, this number corresponds with the index number from the image-array
var newPos:Number = (iniNum+ Number(dispThumbNumber)) % imagesTotal; // Calculate the relative position off the image that needs to be removed
var prevPos:Number = (iniNum+(Number(dispThumbNumber) - 1)) % imagesTotal; // Calculate the relative position off the images before the new image
nextXPosition = prevXPosition - Number(thumbSpace) - Number(thumbWidth); // Calculate the absolute x position = previous position + thumbSpace and thumbWidth
prevXPosition = nextXPosition; // Update prevPosition
iniNum = iniNum + 1;
if (newPos < 0){ //If newPos is negative, make it positive
newPos = imagesTotal + newPos;
if (remPos < 0){ //If remPos is negative, make it positive
remPos = imagesTotal + remPos;
if (prevPos < 0){ //If prevPos is negative, make it positive
prevPos = imagesTotal + prevPos;
loadImage(newPos, prevPos, direction); // Load images and image titles
loadText(newPos, prevPos , direction); // Load titles and caption
mainContent[remPos].removeMovieClip(); // remove the image with name "remPos"
mainContent["tex" + remPos].removeMovieClip(); // remove the text with name tex"remPos"
arcVal = 0; // reset the pieLoader
function loadImage(newPos:Number, prevPos:Number, direction:String){
thumbURL = images[newPos].attributes.thumbPath; // Get thumbUrl from images-array
thumbMc = mainContent.createEmptyMovieClip(""+newPos, mainContent.getNextHighestDepth()); // Create new thumbMc movieClip variable
thumbMc._alpha = 0; // Alpha = zero for fade in effect
if (direction == "left"){
thumbMc._x = mainContent[prevPos]._x - Number(thumbWidth) - Number(thumbSpace); // positioning of thumbMc
if (direction == "right"){
thumbMc._x = mainContent[prevPos]._x + Number(thumbWidth) + Number(thumbSpace); // positioning of thumbMc
if(direction == "load"){
thumbMc._x = Number(thumbWidth*newPos) + Number(thumbSpace*(newPos+1)) ; // positioning of thumbMc
addLoader(thumbMc);
clipLoader.loadClip(thumbDir+thumbURL, thumbMc); // Load the images in the thumbMc
function loadText(newPos:Number, prevPos:Number, direction:String){
thumbTitle = images[newPos].attributes.title; // Get title from images-array
thumbDesc = images[newPos].attributes.description; // Get caption description from images-array
textMc = mainContent.createEmptyMovieClip("tex"+newPos, mainContent.getNextHighestDepth()); // Create new titleMc moveClip variable
if (direction == "left"){
textMc._x = mainContent[prevPos]._x - Number(thumbWidth) - Number(thumbSpace); // positioning of textMc
if (direction == "right"){
textMc._x = mainContent[prevPos]._x + Number(thumbWidth) + Number(thumbSpace); // positioning of textMc
if(direction == "load"){
textMc._x = Number(thumbWidth*newPos) + Number(thumbSpace*(newPos+1)) ; // positioning of textMc
textMc.attachMovie("scrollText" , "scrolltxt", textMc.getNextHighestDepth());
textMc.scrolltxt.bg._width = Number(thumbWidth); // set background width
textMc.scrolltxt.main.content.styleSheet = cssStyle; // set css style
textMc.scrolltxt.main.content._width = Number(thumbWidth) - 30; // set scrolltext components width
textMc.scrolltxt.maskMc._width = Number(thumbWidth) - 10; // set scrolltext components width
textMc.scrolltxt.dragger._x = textMc.scrolltxt.bar._x = textMc.scrolltxt.upBtn._x = textMc.scrolltxt.downBtn._x = textMc.scrolltxt.stripe._x = Number(thumbWidth) - 10; // positioning of scrolltext components
textMc.scrolltxt.main.content.text = thumbDesc; // set text
textMc.scrolltxt.main.content.embedFonts = true;
textMc.scrolltxt.main.content.selectable = false;
textMc.scrolltxt.main.content.setTextFormat(format); // set text format
textMc.scrolltxt.main.content._height = textMc.scrolltxt.main.content.textHeight + 5; // calculate height of text
textMc.createTextField("imtext",1,0,0,thumbWidth,48); // Create a textfield in the titleMc for the image title
textMc.imtext.embedFonts = true;
textMc.imtext.text = thumbTitle; // Add text
textMc.imtext.selectable = false;
textMc.imtext.textColor = 0xaddf99; // Set textColor to pink
textMc.imtext.setTextFormat(format); // set text format
textMc.imtext._x = Math.round((thumbWidth - textMc.imtext.textWidth)/2);
textMc._y = thumbHeight - textMc.imtext._height;
textMc.attachMovie("arrow", "arrowMc", textMc.getNextHighestDepth()); // add arrow
textMc.arrowMc._x = Number(thumbWidth) - textMc.arrowMc._width;
textMc.arrowMc._y = Number(textMc.arrowMc._height);
textMc.arrowMc._alpha = 0;
textMc.scrolltxt.bg.onRollOver = function(){ // pop up scrolltxt
mainContent["tex" + newPos]._y = thumbHeight - textMc.scrolltxt.bg._height;
isReading = true;
textMc.scrolltxt.bg.onRollOut = textMc.scrolltxt.bg.onReleaseOutside = function(){ // pop down scrolltxt
if(!mainContent["tex" + newPos].scrolltxt.bg.hitTest(_root._xmouse, _root._ymouse, true)){
mainContent["tex" + newPos]._y = thumbHeight - textMc.imtext._height;
isReading = false;
function addLoader(thumb:MovieClip){ // Add a preloader to every thumbnail
mainContent.attachMovie("smallLoader", "preloader" + thumb._name, mainContent.getNextHighestDepth()); // add preloader
mainContent["preloader"+thumb._name]._x = thumb._x + (thumbWidth - mainContent["preloader"+thumb._name]._width) /2; // positioning
mainContent["preloader"+thumb._name]._y = (thumbHeight - mainContent["preloader"+thumb._name]._height) /2; // positioning
mclListener.onLoadInit = function(thumb:MovieClip) {
mainContent["preloader"+thumb._name].removeMovieClip();
mainContent[""+thumb._name].onEnterFrame = function(){ // Fade in Effect
mainContent[""+thumb._name]._alpha += Number(fadeInTime); // Every frame the alpha of the thumbnail is added by fadeInTime.
if(mainContent[""+thumb._name]._alpha >= 100){
delete mainContent[""+thumb._name].onEnterFrame; // When fade in effect is done, remove the onEnterFrame funtion
mclListener.onLoadComplete = function(thumb){ // When a thumb is fully loaded, add button action
thumb.onRelease = function(){ // When button released, execute function below
var i = Number(thumb._name)%imagesTotal;
// Go to a website defined in the xml document
thumb.onRollOver = function(){ // make alpha of arrow 100 on roll over
var i = Number(thumb._name)%imagesTotal;
mainContent["tex" + i].arrowMc._alpha = 100;
thumb.onRollOut = function(){ // make alpha of arrow 0 on roll over
var i = Number(thumb._name)%imagesTotal;
mainContent["tex" + i].arrowMc._alpha = 0;
// Button and Position Handling ///
// Left button
leftBtn.onPress = function() {
if (isReading == false){ // onPress call the next picture on the right
callPic("left");
leftBtn.onRollOver = function(){ // onRollOver move the arrow by 5 pixels
if(isReading == false){
leftBtn.arrow._x -= 5;
leftBtn.onRollOut = leftBtn.onReleaseOutside = function(){
if(isReading == false){
leftBtn.arrow._x += 5 ; // onRollOut reset the arrow
// Right button
rightBtn.onPress = function() {
if(isReading == false){
callPic("right"); // onPress call the next picture on the right
rightBtn.onRollOver = function(){
if(isReading == false){
rightBtn.arrow._x += 5 ; // onRollOver move the arrow by 5 pixels
rightBtn.onRollOut = rightBtn.onReleaseOutside = function(){
if(isReading == false){
rightBtn.arrow._x -= 5; // onRollOut reset the arrow
pieMc.onRelease = function(){
if (dwLoader != 0){ // Stops the pieLoader
dwLoader = 0;
else{
dwLoader = 100 * 3.6 / (Number(shiftTime) * 24); // Start the pieLoader
// Easing function //
//Used to give that cool ease effect on the mainContent, titleContainer and reflectContainer and dragger
// Want to change the ease effect? check help document
this.onEnterFrame = function() { // Start endless loop, executed every time frame is updated // If dragEase is false don't allow easing for the dragger
if (dwLoader != 0 && isReading == false){
arcVal += Number(dwLoader); // new value of arcVal is the old value plus dwLoader
pieMc.clear();
pieMc.beginFill(0xaddf99, 100); // draw the pie shape with pink color, you can change the color in this line
pieMc.drawPie(bckgrnd._width - 20, 20, 90, -arcVal, 7); // position the pieLoader, 90 = startAngle, 7 = radius
pieMc.endFill();
if (arcVal > 360){
shiftPic("right"); // If the pie-angle = 360 call the next picture/thumbnail
arcVal = 0;
dx = (nextXPosition - mainContent._x) * easeSpeed; // Calculates how much the mainContent needs to move, note that dx is becomming smaller and smaller when the mainContent reaches its final position.
mainContent._x += dx; // Move the mainContent
MovieClip.prototype.drawPie = function(x, y, startAngle, arc, radius) { // x, y = center point of the wedge.startAngle = starting angle in degrees.arc = sweep of the wedge. Negative values draw clockwise.
this.moveTo(x, y); // move to x,y position
var segAngle, theta, angle, angleMid, segs, startx, starty, anchx, anchy, contrx, contry; // Init vars
segs = Math.ceil(Math.abs(arc)/20); // Devide the arc in 20 segments
segAngle = arc/segs; // Calculate the sweep of each segment.
theta = -(segAngle/180)*Math.PI; // Convert to radions
angle = -(startAngle/180)*Math.PI; // Convert startAngle to radians
startx = x + Math.cos(startAngle/180*Math.PI) * radius; // Calculate curve start x position
starty = y + Math.sin(-startAngle/180*Math.PI) * radius; // Calculate curve start y position
this.lineTo(startx, starty); // Draw a line from the center to the start of the curve
for (var i = 0; i<segs; i++) { // Loop for drawing curve segments
angle += theta; // Icrement angle with segAngle => theta (in radians)
anchx = x+Math.cos(angle)*radius; // Calculate parameters for curveTo function
anchy = y+Math.sin(angle)*radius; // Calculate parameters for curveTo function
contrx = x+Math.cos(angle-(theta/2))*(radius/Math.cos(theta/2)); // Calculate parameters for curveTo function
contry = y+Math.sin(angle-(theta/2))*(radius/Math.cos(theta/2)); // Calculate parameters for curveTo function
this.curveTo(contrx, contry, anchx, anchy); // Draw the curve
this.lineTo(x, y); // close the curve by drawing a line to the centerAs is always the case in this sort of situation, you ask the printer, or banner maker. If you have a particular company in mond, they may have a website with guidelines, and that is going to be much better information than the guesses - good though 'some' of them might be.
25' by 16' is huge. Have you found somewhere that will make it? This company will supply 25 foot long banners, at a surprisingly cheap $176, but only 3 foot high. The problem being the width of the printer.
http://www.allstatebanners.com/3x25-vinyl-banner -
I have some mouse commands to scroll a screen horizontally... need some help adding in a zoom feature where moving the mouse up will zoom in, moving out will zoom out. Here is the code I have so far:
import mx.transitions.easing.*;
import mx.transitions.Tween;
import flash.filters.DropShadowFilter;
import mx.events.EventDispatcher;
//constants
var CENTER_STAGE:Number = Stage.width/2;
var SCROLL_HIT_AREA_POSITION:Number = Stage.width/2;//distance from edges of screen that should trigger scrolling
var RIGHT_SCROLL_HIT_AREA:Number = SCROLL_HIT_AREA_POSITION;
var LEFT_SCROLL_HIT_AREA:Number = Stage.width - SCROLL_HIT_AREA_POSITION;
var RIGHT_SCROLL_EDGE:Number = 100;//x pos at which front scene should stop scrolling left
var LEFT_SCROLL_EDGE:Number = -200;//x pos at which front scene should stop scrolling right
var scrollableArea:Number = RIGHT_SCROLL_EDGE - LEFT_SCROLL_EDGE;//hill1._width - Stage.width;
//var SCROLL_CENTER_POINT:Number = scrollableArea/2;
var SCROLL_DECELERATE_POSITION:Number = 75;//how far from the edges of the scene does the scrolling slow down
var DEFAULT_FRICTION:Number = 1;
var SPEED:Number = 50;
//variables
var friction:Number;
var distFromEdge:Number;
//var swfContainer:MovieClip;
//var localRoot:MovieClip = this;
//var localParent:MovieClip = this._parent;
// determine the correct path to the photos
var dispatchEvent:Function;
EventDispatcher.initialize(this);
setBitmapCaching(true);
this.onEnterFrame = testForScroll;
// determine whether to scroll or not and by how much, based on mouse position and position of the scene
function testForScroll():Void{
var xMouse:Number = this._xmouse;// where is the mouse on the x axis?
var yMouse:Number = this._ymouse;// where is the mouse on the x axis?
var mouseOnStage:Boolean = xMouse > 0 && yMouse > 0; //before someone scrolls into the swf stage area, the mousex and mouse y values are 0, 0 so we need to make sure they are positive values or the scene will begin scrolling to the right immediately
var mouseInScrollArea:Boolean = xMouse > LEFT_SCROLL_HIT_AREA || xMouse < RIGHT_SCROLL_HIT_AREA;//is the mouse close enough to edge of screen to trigger scrolling
if(mouseOnStage && mouseInScrollArea){//only execute if mouse is over the scroll trigger area
var xScrollPos:Number = pintMC.cowMC._x;//x position of the main movieClip
var xDirection:Number = (xMouse - CENTER_STAGE)/Math.abs(xMouse - CENTER_STAGE);//what direction is the scene moving
var nearLeftEdge:Boolean = xScrollPos > (scrollableArea - 100);
var nearRightEdge:Boolean = xScrollPos < (RIGHT_SCROLL_EDGE + 100);
if(nearLeftEdge && xDirection == -1){
distFromEdge = scrollableArea - xScrollPos;
friction = (scrollableArea - xScrollPos)/SCROLL_DECELERATE_POSITION;
}else if(nearRightEdge && xDirection == 1){
distFromEdge = xScrollPos - RIGHT_SCROLL_EDGE;
friction = distFromEdge/SCROLL_DECELERATE_POSITION;
}else{
friction = DEFAULT_FRICTION;
//determine how far to move the scene
var acc:Number = (xMouse - CENTER_STAGE) * (1/SPEED) * friction;
//will next movement make scene scroll past one of it's edges
var reachedEdge:Boolean = (xScrollPos - acc) < RIGHT_SCROLL_EDGE || (xScrollPos - acc) > LeftScrollEdge;
if(!reachedEdge){// only scroll if not going to pass edge
scrollScene(acc);
// move the various scenes at relative speeds
function scrollScene(acc:Number){
pintMC.cowMC._x -= acc;
pintMC.flutterbyMC._x -= acc;
pintMC.grassMC._x -= acc;
pintMC.cloudMC._x -= (acc/2);
pintMC.barnMC._x -= (acc/3);
pintMC.bgMC._x -= (acc/5);
// in order to optimize performance, we create a bitmap of each moving scene. This eliminates the enormous number of vector redraws Flash must perform if vectors are intersecting.
function setBitmapCaching(cache:Boolean):Void{
pintMC.cowMC.cacheAsBitmap = cache;
pintMC.flutterbyMC.cacheAsBitmap = cache;
pintMC.grassMC.cacheAsBitmap = cache;
pintMC.cloudMC.cacheAsBitmap = cache;
pintMC.barnMC.cacheAsBitmap = cache;
pintMC.bgMC.cacheAsBitmap = cache;
Thanks for any helpYou mac doesn't support those preferences. It only supports tap, double-tap, drag and scrolling.
-
Interactive Image Panning Help Please!!!!!
Hey guys,
I'm trying to achieve an effect similar to this one:
http://www.prada.com/pradabook/
When you click on a thumbnail and the larger image opens, when you move the mouse all the way to the right or left, the image just moves a fraction of the distance...
I simply can't figure this out...I only manage to have the image follow the mouse til the absolute edges....
I am playing arround with 2 scrolling codes:
// Create a point when the image is first clicked
var mouseLocFirstTime:Point = new Point(mc2._xmouse, mc2._ymouse);
mc2.onEnterFrame = function()
mc2.onMouseMove = function()
// Keep creating points according the mouse position on the image
var destination:Point = new Point(mc2._xmouse, mc2._ymouse);
// Find the difference between the two points
finalDX = destination.x - mouseLocFirstTime.x;
finalDY = destination.y - mouseLocFirstTime.y;
// Tween to the difference and add the mc2 x and y since the image inside mc2 is aligned top left
TweenMax.to(mc2,2,{_x:finalDX + mc2._x, _y:finalDY + mc2._y});
By the way, mc2 is the large zoomed image, which is much much larger than the stage...its about 8000 px!!!
The above code works fine, but i'm trying to reverse the direction, which is proving to be a pain!!! Can you guys please help?!?!?
The other code I'm trying to implement is this one:
var xRatioS = 0;
var yRatioS = 0;
var xTweenAmountS = 0;
var yTweenAmountS = 0;
mc2.onEnterFrame = function()
xRatioS = ((Stage.width - mc2._width) / Stage.width);
xTweenAmountS = _xmouse * xRatioS;
yRatioS = ((Stage.height - mc2._height) / Stage.height);
yTweenAmountS = _ymouse * yRatioS;
TweenLite.to(mc2,2,{_x:xTweenAmountS, _y:yTweenAmountS});
Now this one goes in the right direction as I need, but it goes all the way to the edges of my image...and I can't seem to figure out how to reduce the distance to about half or a quarter?!?!?!?
Thank you guys...I know this a long post....but i'm hoping that someone out there can help me out with any one of the above!!!
CHEERSdepending on the way you lay it out you could have it become part of the rollover on each button. But you'd have to have enough space on screen to accommodate the text you want displayed. Note that the video playing as part of menu background can only be so long and adds to the media on the disk.
-
I never learnt as2 and I just purchased a fla file from a stock sight thinking it was in as3 and it isn't!!! doh
can anyone help me convert this from as2 to as3:
stop();
import flash.filters.*;
//--------------variables to change--------------------------//
//set this value to true if you want sparkles to be created from the mouse
//and false if you want automatic sparkles
var createSparklesFromAnyMouse:Boolean = true;
//set to true if you want sparkles to stop being created when the mouse
//is still
var createSparklesFromClick:Boolean = false;
//modify the size of the sparkles
var maxSparkSize:Number = 18;
var minSparkSize:Number = 8;
//increase this value to shorten the life, 0 to live forever
var fadeSpeed:Number = 10;
//the speed the sparkles fall, higher number quicker the speed
var speed:Number = 1;
//choose whether you want the sparkle colour to be random
var randomColour:Boolean = true;
//if you don't want a random colour pick a default colour
defaultColour = 0xFFffFF;
//do not modify code below here...
var sparkle:Number = 0;
var mousePosX:Number;
var mousePosY:Number;
var whichBat:Number;
var count:Number = 0;
this.createEmptyMovieClip("empty",this.getNextHighestDepth());
howToCreate();
function howToCreate() {
if (createSparklesFromClick == true) {
trace("create sparkles every time I click the mouse");
//create sparkles from mouse clicks
activateClick();
} else {
if (createSparklesFromAnyMouse == true) {
trace("create sparkles from the mouse");
//create sparkles from the mouse
this.onEnterFrame = function() {
createSparkle();
createSparkle();
} else {
trace("create sparkles every time I move the mouse");
//create sparkles ONLY when the mouseMoves
createWhenMoving();
function createWhenMoving() {
this.onEnterFrame = function() {
if (mousePosX != _root._xmouse && mousePosY != _root._ymouse) {
createSparkle();
mousePosX = _root._xmouse;
mousePosY = _root._ymouse;
function activateClick() {
empty.onMouseDown = function() {
this.onEnterFrame = function() {
createSparkle();
empty.onMouseUp = function() {
delete this.onEnterFrame;
function createSparkle() {
movingSparkle = this.attachMovie("colouredSparkle", "s_"+sparkle, sparkle);
movingSparkle2 = this.attachMovie("colouredSparkle", "ss_"+sparkle, sparkle+100);
sparkle++;
if(sparkle>100){
sparkle = 0;
setParams(movingSparkle);
setParams(movingSparkle2);
function setParams (movingSparkle){
movingSparkle._x = _root._xmouse+randRange(-8, 8);
movingSparkle._y = _root._ymouse+randRange(-15, 0);
movingSparkle._xscale = movingSparkle._yscale=Math.random()*maxSparkSize+minSparkSize;
movingSparkle._rotation = randRange(0, 360);
if (randomColour == true) {
col = Math.round(Math.random()*0xFFFFFF);
} else {
col = defaultColour;
colouredFill = new Color(movingSparkle.colour_mc);
colouredFill.setRGB(col);
colouredFill = new Color(movingSparkle.white_mc);
colouredFill.setRGB(col);
moveSparkle(movingSparkle);
function moveSparkle(movingSparkle) {
var ySpeed = randRange(0, speed);
var rot = randRange(-15, 15);
var blurX = randRange(2, 5);
var blurY = blurX;
var blurFilter = new BlurFilter(blurX, blurY, 3);
movingSparkle.white_mc.filters = [blurFilter];
movingSparkle._alpha = randRange(85, 100);
var alphaDrop = randRange(1, fadeSpeed);
movingSparkle.onEnterFrame = function() {
//change speed
this._y += ySpeed;
//change rotation
this._rotation = this._rotation+rot;
//make it smaller
this._xscale = this._yscale=this._xscale*0.98;
//fade the sparkle
this._alpha = this._alpha-alphaDrop;
//remove the movieclip if it get tiny
if (this._alpha<10) {
this.removeMovieClip();
delete this.onEnterFrame();
if (this._height<4) {
this.removeMovieClip();
delete this.onEnterFrame();
function setColour(mc, col) {
colourIt = new Color(mc);
colourIt.setRGB(col);
function randRange(min:Number, max:Number):Number {
var randomNum:Number = (Math.random()*(max-min))+min;
return randomNum;Zhanbolat,
In theory, conversion of this code is not difficult, especially because it is clear what the logic is designed to do. The issue is that you will not have an expected result once only this code is converted in isolation. This puppy uses some other objects that are written in AS2 including entities in the FLA library.
In short, it looks like this application needs a total overhaul at every level in order for it to properly function as an AS3 program.
With that said, although this is, again, not a difficult task, it is unlikely to find someone to do it for free. You may have a better luck if you start conversion yourself and post focused questions as you go. -
I got this code and i whant to make it so unit moves smoothly to the destination i got told to seach key words like LiteTween and built in tween but i cant find anything that helps will someone help me.
unit.onRelease = function(){
_root.onMouseUp = function(){
unit._x = _xmouse;
unit._y = _ymouse;
delete _root.onMouseUp;my error. use:
import mx.transitions.Tween;
import mx.transitions.easing.*;
unit.onRelease = function(){
_root.onMouseUp = function(){
var t1:Tween = new Tween(unit, "_x", Elastic.easeOut, unit._x, _xmouse, 3, true);
var t2:Tween = new Tween(unit, "_y", Elastic.easeOut, unit._y, _ymouse, 3, true);
delete _root.onMouseUp; -
import mx.transitions.Tween;
import mx.transitions.easing.*;
/* Mouse Click Event
Clicking on the specified symbol instance executes a function in which you can add your own custom code.
Instructions:
1. Add your custom code on a new line after the line that says "// Start your custom code" below.
The code will execute when the symbol instance is clicked.
gage.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler);
function fl_MouseClickHandler(event:MouseEvent):void
// Start your custom code
// This example code displays the words "Mouse clicked" in the Output panel.
trace("Mouse clicked");
// End your custom code
function rotation(350, 182) {
return Math.atan2(dy, dx) * 180/Math.PI;
gage.onRelease = function() {
var newAngle:Number = rotation(_xmouse-this._x, _ymouse-this._y);
var dist:Number = Math.abs(newAngle - this._rotation);
this._rotation %= 360;
if(dist > 180) {
if(newAngle > this._rotation) {
newAngle -= 180;
} else {
newAngle += 180;
new Tween(this, "_rotation", Strong.easeOut, this._rotation, newAngle, 1, true);You appear to have just collected a variety of code snippets and thrown them together, including a section of AS2 code ( gage.onRelease = function() {... )
The suggestion I offered yesterday still stands. You should find a tutorial regarding AS3 and the atan2 function. Beyond that, what you show suggests this is a school assignment. You should seek help from your fellow students and instructor if that is the case. -
Please help...Need to rotate image/MC by moving mouse
Hi all,
I'm sure a lot of you have seen the tutorials for buttonless
scrolling (where you move your cursor to the right of the screen
and the movieclip scrolls to the left etc). Here is an excellent
example...
http://www.gotoandlearn.com/
(and then scroll down until you get to the title, 'Scrolling
Thumbnail Panel'.
Now, I want to use this principle to rotate a MC of the world
instead of scrolling the MC left and right. So, as your cursor
moves to the right of the screen, the globe rotates in an
anti-clockwise direction and visa versa.
Could anyone help moderate the code below (or provide new
code) to make this work? I've tried a few things but none of them
work. Thanks!! (Really need this for campaign at work!! Panicking a
bit).
FG.
the code...
panel.onRollOver = panelOver;
function panelOver() {
this.onEnterFrame = scrollPanel;
delete this.onRollOver;
var b = stroke.getBounds(_root);
function scrollPanel() {
if(_xmouse<b.xMin || _xmouse>b.xMax ||
_ymouse<b.yMin || _ymouse>b.yMax) {
this.onRollOver = panelOver;
delete this.onEnterFrame;
if(panel._x >= 89) {
panel._x = 89;
if(panel._x <= -751) {
panel._x = -751;
var xdist = _xmouse - 250;
panel._x += Math.round(-xdist / 7);
}OK, I've got a script that is a lot easier and DOES rotate
the m/c! It's:
var mouseList:Object = {};
Mouse.addListener(mouseList);
mouseList.onMouseMove = function(){
worldMC._rotation = _xmouse;
But it stops when my cursor does. In the scrolling example,
the further right your cursor goes, the more the horizontal MC
scrolls. Only when the cursor is in the centre of the screen does
the globe stop rotating.
So what I really need here is a globe that starts to rotate
anti-clockwise when the cursor is moved to the right...the further
right it goes, the faster it rotates. When the cursor moves to a
central location, the speed of the globe's rotation slows to a stop
(allowing the user to click onto a point on the globe).
If you've given the example I linked to above a go, this
should be a little clearer. It's hard to put into writing, but I
hope you get the idea. Looking forward to hearing from you.
FG. -
Hi to all,
This is vertical xml gallery code, where the mouse will move
up, then the scoller will move up and vice versa. now i want the
reverse . if it move up , then the scoller come down and if it move
down , then the scoller move up.
Can anyone please help me.
Thanks
Krishna
quote:
this.onEnterFrame = function()
mask_y = _root.main.verti.mask._y;
mask_h = _root.main.verti.mask._height;
mask_middle = (mask_y + mask_h) / 2; // take middle of mask
as reference
roller_y = _root.main.verti.roller._y;
roller_h = _root.main.verti.roller._height;
ymouse = _root.main.verti.mask._ymouse;
// if mous out of range
if (ymouse < mask_y || ymouse> mask_y + mask_h)
speed = 0;
else
speed = (ymouse - mask_middle)/ 10;
// calculate speed -> the closer to middle-> slower,
closer to edges-> faster
// if roller bottom reaches mask bottom and scroll up, stop
if ((roller_y+roller_h)<(mask_y+mask_h) && speed
< 0)
speed = 0;
// if roller top reaches mask top and scroll down, stop
if (roller_y > mask_y && speed > 0)
speed = 0;
_root.main.verti.roller._y += speed;
stop();try:
Maybe you are looking for
-
Importing new business systems into Integration Directory PI 7.1
Team SDN, Team We have presently upgraded to PI 7.1(inline upgrade XI 3.0 was the older version). There are some changes like Import of software component version from SLD to ESR. intially we use to do in Xi 3.0 by selcting tools and import, but now
-
Upon downloading the 4.0 version of your firefox, I have no longer been able to access downloads as they do not appear in the downloads folder (ie- pdf's etc).
-
Can I use a field name in text module
Hi, I get a object name of the standard text in a field. Can I use that field in Text module. Thanks, Srinivas.
-
Determination dumps with assertion_failed error
Hi gurus, I am enhancing a TM feature and my determination dumps with assertion_failed error. I check ST22 and the dump lies in method /BOBF/IF_FRW_CONFIGURATION~GET_CONTENT_KEY_MAPPING. Below is my determination to set the read-only flag. CREATE OBJ
-
Which table cotain cheque numbers
I am using pay_pre_payments_v2 to get the cheque number. But when I query this table against Assignment_action_id. It gives me multiple records against each cheque number with different effective dates.