CreateTextField help...
ok. im trying to get the data that is entered into the
created text fields and turn them into an Array.
for some reason it reads the text field varibles as the
variable name not the value of the text field.
anyone got any idea how to work this out?
the code:
word = "test_test";
amount = word.length;
letters = new Array();
for (x=0; x<amount; x++) {
xpos = 100;
xpos = xpos + x * 25;
createTextField("Box_"+ [x], x, xpos, 150, 20,20);
_root["Box_" + x].type = "input"
_root["Box_" + x].background=true;
_root["Box_" + x].border=true;
_root["Box_" + x].backgroundColor=0xFFFFFF;//white
_root["Box_" + x].borderColor=0x000000;//black
_root["Box_" + x].multiline=false;
_root["Box_" + x].wordWrap=false;
_root["Box_" + x].variable = "myText"+x
_root["Box_" + x].maxChars = 1;
_root["Box_" + x].tabEnabled = false;
btn.onPress = function(){
got = new Array(amount)
for(i=0; i<amount; i++){
got = "myText[" + i + "]";
trace(got);
}
well, that's what you tell it to do.
Why should it get the content when you set got =
"myText["+i+"]";?
You probably mean got = _root["myText"+x];
But what are all these variables for in the first place?
Couldn't you work with _root["Box_" + x].text?
Also, you never set _root["Box_" + x].text to the letters.
And you have typos. I hope only in the copy:
- you're missing a ";" after the variable = "myText"+x
- you're missing a } after the loop
- and it should be "Box_"+x, not "Box_"+[x] inside
createTextField("Box_"+ [x], x, xpos, 150, 20,20);
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; -
I am using a class called DrawingUtilities.as and the file is
placed at the same root level as my .fla file, but I get an error
when testing the movie. The error is:
**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 20: The
class or interface 'actionscriptbible.drawing.DrawingUtilities'
could not be loaded.
var duDrawer
rawingUtilities = new DrawingUtilities(mButton);
Total ActionScript Errors: 1 Reported Errors: 1
why can't it find the damn class!?
here is the entire AS code I am using if that helps...
import actionscriptbible.drawing.DrawingUtilities;
var mLoginButton:MovieClip;
var mSaveButton:MovieClip;
makeLoginScreen();
//the drawButton() function makes a new MovieClip object with
a nested
//label TextField object.
function drawButton(mParent:MovieClip, sLabel:String,
nWidth:Number, nHeight:Number):MovieClip {
//Make a movieclip object nested in the parent object. Use a
unique
// instance name and depth.
var nDepth:Number = mParent.getNextHighestDepth();
var mButton:MovieClip =
mParent.createEmptyMovieClip("mButton" + nDepth, nDepth);
//Draw a rectangle in the MovieClip object
var duDrawer
rawingUtilities = new DrawingUtilities(mButton);
duDrawer.beginFill(0xFFFFCC, 100);
duDrawer.drawRectangle(nWidth, nHeight, nWidth/2, nHeight/2);
duDrawer.endFill();
// Add a TextField object to the MovieClip. Apply the label.
var tLabel:TextField = mButton.createTextField("tLabel",
mButton.getNextHighestDepth(),0,0, nWidth, nHeight);
tLabel.Selectable = false;
tLabel.text = sLabel;
return mButton;
function makeLoginScreen():Void {
//Create the TextField and MovieClip Objects.
this.createTextField("tUsername", this.getNextHighestDepth(),
100, 100, 200, 20);
this.createTextField("tPassword", this.getNextHighestDepth(),
100, 140, 200, 20);
this.createTextField("tMessage", this.getNextHighestDepth(),
100, 60, 200, 20);
mLoginButton = drawButton(this, "Login", 100, 25);
//Set the properties of the TextField Objects.
tUsername.border = true;
tPassword.border = true;
tUserName.type = "input";
tPassword.type = "input";
tPassword.password = true;
tMessage.textColor = 0xFF0000;
//Place the button
mLoginButton._x = 100;
mLoginButton._y = 180;
mLoginButton.onRelease = function():Void {
//Check to see if the user has entered the correct username
//and password. If so, call the login() function.
//otherwise, display
//a message to the user and clear the values from the login
//TextField objects.
if(tUserName.text =="admin" && tPassword.text
=="admin") {
login();
else {
tMessage.text = "Try again.";
tUsername.text = "";
tPassword.text = "";
function login(): Void {
//Remove the TextField and MovieClip objects that made up
the
//login screen.
tUsername.removeTextField();
tPassword.removeTextField();
mLoginButton.removeMovieClip();
//Create the TextField and MovieClip for the notes screen.
this.createTextField("tNotes", this.getNextHighestDepth(),
100, 100, 350, 200);
mSaveButton = drawButton(this, "Save", 100, 25);
//Set the properties of the TextField Object.
tNotes.border = true;
tNotes.type = "input";
//Place the button
mSaveButton._x = 100;
mSaveButton._y = 320;
//Open a local shared object.
var lsoNotes:SharedObject = SharedObject.getLocal("notes");
// Assign the stored text, if any.
tNotes.text = (lsoNotes.data.notes == undefined) ? "" :
lsoNotes.data.notes;
//When the user clicks and releases the button store the
current
//current notes. in the shared object
mSaveButton.onRelease = function():Void {
lsoNotes.data.notes = tNotes.text;
lsoNotes.flush();thanks,
I can get my form to dispay now, but the first input isn't
alowing any text input
here is tha code
import DrawingUtilities;
var mLoginButton:MovieClip;
var mSaveButton:MovieClip;
makeLoginScreen();
//the drawButton() function makes a new MovieClip object with
a nested
//label TextField object.
function drawButton(mParent:MovieClip, sLabel:String,
nWidth:Number, nHeight:Number):MovieClip {
//Make a movieclip object nested in the parent object. Use a
unique
// instance name and depth.
var nDepth:Number = mParent.getNextHighestDepth();
var mButton:MovieClip =
mParent.createEmptyMovieClip("mButton" + nDepth, nDepth);
//Draw a rectangle in the MovieClip object
var duDrawer
rawingUtilities = new DrawingUtilities(mButton);
duDrawer.beginFill(0xFFFFCC, 100);
duDrawer.drawRectangle(nWidth, nHeight, nWidth/2, nHeight/2);
duDrawer.endFill();
// Add a TextField object to the MovieClip. Apply the label.
var tLabel:TextField = mButton.createTextField("tLabel",
mButton.getNextHighestDepth(),0,0, nWidth, nHeight);
tLabel.Selectable = false;
tLabel.text = sLabel;
return mButton;
function makeLoginScreen():Void {
//Create the TextField and MovieClip Objects.
this.createTextField("tUsername", this.getNextHighestDepth(),
100, 100, 200, 20);
this.createTextField("tPassword", this.getNextHighestDepth(),
100, 140, 200, 20);
this.createTextField("tMessage", this.getNextHighestDepth(),
100, 60, 200, 20);
mLoginButton = drawButton(this, "Login", 100, 25);
//Set the properties of the TextField Objects.
tUsername.border = true;
tPassword.border = true;
tUserName.type = "input";
tPassword.type = "input";
tPassword.password = true;
tMessage.textColor = 0xFF0000;
//Place the button
mLoginButton._x = 100;
mLoginButton._y = 180;
mLoginButton.onRelease = function():Void {
//Check to see if the user has entered the correct username
//and password. If so, call the login() function.
//otherwise, display
//a message to the user and clear the values from the login
//TextField objects.
if(tUserName.text =="admin" && tPassword.text
=="admin") {
login();
else {
tMessage.text = "Try again.";
tUsername.text = "";
tPassword.text = "";
function login(): Void {
//Remove the TextField and MovieClip objects that made up
the
//login screen.
tUsername.removeTextField();
tPassword.removeTextField();
mLoginButton.removeMovieClip();
//Create the TextField and MovieClip for the notes screen.
this.createTextField("tNotes", this.getNextHighestDepth(),
100, 100, 350, 200);
mSaveButton = drawButton(this, "Save", 100, 25);
//Set the properties of the TextField Object.
tNotes.border = true;
tNotes.type = "input";
//Place the button
mSaveButton._x = 100;
mSaveButton._y = 320;
//Open a local shared object.
var lsoNotes:SharedObject = SharedObject.getLocal("notes");
// Assign the stored text, if any.
tNotes.text = (lsoNotes.data.notes == undefined) ? "" :
lsoNotes.data.notes;
//When the user clicks and releases the button store the
current
//current notes. in the shared object
mSaveButton.onRelease = function():Void {
lsoNotes.data.notes = tNotes.text;
lsoNotes.flush(); -
Loading external SWF into a FLA (help!!!)
Hello,
I'm building a website in AS2. I have created a xml driven flash image gallery and am trying to get this into my website. I'm totally new to flash.
In the website I'm building, I have a gallery button on the main page with this code:
over3_btn.onRelease = function(){
play();
target="gallery";
Which I understand that when you click it, it brings you to the gallery keyframe and play it's contents. Then I found this code:
var imageRequest:URLRequest = new URLRequest("my_gallery.swf");
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
addChild(imageLoader);
Which I pasted into the gallery keyframe, hoping that it will call up the gallery, however, this didn't work.
Please help. I've search far and wide and couldn't find anything that would work.
Here is my the code to my gallery. Maybe I'm coding it incorrectly?
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery.xml");
myGalleryXML.onLoad = function() {
_root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x;
_root.gallery_y = myGalleryXML.firstChild.attributes.gallery_y;
_root.gallery_width = myGalleryXML.firstChild.attributes.gallery_width;
_root.gallery_height = myGalleryXML.firstChild.attributes.gallery_height;
_root.myImages = myGalleryXML.firstChild.childNodes;
_root.myImagesTotal = myImages.length;
_root.thumb_height = myGalleryXML.firstChild.attributes.thumb_height;
_root.thumb_width = myGalleryXML.firstChild.attributes.thumb_width;
_root.full_x = myGalleryXML.firstChild.attributes.full_x;
_root.full_y = myGalleryXML.firstChild.attributes.full_y;
callThumbs();
createMask();
scrolling();
function callThumbs() {
_root.createEmptyMovieClip("container_mc",_root.getNextHighestDepth());
container_mc._x = _root.gallery_x;
container_mc._y = _root.gallery_y;
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i=0; i<_root.myImagesTotal; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth() );
myThumb_mc._x = _root.thumb_width*i;
clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,100,20);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
preloader.onLoadComplete=function(target){
target.my_txt.removeTextField();
target.onRelease=function(){
callFullImage(this._name);
function callFullImage(myNumber) {
myURL = myImages[myNumber].attributes.full_url;
myTitle = myImages[myNumber].attributes.title;
_root.createEmptyMovieClip("fullImage_mc",_root.getNextHighestDepth());
fullImage_mc._x = _root.full_x;
fullImage_mc._y = _root.full_y;
var fullClipLoader = new MovieClipLoader();
var fullPreloader = new Object();
fullClipLoader.addListener(fullPreloader);
fullPreloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,200,20);
target.my_txt.selectable = false;
fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
fullPreloader.onLoadComplete = function(target) {
target.my_txt.text = myTitle;
fullClipLoader.loadClip("full_images/"+myURL,fullImage_mc);
function createMask() {
_root.createEmptyMovieClip("mask_mc",_root.getNextHighestDepth());
mask_mc._x = _root.gallery_x;
mask_mc._y = _root.gallery_y;
mask_mc.beginFill(0x000000,100);
mask_mc.lineTo(_root.gallery_width,0);
mask_mc.lineTo(_root.gallery_width,_root.gallery_height);
mask_mc.lineTo(0,_root.gallery_height);
mask_mc.lineTo(0,0);
container_mc.setMask(mask_mc);
function scrolling() {
_root.onEnterFrame = function() {
container_mc._x += Math.cos(((mask_mc._xmouse)/mask_mc._width)*Math.PI)*15;
if (container_mc._x>mask_mc._x) {
container_mc._x = mask_mc._x;
if (container_mc._x<(mask_mc._x-(container_mc._width-mask_mc._width))) {
container_mc._x = mask_mc._x-(container_mc._width-mask_mc._width);
Would really really appreciate any help I can get. Thuyvar imageRequest:URLRequest = new URLRequest("my_gallery.swf");
var imageLoader:Loader = new Loader();
imageLoader.load(imageRequest);
addChild(imageLoader);
is as3 code. that won't work in your as2 project.
here's the equivalent in as2:
this.createEmptyMovieClip("targetMC",this.getNextHighestDepth());
targetMC.loadMovie("my_gallery.swf"); -
Flash Photogallery with preloader PLEASE HELP!!!
Ok...So after searching quite a bit I found a decent flash tutorial to help me make a photogallery. The only problem is that it takes quite sometime to load. I would like to create preloader for this swf file but I can't get anything to work. Here is the code for my gallery....Found at the bottom of the page at this site...
http://www.republicofcode.com/tutori...egallery/4.php
This all works just fine...but no matter what I do I can't seem to get a preloader for this code to work. If I load a simple image in the second frame it works fine, however if I move my flash gallery to second frame it just goes to my gallery after loading...(which takes a while)..no preloader bar or anything! Here is a link to my site... www.nakean.com visit the blank page for the photo gallery...you have to wait a bit for it to load. (15 seconds)..Please Please HELP!rename your gallery to something other than galleryinprogress.swf, say gallery.swf.
in flash create a new fla named galleryinprogress.fla with the same stage size and background color as your previous galleryinprogress.swf and attached to frame one of your new galleryinprogress.fla add:
var tf:TextField = this.createTextField("tf",1,0,0,100,40);
tf.autoSize = "center";
tf._x = Stage.width/2;
tf._y = Stage.height/2;
this.createEmptyMovieClip("mc",1);
mc.loadMovie("http://homepage.mac.com/nakean/.Public/swf/gallery.swf");
preloadI=setInterval(preloadF,100);
function preloadF(){
tf.text=mc.getBytesLoaded() +" bytes loaded out of "+mc.getBytesTotal()+" bytes total.";
if(mc.getBytesLoaded()>0&&mc.getBytesLoaded()>=mc.getBytesTotal()){
clearInterval(preloadI);
tf.removeTextField();
publish your new galleryinprogress.swf and upload to the same directory as your previous (but now renamed) galleryinprogress.swf. -
I'm just getting started with Flash and thought I'd work
through the tutorials included in the programs help. The tutorial
I'm stuck on is called: Creating Graphics - Applying Gradients. The
section I'm stuck on is Create a transform gradient with a shape.
I'm having problems applying the radial gradient—either
it doesn't work at all or applies to the fill but not the stoke.
This leads me to the question of what stroke and fill settings I
should have set up—after all I don't really want a stroke! Is
this oval shape drawn with object drawing turn't on or something?
I've looked at the completed .fla file and this shadow oval
shape seems to be a group. Has the person who created it grouped
the stoke and the fill or what? Which ever way the shape is
created, it doesn't say anything in the tutorial about how it
should be selected to apply the radial gradient! Surely it needs to
be selected somehow? Because when I try to apply the radial
gradient nothing happens!
Please can somebody help me figure this out—it's really
bugging me!rename your gallery to something other than galleryinprogress.swf, say gallery.swf.
in flash create a new fla named galleryinprogress.fla with the same stage size and background color as your previous galleryinprogress.swf and attached to frame one of your new galleryinprogress.fla add:
var tf:TextField = this.createTextField("tf",1,0,0,100,40);
tf.autoSize = "center";
tf._x = Stage.width/2;
tf._y = Stage.height/2;
this.createEmptyMovieClip("mc",1);
mc.loadMovie("http://homepage.mac.com/nakean/.Public/swf/gallery.swf");
preloadI=setInterval(preloadF,100);
function preloadF(){
tf.text=mc.getBytesLoaded() +" bytes loaded out of "+mc.getBytesTotal()+" bytes total.";
if(mc.getBytesLoaded()>0&&mc.getBytesLoaded()>=mc.getBytesTotal()){
clearInterval(preloadI);
tf.removeTextField();
publish your new galleryinprogress.swf and upload to the same directory as your previous (but now renamed) galleryinprogress.swf. -
Why is AS1 documentation not a part of CS3 help
hello;
in my flash CS3 help, there is AS2 and AS3 documentation, but
no AS1 documentation;
I have come to the understanding that AS1 would continue to
be supported in future flash authoring environments;
any thoughts?
thanks
dsdsdsdsddsdsdsdsd,
> I am still not convinced that AS3 is necessary
It isn't.
> just because an engineer can build a 800hp engine,
> powerful enough to thrust a wing-adapted minivan
> into flight
> doesn't mean it is the right approach: do soccer moms
even
> want to fly?
I do get your analogy. Really, I do. What I don't get is why
you're
the one making it -- because based on what you've described,
it sounds like
you're the engineer in this analogy, not the soccer mom.
After reading
Colin Moock's article, I would think even the soccer moms
should find
encouraged, but regardless ... of course you don't have to
use AS3. ;)
If you don't, you're stuck with a different set of
complexities, so it
all comes down to what you're comfortable with. In AS1/AS2,
you have on()
and/or onClipEvent() for handling events. You also have the
dot notation
equivalents (e.g. myClip.onRelease = handlerFunction). But
wait, there's
more! You also have addListener(). How's that for consistent?
Ah, but
then you also have addEventListener() -- just depends on
which datatype
you're handling the event for. If you're a longtime Flash
user -- and you
are -- then each new event handling model was something you
took in stride.
If you're new to the scene, it could seem like a completely
arbitrary mess.
In AS3 (outside of a drop-in-the-bucket NetStream exception),
you have
addEventListener(). Easy to learn and easy to remember,
because it's very
nearly consistent.
In AS1/AS2, if you want to instantiate a new MovieClip
instance, you
have to refer to an existing MovieClip instance and invoke
the
createEmptyMovieClip() method, give the new instance an
instance name and
assign it a depth. In AS3, you just invoke the constructor:
new
MovieClip(), then add the new instance to the display list.
It comes down to personal taste, I guess. To me, the newer
models are
easier to use ... once you learn them (of course). There are
trade-offs in
either camp, obviously.
> if someone could tell me some concrete thing
> that AS3 can do that AS1 cannot
> I would appreciate it;
I'm sure there are more, but here's a concrete thing off the
top of my
head: AS3 allows you to reparent movie clips (and other
visual display
objects) simply by removing them from the display list of one
object and
adding them to another. A practical example that comes to
mind is a jigsaw
puzzle, in which snapped-together pieces stay together,
making it easy to
move snapped-together pieces as a single group. Each
individual piece could
initially belong to the display list of the main timeline,
but could be
moved to the collective display list of a group of
snapped-together pieces.
Not that a single example should sway you. The example I
made might
just be meaningless to you, because you might not be
interested in
Flash-based jigsaws (or you might be interested, but would
rather move
snapped-together pieces by way of some algorithm that tracks
the position
and movement of each individual piece -- again, you're
trading one set of
complexities for another; on the main, I personally find the
complexities of
AS3 worth the learning curve).
> I am working on my first AS3 project - shopping cart -
but
> I will not use external packages );
And you shouldn't, unless you feel that external classes
would help you.
For me, I like the idea of utility classes (at least). In
order to create a
dynamic text field in AS1 -- let's say a non-selectable text
field, that
resizes as needed to fit the text, with a sans serif font --
you might do
something like this:
var tf = this.createTextField("myTextField", 0, 0, 0, 0, 0);
tf.selectable = false;
tf.autoSize = "left";
var fmt = new TextFormat();
fmt.font = "_sans";
tf.setNewTextFormat(fmt);
tf.text = "Lorem ipsum dolor sit amet";
(Note, this assumes Flash Player 8 or higher, because prior
to Flash Player
8, the MovieClip.createTextField() method returns Void.)
So ... to me, that's a lot to type. Again (this is my mantra
in this
post) ... one set of complexities for another. To reuse this
code, I could
certainly throw it into a function. Let's say something like
this:
function makeTextField(target, text) {
var tf = target.createTextField("myTextField" +
target.getNextHighestDepth(),
target.getNextHighestDepth(), 0, 0, 0, 0);
tf.selectable = false;
tf.autoSize = "left";
var fmt = new TextFormat();
fmt.font = "_sans";
tf.setNewTextFormat(fmt);
tf.text = text;
makeTextField(this, "Lorem ipsum dolor sit amet");
That's a tried and true procedural way to make your work
easier. I
think, so far, you would agree ... and I think, for you,
there's nothing new
so far. Notice that to keep instance names unique, I used
MovieClip.getNextHighestDepth() to append a number to the
instance name, and
also to ensure that a safe depth is met. A real
implementation would
probably include x,y positioning parameters, to make sure
text doesn't
overlap ... but you get the idea.
I could use AS2 to create a utility class called, say,
SimpleText.
Here's a stab at it. Quick and dirty AS2 external class file.
// Class file
class net.quip.utils.text.SimpleText {
public function SimpleText() {};
public static function makeTextField (target:MovieClip,
text:String):Void {
var tf:TextField = target.createTextField("myTextField" +
target.getNextHighestDepth(), target.getNextHighestDepth(),
0, 0, 0, 0);
tf.selectable = false;
tf.autoSize = "left";
var fmt:TextFormat = new TextFormat();
fmt.font = "_sans";
tf.setNewTextFormat(fmt);
tf.text = text;
More complex? In a sense, sure. Not by a whole lot, if you
really look
at it. The AS1 function version was a teensy bit bigger than
the
non-function version. The AS2 class version is a teensy bit
bigger than the
AS1 function version. But once it's done, it's done. If I
ever want this
functionality, I just import my class and use its (in this
case) static
method:
import net.quip.utils.text.SimpleText;
SimpleText.makeTextField(this, "Lorem ipsum dolor sit amet");
In my experience, that saves me time and effort. And this
same sort of
approach applies to non-static methods as well. It's just a
way to organize
your code. Many people find it more efficient. If you don't,
then you
don't. ;) It's as simple as that.
David Stiller
Adobe Community Expert
Dev blog,
http://www.quip.net/blog/
"Luck is the residue of good design." -
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 -
SetInterval passing variables...Need help
I have a script that I am trying to use the setInterval
command to animate a
textfield on the stage. I have a sample script that works and
passes the
value of this._y to the fly function but it uses onEnterFrame
since it is
created using movie clips in the library rather then in a
action script
class file. Any thoughts would be GREAT! its my understanding
that the
.prototype method indicates that the new function will assume
all values of
the previous function... is that not correct?
+++++++++++++++++++++++++++++++++++++++
New Code:
+++++++++++++++++++++++++++++++++++++++
function ScrollMsg(nin, depth, initialization) {
this._x = 30;
this._y = 500;
this.createTextField("Msg", 0, 0, 0,500, 150);
with(initialization.msgtext) {
wordWrap = true;
multiline = true;
border = true;
text = initialization.msgtext;
trace("bfr-this._y:"+this._y); // has value of _y
= to 500
// set continual function to fly
ScrollMsg.prototype.fly = function() {
trace("this._y:"+this._y); // value is
undefined
if (this._y > initialization.distance) {
this._y -=_global.MSG_SPEED;
trace("--this._y:"+this._y); // value is
undefined
} else {
this.removeMovieClip();
//Define Speed
setInterval( ScrollMsg.prototype.fly , 1000 );
+++++++++++++++++++++++++++++++++++++++
Original Script: (Works perfectly)
+++++++++++++++++++++++++++++++++++++++
// allow ScrollMsg to inherit MovieClip properties
ScrollMsg.prototype = new MovieClip();
function ScrollMsg() {
this._x = 30;
this._y = 0;
this.createTextField("Msg", 0, 0, 0, this.msgwidth, 10);
with(this.Msg) {
setNewTextFormat(_global.MsgFormat);
autoSize = "left";
wordWrap = true;
multiline = true;
embedFonts = true;
selectable = false;
text = this.msgtext;
// set continual function to fly
this.onEnterFrame = this.fly;
// instance methods
ScrollMsg.prototype.fly = function() {
if(!_global.MSG_ON_HOLD&&!_global.SYSTEM_ON_HOLD) {
if (this._y > this.distance) { this._y
-=_global.MSG_SPEED;} else {
this.removeMovieClip(); }
//this._alpha = 100 - Math.abs(this._y -
this.distance/2)*.3;I am trying to move different objects across the page at
different Intervals from nested actions on keyframes,
Kind of an on going action. One object (1) is a blimp flying
across the sky Left to right. Then a Jet plane (2) flys across
right to left. and then flys back to left,Then the blimp goes right
to left. I will fix those errors. Thank you so much. If this
addtional information helps, Please help.
BozArt -
Help with completing sentences game code
Hi, I`m a bit stuck, I`m making a game where you have to complete the sentences by dragging the words which are generated dinamically to its right place over some boxes, everything works fine but if you pull the words out of the boxes one all are placed it crashes.
Unfortunately this is someone elses code (another programmer who bailed on us in the middle of the proyect) although I manage to make it work with new words, making the draggable items undraggable one you place all 4 of them in the right boxes is totally unclear to me. I`ll appreciate any help I can get.
Here`s all the code that this part of the movie is using:
function aleatorio(min, max)
var _loc2 = true;
if (usados.length <= max - min)
while (_loc2 != false)
var _loc1 = Math.floor(Math.random() * (max - min + 1));
_loc2 = repetido(_loc1);
} // end while
usados.push(_loc1);
return (_loc1);
else
return (0);
} // end else if
} // End of the function
function repetido(num)
var _loc1 = false;
for (i = 0; i < usados.length; i++)
if (num == usados[i])
_loc1 = true;
} // end if
} // end of for
return (_loc1);
} // End of the function
stop ();
var usados = new Array();
_root.palabras_colocadas = 0;
palabras_correctas = 0;
listado_x = 700;
listado_y = 400;
origenx = 0;
origeny = 0;
estaba_en = -1;
apagar = false;
_root.frase = 2;
var palabras = new Array("huts", "made", "mud", "straw");
var correctas = new Array(false, false, false, false);
var ocupadas = new Array(-1, -1, -1, -1);
var my_font = new TextFormat();
my_font.font = "Arial";
my_font.color = 0;
my_font.size = 30;
palabras[i].embedFonts = true;
my_font.bold = true;
var i = 0;
while (i < 4)
this["cuadro" + i].gotoAndStop(1);
this.createEmptyMovieClip("myClip" + i, this.getNextHighestDepth());
largo = palabras[i].length * 22;
this["myClip" + i].createTextField("label", 1, 0, 0, largo, 40);
this["myClip" + i].label.text = palabras[i];
this["myClip" + i].label.setTextFormat(my_font);
this["myClip" + i].onPress = function ()
temp = this._name;
temp = Number(temp.charAt(6));
if (ocupadas[0] == temp)
apagar = true;
estaba_en = 0;
} // end if
if (ocupadas[1] == temp)
apagar = true;
estaba_en = 1;
} // end if
if (ocupadas[2] == temp)
apagar = true;
estaba_en = 2;
} // end if
if (ocupadas[3] == temp)
apagar = true;
estaba_en = 3;
} // end if
if (!apagar)
estaba_en = -1;
} // end if
origenx = this._x;
origeny = this._y;
trace ("estaba en " + estaba_en);
this.startDrag();
this["myClip" + i].onRelease = this["myClip" + i].onReleaseOutside = function ()
this.stopDrag();
cual = this._name;
cual = Number(cual.charAt(6));
drop = eval(this._droptarget);
trace (drop);
donde = String(drop);
cuadro = donde.substr(8, 6);
donde = Number(donde.charAt(14));
trace (cual + " en " + donde + " " + cuadro);
if (cuadro == "cuadro")
if (ocupadas[donde] >= 0 && ocupadas[donde] <= 3 || donde == estaba_en)
apagar = false;
this._x = origenx;
this._y = origeny;
else
if (!apagar)
++_root.palabras_colocadas;
} // end if
tramo = eval("tramo" + (donde + 1) + "_mc");
tramo.gotoAndPlay(2);
if (_root.palabras_colocadas >= 4)
startbtn.start();
start_mc.gotoAndPlay(2);
else
palabra_ok.start();
} // end else if
largo = palabras[cual].length * 8.500000E+000;
drop.gotoAndStop(2);
this._y = drop._y - 22;
this._x = drop._x - largo;
ocupadas[donde] = cual;
if (apagar)
apaga = eval("cuadro" + estaba_en);
apaga.gotoAndStop(1);
tramo = eval("tramo" + (estaba_en + 1) + "_mc");
tramo.gotoAndPlay(6);
ocupadas[estaba_en] = -1;
correctas[estaba_en] = false;
apagar = false;
trace ("hay " + _root.palabras_colocadas + " palabras");
if (_root.palabras_colocadas == 3)
trace ("apaga sin ruido");
start_mc.gotoAndStop(1);
} // end if
} // end if
trace (ocupadas[0] + " " + ocupadas[1] + " " + ocupadas[2] + " " + ocupadas[3]);
if (cual == donde)
++palabras_correctas;
correctas[donde] = true;
} // end if
} // end if
} // end else if
if (cuadro == "myClip" || cuadro == "start_")
palabra_error.start();
this._x = origenx;
this._y = origeny;
} // end if
if (cuadro == "fondo")
if (apagar)
apaga = eval("cuadro" + estaba_en);
apaga.gotoAndStop(1);
tramo = eval("tramo" + (estaba_en + 1) + "_mc");
tramo.gotoAndPlay(6);
ocupadas[estaba_en] = -1;
correctas[estaba_en] = false;
--_root.palabras_colocadas;
apagar = false;
trace ("hay " + _root.palabras_colocadas + " palabras");
if (_root.palabras_colocadas == 3)
startbtn.start();
start_mc.gotoAndStop(1);
} // end if
} // end if
} // end if
++i;
} // end while
var ii = 0;
while (ii < 4)
var numeroNuevo = aleatorio(1, 4);
trace (numeroNuevo);
this["myClip" + numeroNuevo]._x = listado_x;
this["myClip" + numeroNuevo]._y = listado_y + 40 * i;
++ii;
} // end whilethat's too much code to go through line by line. i'd recommend placing some trace() functions in strategic locations to narrow the location of the problem.
-
Help with ActionScript 2.0 and XML
Here I am trying to use actionscript to load my content with is an XML file with html formatting. I have the actionscript on only 1 Scene and i have links that switch between scences. The problem(s) is(are) that when I click the link for the scene that has the actionscipt all it says is "null" where it should have the text i want to display from the XML file. Here is the code for the AS and XML:
xml = new XML();
xml.ignoreWhite = true;
xml.load("contenido.xml");
xml.onLoad = function () {
txt = createTextField("txt",getNextHighestDepth(), 30, 300, 300, 100);
txt.html = true;
txt.htmlText = xml.firstChild.nodeValue;
<?xml version="1.0" encoding="UTF-8"?>
<htmlData><![CDATA[ Here is my <br/> html text ]]></htmlData>
any help is greatly appreciatedTry...
xml.onLoad = function () {
txt = createTextField("txt",getNextHighestDepth(), 30, 300, 300, 100);
txt.multiline = true;
txt.html = true;
txt.htmlText = xml.firstChild.childNodes[0].nodeValue; -
CreateTextField function question
Hi - I think what I'm trying to do is fundamental but I'm not
doing it correctly.
I have a swf that has a few different textFields appearing
when buttons are clicked. I thought I could write one function that
would handle the creation of all the textFields so that I could
just put a few parameters into the function call at the onRelease.
So is there a way to make this code into a function (like
"makeTF") such that I could replace "block_txt" with any string I
want and call the function like : makeTF(AnyString, depth, 110,90,
200,60);
I appreciate any help with this.
jlkglad - thanks for the reply. The only thing I think I
understand is "change makeTF() so it accepts a movieclip parameter.
So I added "basemc:MovieClip" within the parens. That's as
much as I thought I was sure of.
"that movieclip will be the one upon which you want to attach
the textfield." is where I stop understanding because of the word
"attach". But I persist anyway.
"then inside your function body use that movieclip parameter
instead of "this". "
So - inside the function body I see:
this.createTextField(s,dep,x,y,w,h);
....and I replace that with:
basemc.createTextField(s,dep,x,y,w,h);
This sort of make sense until I go to the place where the
function call actually sits. The "makeTF()" call goes on the
actions layer on the movie clip "info_panel1" (because that's the
mc upon which I want to ....) so it looks like:
info_panel1.makeTF("<h1> This is
INFO.</h1>","tf_panel1",99,40,250,370,140);
... and the text doesn't show at all.
BTW: otherwise the call I was using looked like this:
_root.makeTF("<h1> This is
INFO.</h1>","tf_panel1",99,40,250,370,140);
...but that's the code that didn't go away when another mc
was attached.
Where did I misunderstand?
jl -
Migration Help with createEmptyMovieClip
Hi,
I'm having some big problems trying to migrate this part of
code from AS2 to AS3. I'm newbie, and tried to google examples, but
i still can't get it. If someone could really help me, please.
quote:
mc.createEmptyMovieClip(clip_name, mc.getNextHighestDepth());
('field_container_mc', mc[clip_name].getNextHighestDepth());
mc[clip_name].field_container_mc.createTextField('field_mc',
mc[clip_name].field_container_mc.getNextHighestDepth(), 0, 0,
bm_width, bm_height);
mc[clip_name].field_container_mc.field_mc.autoSize = 'left';
Thanks, Mauricesolved.
-
Problem with threads and simulation: please help
please help me figure this out..
i have something like this:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class DrawShapes extends JApplet{
private JButton choices[];
private String names[]={"line", "square", "oval"};
private JPanel buttonPanel;
private DrawPanel drawingArea;
private int width=300, height=200;
public void init(){
drawingArea=new DrawPanel(width, height);
choices=new JButton[names.length];
buttonPanel=new JPanel();
buttonPanel.setLayout(new GridLayout(1, choices.length));
ButtonHandler handler=new ButtonHandler();
for(int i=0; i<choices.length; i++){
choices=new JButton(names[i]);
buttonPanel.add(choices[i]);
choices[i].addActionListener(handler);
Container c=getContentPane();
c.add(buttonPanel, BorderLayout.NORTH);
c.add(drawingArea, BorderLayout.CENTER);
}//end init
public void setWidth(int w){
width=(w>=0 ? w : 300);
public void setHeight(int h){
height=(h>=0 ? h : 200);
/*public static void main(String args[]){
int width, height;
if(args.length!=2){
height=200; width=300;
else{
width=Integer.parseInt(args[0]);
height=Integer.parseInt(args[1]);
JFrame appWindow=new JFrame("An applet running as an application");
appWindow.addWindowListener(
new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
DrawShapes appObj=new DrawShapes();
appObj.setWidth(width);
appObj.setHeight(height);
appObj.init();
appObj.start();
appWindow.getContentPane().add(appObj);
appWindow.setSize(width, height);
appWindow.show();
}//end main*/
private class ButtonHandler implements ActionListener{
public void actionPerformed(ActionEvent e){
for(int i=0; i<choices.length; i++){
if(e.getSource()==choices[i]){
drawingArea.setCurrentChoice(i);
break;
}//end class DrawShapes
class DrawPanel extends JPanel{
private int currentChoice=-1;
private int width=100, height=100;
public DrawPanel(int w, int h){
width=(w>=0 ? w : 100);
height=(h>=0 ? h : 100);
public void paintComponent(Graphics g){
super.paintComponent(g);
switch(currentChoice){
case 0: g.drawLine(randomX(), randomY(), randomX(), randomY());
break;
case 1: g.drawRect(randomX(), randomY(), randomX(), randomY());
break;
case 2: g.drawOval(randomX(), randomY(), randomX(), randomY());
break;
public void setCurrentChoice(int c){
currentChoice=c;
repaint();
private int randomX(){
return (int) (Math.random()*width);
private int randomY(){
return (int) (Math.random()*height);
}//end class drawPanel
That one's from a book. I used that code to start with my applet. Mine calls different merthod from the switch cases. Say I have:
case 0: drawStart(g); break;
public void drawStart(Graphics g){
/* something here */
drawMain(g);
public void drawMain(graphics g){
g.drawString("test", x, y);
//here's where i'm trying to pause
//i've tried placing Thread.sleep between these lines
g.drawLine(x, y, a, b);
//Thread.sleep here
g.drawRect(x, y, 50, 70);
}I also need to put delays between method calls but I need to synchronize them. Am I doing it all wrong? The application pauses or sleeps but afterwards, it still drew everything all at once. Thanks a lot!It is. Sorry about that. Just answer any if you want to. I'd appreciate your help. Sorry again if it caused you anything or whatever. .n_n.
-
Table1:
ou store point
LS LIB1 50
LS LIB1 200
LS LIB1 100
LS LIB1 79
I have to insert table1 to table2 by splitting into every 143point and assing serial number for every 143 from parameter.
in aboce example we can split 3 time 143 like below table2 sample.
Table2
ou store point serial_number
LS LIB1 50 101
LS LIB1 93 101
LS LIB1 107 102
LS LIB1 36 102
LS LIB1 64 103
LS LIB1 79 103
i tried below procedure its not working.
table may have any order like below.
Table1:
ou store point
LS LIB1 200
LS LIB1 50
LS LIB1 100
LS LIB1 79
then table2
ou store point serial_number
LS LIB1 143 101
LS LIB1 57 102
LS LIB1 50 102
LS LIB1 36 102
LS LIB1 64 103
LS LIB1 79 103
create or replace procedure assign_serial(from_num number,to_num number) is
bal number(10);
begin
bal := 0;
for c1 in(select * from table1)
loop
if c1.point <=143 then
if bal=0 then
bal=143-used;
insert int0 table2 values(c1.ou,c1.store,used);
elsif used > 0 then
used=used-bal;
insert int0 table2 values(c1.ou,c1.store,bal);
bal=0;
if used > 0 then
insert int0 table2 values(c1.ou,c1.store,used);
end if;
bal:=143-used;
end if;
end loop;
end;
How to split and assign serial number,please hELP..after giving serial num i have to change points in table1 to 0.The problem for SUm and split for every 143 is ,different OU and store is there.we have to know for which store points we earned serial number.
i hope this below logic little satisfy except assign cardnum,please........ check and currect the logic
LS LIB1 50
LS LIB1 200
LS LIB1 100
LS LIB1 79
--variable used and bal
for c1 in(select * from table1)
loop
used := c1.points;
if c1.point <=143 then
if bal=0 then
bal=143-used;
insert int0 table2 values(c1.ou,c1.store,used);
elsif used > 0 then
used=used-bal;
insert int0 table2 values(c1.ou,c1.store,bal);
bal=0;
if used > 0 then
insert int0 table2 values(c1.ou,c1.store,used);
end if;
bal:=143-used;
end if;
end loop;
Maybe you are looking for
-
Retrieving datas with ArrayList
Below, im trying to get 6 columned records from the access database. //PNL 1: PNL1=new JPanel(); PNL1.setLayout(new BorderLayout(15,15)); java
-
i was wondering if there is a device that helps improve my cell phone (IPhone) signal? When I send a text or call anyone from my house I am unable to reach anyone and or the texts don't go through until I get closer to town... Thanks
-
I have pictures in my camera roll on my 3gs model and have a new 4s, question is, how do I transfer the camera roll photos to the new iphone ?
-
Java.exe return codes - windows
I have a java application being run from a batch file on WindowsNT4sp6a using Sun's j2se 1.3.0 (build 1.3.0-C) with Java Hotspot (TM) Client VM (build 1.3.0-C, mixed mode) and during the course of running the app (confirmed that it happens at differe
-
I'm trying to open a crystal report, and it's giving me the error pasted below. I see that it says "bad username/password", but I already went into crystal report administration --> account setup, and entered my database username and password (sa/pas