RemoveTextField
I created textfield at runtime using createTextField method,
then i tried to clear the textfield, i used
removeTextField() method
but it is not removing the textfield, even i used
textfield.visible=false
then also not it is showing the textfield, help me to remove
textfield
create an array to store your textfields and store their references in that array. then loop through that array (from end to beginning) and remove them when you want:
// these lines should execute once only at the start of your fla to initialize tfA and removeTF()
var tfA:Array = [];
function removeTF(){
for(var i:Number=tfA.length-1;i>=0;i--){
tfA[i].removeTextField();
// then when you create tf's, store them:
this.createTextField("scroll_txt", this.getNextHighestDepth(), 0, 0, 0, 0);
this.createTextField("newszlatest", this.getNextHighestDepth(), 143, 170, 648, 233);
tfA.push(scroll_txt);
tfA.push(newszlatest);
// then when you want to remove them all, call removeTF():
Similar Messages
-
Change Movieclips Parameters-Variables
Hi,
Im working on the following code and i need some help to
change part of the code:
The code is a slider to view pictures loaded from external
file. I changed the size of the stage(1000x1000), the big pictures
are displayed above(1000x400) and i would like to do 3 things:
1.The slider has the size(400x50). I changed its
size(500x80), the thumbnails move but at some point the slider
remains half empty and then fills up again. This happens when i
have small amount of pictures. I would like not to double but
treble the No of the thumbnails so the slider wont remains empty.
2.Move the thumbnails on the right-half part of the stage.
When i only change the coordinates(x,y) of the slider it doesnt
work.They r loaded on the right part, but when placing the cursor
above they disappear.
3.Is it possible when placing the cursor over a thumbnails to
show text(small description of each pic)????
Heres the URL of the code working:
http://www.flash-creations.com/notes/dynamic_slidingviewer.php
Thanks
Theo
Heres the code:
/********* DECLARE AND INITIALIZE VARIABLES
// names of folder and pictures, in the order to put them
into the slider
var picnames:Array = [
"flower_orange",
"flower_yellow",
"flower_pink",
"flower_red",
"flower_purple"
// constants
var PICPATH:String = "flowers/"; // folder with jpgs
var NPICS:Number = picnames.length; // number of pictures to
load
var PICX:Number = 10; // x loc of big picture
var PICY:Number = 10; // y loc
var THUMBHOLDERX:Number = 0; // x location of thumbnail
holder movieclip
var THUMBHOLDERY:Number = 240; // y location
var THUMBW:Number = 72; // width of each thumbnail
var THUMBH:Number = 40; // height
var MARGIN:Number = 10; // margin between thumbnails
var TOTALBYTES:Number = 212000; // approx sum of bytes in all
jpgs (x 2)
var MAXPIXELS:Number = 12; // max number of pixels to move
slider per frame
// mask definition; mask is assumed to cover some part of the
thumbnail slider (here the numbers
// were chosen so that there are margins between the mask and
the right and left edges of the movie
// (which is 420 x 290), and enough space above and below the
thumbs to show them when they 'grow'
// on mouseover
var MASKX:Number = 10; // start x location of mask
var MASKW:Number = 400; // mask width
var MASKY:Number = 230; // start y location of mask
var MASKH:Number = 60; // mask height
var totalloaded:Number = 0; // running tally of bytes loaded
from all pics
// index into pictures array, used for loading
var ipic:Number;
// set up loader, an instance of MovieClipLoader
var loader:MovieClipLoader = new MovieClipLoader();
// use the main timeline to listen to and respond to loader's
broadcast events
loader.addListener(this);
/********* DEFINE FUNCTIONS, INCLUDING INIT FOR MOVIE SETUP
// thumbnail rollover handler
function grow() {
this.onEnterFrame = function() {
if (this._width < THUMBW * 1.2) {
this._x -= this._width * .025;
this._y -= this._height * .025;
this._width *= 1.05;
this._height *= 1.05;
} else delete this.onEnterFrame;
// thumbnail rollout handler
function shrink() {
this.onEnterFrame = function() {
if (this._width > THUMBW) {
this._width /= 1.05;
this._height /= 1.05;
this._x += this._width * .025;
this._y += this._height * .025;
} else delete this.onEnterFrame;
// function to move thumbnail slider ("this" = thumbs_mc)
function sliderControl() {
var w:Number = this._width/2;
var hw:Number = mask_mc._width/2;
var npixels:Number;
// only do when mouse over slider mask
if (_ymouse > mask_mc._y && _ymouse <
mask_mc._y + mask_mc._height) {
// mouse over left half of slider:
if (_xmouse > mask_mc._x && _xmouse <
mask_mc._x + hw) {
npixels = (hw - _xmouse) / hw * MAXPIXELS;
this._x += npixels;
if (this._x >= 0) this._x = this._x - w;
// mouse over right half of slider:
} else if (_xmouse > mask_mc._x + hw && _xmouse
< mask_mc._x + mask_mc._width) {
npixels = (_xmouse - hw) / hw * MAXPIXELS;
this._x -= npixels;
if (this._x <= -w) this._x = this._x + w;
// thumbnail click (onrelease) handler
function openPic() {
pic_mc.loadMovie(PICPATH + picnames[this.i] + ".jpg");
// assign event handlers (called when all jpgs are loaded)
function setupHandlers() {
pct_txt.removeTextField(); // don't need loading indicator
any more
thumbs_mc.onEnterFrame = sliderControl;
for (var i:Number = 0; i < NPICS*2; i++) {
thumbs_mc["mc"+i].onRollOver = grow;
thumbs_mc["mc"+i].onRollOut = shrink;
thumbs_mc["mc"+i].onRelease = openPic;
// listener function for broadcast 'done' message (for each
pic)
// onLoadInit gets executed when the movieclip has been
loaded into _mc AND
// its width and height data are available.
// (_mc = the movieclip being loaded into)
// this routine sets the size and position of each thumbnail
clip as its jpg
// is loaded and starts the next one loading. When all have
been loaded,
// a random picture is loaded into pic_mc and setupHandlers
is called to
// assign handlers to each thumbnail movieclip
function onLoadInit(_mc:MovieClip) {
// this gets done when the jpg is completely loaded:
_mc._width = THUMBW;
_mc._height = THUMBH;
_mc._alpha = 99; // for image clarity
// give the movieclip a property to remind it who it is
// (used by openPic to know which big picture to open)
_mc.i = (ipic >= NPICS ? ipic-NPICS : ipic);
// add picture size to totalloaded variable
totalloaded += loader.getProgress(_mc).bytesTotal;
// now load the next one (if there are more) or set up
handlers if done
ipic++;
if (ipic == NPICS * 2) {
// start with a random photo displayed when all thumbs
loaded
pic_mc.loadMovie(PICPATH +
picnames[Math.floor(Math.random()*NPICS)] + ".jpg");
setupHandlers();
} else if (ipic >= NPICS) {
// load jpg into duplicate thumbnail (will already be
cached)
loader.loadClip(PICPATH + picnames[ipic-NPICS] + ".jpg",
thumbs_mc["mc"+ipic]);
} else {
// load jpg into thumbnail
loader.loadClip(PICPATH + picnames[ipic] + ".jpg",
thumbs_mc["mc"+ipic]);
// listener function to handle broadcast progress messages
// make pct_txt show cumulative loading progress
function onLoadProgress(_mc:MovieClip, loaded:Number) {
var loadedsofar:Number = totalloaded + loaded;
pct_txt.text = Math.floor(loadedsofar / TOTALBYTES * 100) +
function init() {
// create holder for pictures
createEmptyMovieClip("pic_mc", 1);
pic_mc._x = PICX;
pic_mc._y = PICY;
// create (and draw) holder for thumbnails
createEmptyMovieClip("thumbs_mc", 2);
thumbs_mc.beginFill(0, 100); // black
thumbs_mc.moveTo(0, 0);
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, 0);
thumbs_mc.lineTo(2 * (MARGIN + THUMBW) * NPICS, THUMBH);
thumbs_mc.lineTo(0, THUMBH);
thumbs_mc.endFill();
// drawing the thumb holder at 0, 0 and then moving it makes
its reg point = upper left
thumbs_mc._x = THUMBHOLDERX;
thumbs_mc._y = THUMBHOLDERY;
// create, draw and enable mask over thumbs (could use
different variables to define mask
// if desired)
createEmptyMovieClip("mask_mc", 3);
mask_mc.beginFill(0x0000cc, 100);
mask_mc.moveTo(0, 0);
mask_mc.lineTo(MASKW, 0);
mask_mc.lineTo(MASKW, MASKH);
mask_mc.lineTo(0, MASKH);
mask_mc.endFill();
mask_mc._x = MASKX;
mask_mc._y = MASKY;
thumbs_mc.setMask(mask_mc);
// create loading textfield indicator
createTextField("pct_txt", 4, 200, 100, 40, 100);
var tf:TextFormat = new TextFormat();
tf.align = "center";
tf.size = 12;
tf.font = "Verdana";
tf.color = 0xFFFF00;
pct_txt.setNewTextFormat(tf);
// make empty movieclips in thumbs_mc for each pic to go
into
// make double the number so the slider can move
continuously and show content
for (var i:Number = 0; i < NPICS * 2; i++) {
var mc:MovieClip = thumbs_mc.createEmptyMovieClip("mc"+i,
i+1);
mc._x = i*(MARGIN + THUMBW);
mc._y = 0;
// set the pointer to the first jpg in the array picnames
ipic = 0;
// start loading jpgs (ipic is initialized to 0)
loader.loadClip(PICPATH + picnames[ipic] + ".jpg",
thumbs_mc["mc"+ipic]);
/********* CALL THE INIT FUNCTION TO START THE MOVIE
init();Hi,
Thanks for the quick reply.
The problem here is there variables are again used in calculating some other variable values either single value or intervals. Also there are many queries which use these variable I am discussing about. So, in this case it will be really hectic to change all these queries. Even though if we change these variable properties, I think as these are mandatory customer exit default value variables, there wont be any effect. If at all any exists can you please let me know what type?
What do you suggest?
Regards,
Ravi -
Why does the content spill over and how do I position this under the menu and title?
I was following this tutorial on how to add a scrolling image gallery to a Flash website.
(http://www.republicofcode.com/tutorials/flash/xmlimagegallery/index.php)
From what I understand from this tutorial, it is just a matter of copying the Actionscript code and pasting it onto the timelines then making modifications on the XML.
(kindly see a screenshot of timeline layers I made and as to where I put the Actionscript code:
http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_01.jpg )
I pasted the code onto the blank keyframe labeled "Gallery"...
But all I get is this weird effect when I click on the button for the gallery...
(kindly see a screenshot of it here: http://i429.photobucket.com/albums/qq19/tsujzpie/imagegalleryproblem_02.jpg )
When you put a blank keyframe on a timeline, any content put in there is supposed to only be contained in that very frame, right? How come then that - whenever the gallery button is clicked on - the content from that section spills out onto the other sections even when I click on other button for the other areas?
I just really couldn't think why this is happening - any reason why this is so?
And how do I position the gallery right under the section header and menu bar?
Here is its AS2 code, by the way:
import mx.transitions.Tween;
import mx.transitions.easing.*;
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<myImagesTotal; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
myThumb_mc._y = _root.thumb_height*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) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 50;
target.onRollOut = function() {
this._alpha = 100;
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",fullImage_mc.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) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
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._y += Math.cos(((mask_mc._ymouse)/mask_mc._height) *Math.PI)*15;
if (container_mc._y>mask_mc._y) {
container_mc._y = mask_mc._y;
if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc. _height))) {
container_mc._y = mask_mc._y-(container_mc._height- mask_mc._height);You should create a manually movieclip symbol with nothing in it and take a copy of it from the library and place it in the frame where you intend for the gallery to display. Give it an instance name of "container_mc" and remove the following line from your callThumbs function
_root.createEmptyMovieClip("container_mc",_root.getNextHigh estDepth());
You probably need to do the same for the mask and the full images since they appear to also be created using dynamic mc's. -
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(); -
How to load 2 xml galleries in single function loop.
how to load 2 xml galleries in single function loop.
my function is--------
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery.xml");
function callThumbs()
_root.createEmptyMovieClip("wall",_root.getNextHighestDepth());
wall._x = _root.gallery_x;
wall._y = _root.gallery_y;
wall.addEventListener(MouseEvent.CLICK);
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i =0; i <6; i++)
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height * i;
myThumb_mc._x = _root.thumb_position = -3100 + (i-j) * 765;
clipLoader.loadClip("shop/" + thumbURL,myThumb_mc); // i want to load this by xml gallery "gallery1.xml"
preloader.onLoadStart = function(target)
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes)
target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);
preloader.onLoadComplete = function(target)
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function()
callFullImage(this._name);
target.onRollOver = function()
this._alpha = 100;
target.onRollOut = function()
this._alpha = 100;
for (i = 0; i < 6; i++)
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height * i;
myThumb_mc._x = _root.thumb_position = -7210 + (i-j) * 765;
myThumb_mc._y = _root.thumb_position = 180;
clipLoader.loadClip("banner/" + thumbURL,myThumb_mc); // i want to load this by xml gallery "gallery2.xml"
preloader.onLoadStart = function(target)
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes)
target.my_txt.text = Math.floor((loadedBytes / totalBytes) * 100);
preloader.onLoadComplete = function(target)
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function()
callFullImage(this._name);
target.onRollOver = function()
this._alpha = 100;
target.onRollOut = function()
this._alpha = 100;combine the two xml files into one if you want to create one gallery.
if you want two different galleries that display at different times, remove the movieclip wall after you're done with gallery1 and execute myGalleryXML.load("gallery2.xml"); -
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"); -
I want to space between thumb... which is calling by "gallery.xml"
function callThumbs() {
_root.createEmptyMovieClip("wall",_root.getNextHighestDepth());
wall._x = _root.gallery_x= 0;
wall._y = _root.gallery_y= 340;
wall.addEventListener(MouseEvent.CLICK);
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i=0; i<15; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height*i;
myThumb_mc._x = _root.thumb_position=-2000;
clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,1 0);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
preloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100;use:
var gapX:Number=5;
var nextX:Number = 0;
var loadNum:Number=0;
var preloader:Object={};
var clipLoader:MovieClipLoader=new MovieClipLoader();
clipLoader.addListener(preloader);
function callThumbs() {
_root.createEmptyMovieClip("wall",_root.getNextHighestDepth());
wall._x = _root.gallery_x= 0;
wall._y = _root.gallery_y= 340;
//wall.addEventListener(MouseEvent.CLICK);
//var clipLoader = new MovieClipLoader();
//var preloader = new Object();
//clipLoader.addListener(preloader);
loadnextF();
function loadnextF(){
thumbURL = myImages[loadNum].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(loadNum, wall.getNextHighestDepth())
myThumb_mc._alpha=0;
clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,1 0);
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._x = nextX;
nextX += target._width+gapX;
loadNum++;
if(loadNum<15){
loadnextF();
} else {
// all images loaded. do whatever.
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100; -
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. -
AS Random letter script not working
I have the Flash AS Bible and one of the exercises is to
create a random letter displayer. I am not getting any errors in my
AS code, so I believe I have that o.k, but when I test movie I only
get a blank screen. One part I am unsure about is "using the text
tool, add an authoring time dynamic TextField object offstage on
the embedded font layer.
I see ta dynamic text box created, but I am not sure about
the rest. I also have it in the embedded font layer.
Also this part. "Open the Character Embedding dialog box and
choose the "specify ranges" option and the value abcdef in the
"include these characters" field.
I see the character embedding dialog box, but not the option
to choose "specify ranges". I do see the "include these characters"
field.
Someone please explain what I may be doing wrong.
Also just FYI herre is the AS code:
//Create the array of letters.
var aLetters:Array = ["a", "b", "c", "d" , "e", "f"];
//Set the interval at which a new letter should be displayed.
var nDisplayInterval:Number = setInterval(this,
"displayLetter", 1);
//Define an associative array to store data about ecach
letter.
var oLetters
bject = new Object();
function displayLetter():Void {
//Create a random integer to yield one of the indices from
the
//aLetters array.
var nRandomIndex:Number = Math.floor(Math.random()
*aLetters.length);
//Create random numbers to use for x and y coordinates of
// the letter TextField.
var nRandomX:Number = Math.random() *550;
var randomY:Number = Math.random() *400;
//Get the next available depth;
var nDepth:Number = this.getNextHighestDepth();
//Create a new Textfield object at the random x and y
//coordinates.
var tLetter:TextField = this.createTextField("tletter" +
nDepth,
nDepth, nRandomX, nRandomY, 0, 0);
//Set the autosize and text properties so the random letter
displays
tLetter.autosize = "left";
//Set the text.
tLetter.text = aLetters[nRandomIndex];
//Initialize the _alpha property to 0.
tLetter._alpha=0;
//Tell Flash to embed the font for the TextField.
tLetter.embedFonts = true;
//Define a new object into which to store some data for the
letter.
var oLetter
bject = new Object();
//Assign the object to the oLetters assocaitive array usimg
the instance name
//of the TextField object as the key
oLetters[tLetter._name] = oLetter;
//Set a element called fadeDirection that determines
//the increment by which the alpha will change. And set the
//alpha to 0 initially.
oLetter.fadeDirection = 5;
//Define an element that references the TextField.
oLetter.letterField = tLetter;
//Create a TextFormat object that tells Flash to use the
//Verdana font and sets the size to 15.
var tfFormatter:TextFormat = new TextFormat();
tfFormatter.font="Verdana";
tfFormatter.size= 15;
//Assign the TextFormat to the TextField.
tLetter.setTextFormat(tfFormatter);
//Set an interval at which the letter will fade in and out.
Assign the ID
//to a property of the oLetter onject so we can clear it
later. Pass the
//alphaFade() function a reference to the oletter object.
oLetter.interval = setInterval(alphaFade, 10, oLetter);
function alphaFade(oLetter
bject):Void {
//Retrieve the TextField object reference.
var tLetter:TextField = oLetter.letterField;
//Increment the letter TextField's alpha.
tLetter._alpha += oLetter.fadeDirection;
//Check to see if the letter has faded in completely. If so
//set the fadeDirection property to -5 so that The TextField
//Starts to fade out. Otherwise, if the letter has faded out
//completely clear the interval and remove the TextField.
if(oLetter.fadeDirection > 0 && tLetter._alpha
>=100) {
oLetter.fadeDirection = -5;
else if(oLetter.fadeDirection < 0 &&
tLetter._alpha <=0) {
clearInterval(oLetter.interval);
delete oLetters[tLetter._name];
tLetter.removeTextField();
//make sure to update the screen.
updateAfterEvent();
thanks!Sounds ok but here is how you do that.
With the text tool selected, draw a text box anywhere you
like but not on the stage. Using the property inspector set the
text field to be dynamic. Type some text in the text field, select
it and using the property inspector, select Verdana for the font.
In the property inspector click 'embed' and select the character
sets you want to embed or just use the "include these characters"
field to embed the characters you are using in your aLetters array.
If you do not embed the font, you'll get a blank screen. I've
tested the code and it works properly. -
For (i=0; i mgBW.length; i++) {
I'm trying to loop this but won't work. Could someone help me to get this fixed?
var mgB:Array = [browseMC1, browseMC2, browseMC3];
var mgBW:Array = [targetMC1, targetMC2, targetMC3];
var mgPW:Array = [logoPreviewMC1, logoPreviewMC2, logoPreviewMC3];
for (i=0; i<mgBW.length; i++) {
mgB[i].ivar=i;
tl.mgB[i].onRelease = function() {
var fileType:Array = [{description: "Image files", extension: "*.jpg;*.gif;*.png"}]
fRef.browse(fileType);
tl.targetXMC3 = tl.mgBW[this.ivar]._x;
tl.targetYMC3 = tl.mgBW[this.ivar]._y;
var fileLimit:Number = 1000*1024;
var previewMCL:MovieClipLoader = new MovieClipLoader();
var previewLO:Object = {};
var logoMCL:MovieClipLoader = new MovieClipLoader();
var logoLO:Object = {};
var logoA:Array = [gmb_mc.logoz_mc1,gmb_mc.logoz_mc2];
previewLO.onLoadInit = function(targetMC:MovieClip){
mgBW[this.ivar]._alpha = 100;
mgBW[this.ivar].forceSmoothing = true;
mgBW[this.ivar].cacheAsBitmap = true;
var aspectRatio:Number = mgBW[this.ivar]._width/mgBW[this.ivar]._height;
if(aspectRatio >= tl.mgPW[this.ivar]._width/tl.mgPW[this.ivar]._height){
mgBW[this.ivar]._width = tl.mgPW[this.ivar]._width;
mgBW[this.ivar]._height = mgBW[this.ivar]._width/aspectRatio;
mgBW[this.ivar]._x = tl.mgPW[this.ivar]._x;
mgBW[this.ivar]._y = tl.mgPW[this.ivar]._y + (tl.mgPW[this.ivar]._height - mgBW[this.ivar]._height)/2;
} else {
mgBW[this.ivar]._height = tl.mgPW[this.ivar]._height;
mgBW[this.ivar]._width = aspectRatio*mgBW[this.ivar]._height;
mgBW[this.ivar]._y = tl.mgPW[this.ivar]._y;
mgBW[this.ivar]._x = tl.mgPW[this.ivar]._x + (tl.mgPW[this.ivar]._width - mgBW[this.ivar]._width)/2;
logoIndex = 0;
replaceLOGOF();
previewMCL.addListener(previewLO);
logoLO.onLoadInit = function(targetMC:MovieClip){
logoIndex++;
mgBW[this.ivar].forceSmoothing = true;
mgBW[this.ivar].aspectRatio = mgBW[this.ivar]._width/mgBW[this.ivar]._height;
if(mgBW[this.ivar].aspectRatio>=mgBW[this.ivar]._parent.logoMC._width/mgBW[this.ivar]._par ent.logoMC._height){
mgBW[this.ivar]._width = mgBW[this.ivar]._parent.logoMC._width;
mgBW[this.ivar]._height = mgBW[this.ivar]._width/mgBW[this.ivar].aspectRatio;
} else {
mgBW[this.ivar]._height = mgBW[this.ivar]._parent.logoMC._height;
mgBW[this.ivar]._width = mgBW[this.ivar].aspectRatio*mgBW[this.ivar]._height;
mgBW[this.ivar]._x = -mgBW[this.ivar]._width/2;
mgBW[this.ivar]._y = -mgBW[this.ivar]._height/2;
mgBW[this.ivar]._alpha = 100;
mgBW[this.ivar]._parent.logoMC._visible = false;
if(logoIndex<logoA.length){
replaceLOGOF();
} else {
logoMCL.addListener(logoLO);
function replaceLOGOF(){
logoA[logoIndex].mgBW[this.ivar]._alpha = 0;
logoA[logoIndex].logoIndex = logoIndex;
logoMCL.loadClip(logoFileS,logoA[logoIndex].mgBW[this.ivar]);
var fRef:FileReference = new FileReference();
var fRefLO:Object = new Object();
fRefLO.onSelect = function(file:FileReference):Void {
for(k=1; k<mgB.length; k++){
mgB[k].enabled = false;
file.upload("/php/upload.php");
fRefLO.onCancel = function(file:FileReference):Void {
_root.upldbg_mc._visible = false;
_root.bar._visible = false;
_root.border._visible = false;
fRefLO.onOpen = function(file:FileReference):Void {
_root.upldbg_mc._visible = true;
_root.bar._visible = true;
_root.border._visible = true;
fRefLO.onProgress = function(file:FileReference, bl:Number, bt:Number):Void {
if(bl > fileLimit) {
cancelUploadF(file);
fRefLO.onComplete = function(file:FileReference):Void {
logoFileS = "/logoImages/"+file.name;
if(tl.mgBW[this.ivar]._width>0){
tl.mgBW[this.ivar].swapDepths(dep);
tl.mgBW[this.ivar].removeMovieClip();
tl.createEmptyMovieClip(mgBW[this.ivar],dep++);
tl.mgBW[this.ivar]._x = tl.targetXMC3;
tl.mgBW[this.ivar]._y = tl.targetYMC3;
tl.mgBW[this.ivar]._alpha = 0;
previewMCL.loadClip(logoFileS,tl.mgBW[this.ivar]);
var fileRef:FileReference = new FileReference();
fRef.addListener(fRefLO);
function cancelUploadF(file:FileReference){
file.cancel();
tl.mgBW[this.ivar]._alpha = 100;
if(!tl.mgBW[this.ivar].tf){
tl.mgBW[this.ivar].createTextField("tf",dep++,0,0,tl.mgPW[this.ivar]._width,tl.mgPW[this. ivar]._height);
with(tl.mgBW[this.ivar].tf){
multiline = true;
wordWrap = true;
text = "Upload Excedes 1000kb Size Limit";
clearTimeout(removeTO);
removeTO = setTimeout(removeTF,4000);
function removeTF(){
tl.mgBW[this.ivar].tf.removeTextField();In my webpage there are these 3 browse buttons (mgB). The user is allowed to upload 3 images and each uploaded image will show a preview in mgBW.
or
How can I enable the user to just use browseMC1 button to upload more than one image and make each uploaded image preview to display in targetMC1, targetMC2, etc.. in a sequence? to do this I've got the following code working but I'm not knowing how to make the image preview load in a sequence? (The first uploaded logo preview to be displayed in targetMC1 then the second uploaded image preview to be in targetMC2, etc...)
var tl:MovieClip = this;
var dep:Number = 0;
var logoFileS:String;
var logoIndex:Number;
tl.targetMC1X = tl.targetMC1._x;
tl.targetMC1Y = tl.targetMC1._y;
var fileLimit:Number = 1000*1024;
var previewMCL:MovieClipLoader = new MovieClipLoader();
var previewLO:Object = {};
var logoMCL:MovieClipLoader = new MovieClipLoader();
var logoLO:Object = {};
var logoA:Array = [gmb_mc.logoz_mc1,gmb_mc.logoz_mc2,gmb_mc.logoz_mc3];
tl.browseMC1.onRelease = function() {
var fileType:Array = [{description: "Image files", extension: "*.jpg;*.gif;*.png"}]
fRef.browse(fileType);
previewLO.onLoadInit = function(targetMC1:MovieClip){
targetMC1._alpha = 100;
targetMC1.forceSmoothing = true;
targetMC1.cacheAsBitmap = true;
var aspectRatio:Number = targetMC1._width/targetMC1._height;
if(aspectRatio >= tl.logoPreviewMC1._width/tl.logoPreviewMC1._height){
targetMC1._width = tl.logoPreviewMC1._width;
targetMC1._height = targetMC1._width/aspectRatio;
targetMC1._x = tl.logoPreviewMC1._x;
targetMC1._y = tl.logoPreviewMC1._y + (tl.logoPreviewMC1._height - targetMC1._height)/2;
} else {
targetMC1._height = tl.logoPreviewMC1._height;
targetMC1._width = aspectRatio*targetMC1._height;
targetMC1._y = tl.logoPreviewMC1._y;
targetMC1._x = tl.logoPreviewMC1._x + (tl.logoPreviewMC1._width - targetMC1._width)/2;
logoIndex = 0;
replaceLOGOF();
previewMCL.addListener(previewLO);
logoLO.onLoadInit = function(targetMC1:MovieClip){
logoIndex++;
targetMC1.forceSmoothing = true;
targetMC1.aspectRatio = targetMC1._width/targetMC1._height;
if(targetMC1.aspectRatio>=targetMC1._parent.logoMC._width/targetMC1._parent.logoMC._height ){
targetMC1._width = targetMC1._parent.logoMC._width;
targetMC1._height = targetMC1._width/targetMC1.aspectRatio;
} else {
targetMC1._height = targetMC1._parent.logoMC._height;
targetMC1._width = targetMC1.aspectRatio*targetMC1._height;
targetMC1._x = -targetMC1._width/2;
targetMC1._y = -targetMC1._height/2;
targetMC1._alpha = 100;
targetMC1._parent.logoMC._visible = false;
if(logoIndex<logoA.length){
replaceLOGOF();
logoMCL.addListener(logoLO);
function replaceLOGOF(){
logoA[logoIndex].targetMC1._alpha = 0;
logoA[logoIndex].logoIndex = logoIndex;
logoMCL.loadClip(logoFileS,logoA[logoIndex].targetMC1);
var fRef:FileReference = new FileReference();
var fRefLO:Object = new Object();
fRefLO.onSelect = function(file:FileReference):Void {
file.upload("php/upload.php");
fRefLO.onCancel = function(file:FileReference):Void {
_root.upldbg_mc._visible = false;
fRefLO.onOpen = function(file:FileReference):Void {
_root.upldbg_mc._visible = true;
fRefLO.onProgress = function(file:FileReference, bl:Number, bt:Number):Void {
if(bl > fileLimit) {
cancelUploadF(file);
fRefLO.onComplete = function(file:FileReference):Void {
logoFileS = "logoImages/"+file.name;
if(tl.targetMC1._width>0){
tl.targetMC1.swapDepths(dep);
tl.targetMC1.removeMovieClip();
tl.createEmptyMovieClip("targetMC1",dep++);
tl.targetMC1._x = tl.targetMC1X;
tl.targetMC1._y = tl.targetMC1Y;
tl.targetMC1._alpha = 0;
previewMCL.loadClip(logoFileS,tl.targetMC1);
var fileRef:FileReference = new FileReference();
fRef.addListener(fRefLO);
function cancelUploadF(file:FileReference){
file.cancel();
tl.targetMC1._alpha = 100;
if(!tl.targetMC1.tf){
tl.targetMC1.createTextField("tf",dep++,0,0,tl.logoPreviewMC1._width,tl.logoPreviewMC1._h eight);
with(tl.targetMC1.tf){
multiline = true;
text = "Upload Excedes 1000kb Size Limit";
clearTimeout(removeTO);
removeTO = setTimeout(removeTF,4000);
function removeTF(){
tl.targetMC1.tf.removeTextField(); -
I think I will be loosing time, since in this forums there are hundreds of views per post though no answer, although as I am almost desperate I think I should try.
I'm creating a flash gallery (like in here: www.goaretouch.com/gallery) and I can't make it work propperly.
I have 3 kind of images: "thumbnails", "full size" and "full size B". The code is as follows:
import mx.transitions.Tween;
import mx.transitions.easing.*;
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<myImagesTotal; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = container_mc.createEmptyMovieClip(i, container_mc.getNextHighestDepth());
myThumb_mc._y = _root.thumb_height*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) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 50;
target.onRollOut = function() {
this._alpha = 100;
function callFullImage(myNumber) {
myURL = myImages[myNumber].attributes.full_url;
_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);
var preloader = new Object();
clipLoader.addListener(preloader);
fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
fullPreloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.onRelease = function() {
callBeforeImage(this._name);
fullClipLoader.loadClip("full_images/"+myURL+".jpg",fullImage_mc);
preloader.onLoadComplete=function(target){
target.onRelease=function(){
callBeforeImage(this._name);
function callBeforeImage(myNumber) {
myURL = myImages[myNumber].attributes.full_url;
_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);
var preloader = new Object();
clipLoader.addListener(preloader);
fullPreloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
fullPreloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.onRelease = function() {
callBeforeImage(this._name);
fullClipLoader.loadClip("full_images/"+myURL+"b.jpg",fullImage_mc);
preloader.onLoadComplete=function(target){
target.onRelease=function(){
callBeforeImage(this._name);
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._y += Math.cos(((mask_mc._ymouse)/mask_mc._height)*Math.PI)*15;
if (container_mc._y>mask_mc._y) {
container_mc._y = mask_mc._y;
if (container_mc._y<(mask_mc._y-(container_mc._height-mask_mc._height))) {
container_mc._y = mask_mc._y-(container_mc._height-mask_mc._height);
So, the first Full Size image loads perfectly, although the second gives the error as "not defined".
I'm starting to think I have an error in sintax and I should change this._name, but I'm not sure.
Any idea is truly appreciatedSounds like you want a MultiLoader style class.
I know David Stiller has one on his site.
http://www.quip.net/blog/2007/flash/actionscript-20/tracking-multiple-files-part2
I have one that is a variation to that approach. The link to
mine is in the comment history -under gwd - and yes I'm still
'working on it'. I'd recommend you read through David's article
(perhaps including part1 as well!). -
I want to start gallrey left to right.
I want to start gallrey left to right. my flash stage size is 1300px 700px.... please help
<?xml version="1.0" encoding="utf-8"?>
<gallery thumb_width="350" thumb_height="290">
<image thumb_url="shop.png" full_url="front.jpg" title="Mango Juice"/>
<image thumb_url="banner1.png" full_url="front.jpg" title="Mango Juice" />
<image thumb_url="shop2.png" full_url="front.jpg" title="Mango Juice"/>
</gallery>yes,,, i have a code which is-----
import mx.transitions.Tween;
import mx.transitions.Zoom.*;
import caurina.transitions.*;
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery.xml");
myGalleryXML.onLoad = function() {
_root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x=100;
_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();
function callThumbs() {
_root.createEmptyMovieClip("wall",_root.getNextHighestDepth());
wall._x = _root.gallery_x= 0;
wall._y = _root.gallery_y= 340;
wall.addEventListener(MouseEvent.CLICK);
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i=0; i<15; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height*i;
myThumb_mc._x = _root.thumb_position=-2000;
clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
preloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100;
and i also want to space between thumbs.. -
I want to call dynamically next 12 images by function on next button...
my script is ........
import mx.transitions.Tween;
import mx.transitions.Zoom.*;
import caurina.transitions.*;
var myGalleryXML = new XML();
myGalleryXML.ignoreWhite = true;
myGalleryXML.load("gallery24.xml");
myGalleryXML.onLoad = function() {
_root.gallery_x = myGalleryXML.firstChild.attributes.gallery_x=100;
_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();
function callThumbs() {
_root.createEmptyMovieClip("wall",_root.getNextHighestDepth());
wall._x = _root.gallery_x=0;
wall._y = _root.gallery_y=230;
wall.addEventListener(MouseEvent.CLICK);
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
/*myImagesTotal*/
for (i=0; i<6; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height*i;
myThumb_mc._x = _root.thumb_position=-3260+i*765;
clipLoader.loadClip("shop/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
preloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100;
for (i=6; i<12; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(i, wall.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height*i;
myThumb_mc._x = _root.thumb_position=-7367+i*765;
myThumb_mc._y = _root.thumb_position=180;
clipLoader.loadClip("banner/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
preloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100;
function callFullImage(myNumber) {
myURL = myImages[myNumber].attributes.full_url;
myTitle = myImages[myNumber].attributes.title;
_root.createEmptyMovieClip("ajit",_root.getNextHighestDepth());
ajit._x = _root.full_x=130;
ajit._y = _root.full_y=32;
/*by forum*/
_root.onEnterFrame = function() {
wall._alpha = 0;
if(_root._currentframe==2)
wall._alpha = 100;
this.gotoAndStop(21);
var fullClipLoader = new MovieClipLoader("ajit");
var fullPreloader = new Object();
fullClipLoader.addListener(fullPreloader);
fullPreloader.onLoadStart = function(target) {
target.createTextField("my_txt",ajit.getNextHighestDepth(),0,0,400,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) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.text = myTitle;
fullClipLoader.loadClip("full_images/"+myURL,ajit);
/*function for call next 12 images*/
var gapX:Number=5;
var nextX:Number = 13;
var loadNum:Number=13;
var preloader:Object={};
var clipLoader:MovieClipLoader=new MovieClipLoader();
clipLoader.addListener(preloader);
function loadnextF(){
thumbURL = myImages[loadNum].attributes.thumb_url;
myThumb_mc = wall.createEmptyMovieClip(loadNum, wall.getNextHighestDepth())
myThumb_mc._alpha=0;
clipLoader.loadClip("shop/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,10,10);
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._x = nextX;
nextX += target._width+gapX;
loadNum++;
if(loadNum<12){
loadnextF();
} else {
// all images loaded. do whatever.
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100;This appears to be the same issue as your other post, just less meaningful information. Please don't post twice for the same problem.
-
Function do work in only one frame
this function showing in all frame on stage....i want to it within a perticular frame
function callThumbs() {
_root.createEmptyMovieClip("sliderBox",_root.getNextHighestDepth());
sliderBox._x = _root.gallery_x=30;
sliderBox._y = _root.gallery_y=30;
sliderBox.addEventListener(MouseEvent.CLICK);
var clipLoader = new MovieClipLoader();
var preloader = new Object();
clipLoader.addListener(preloader);
for (i=0; i<myImagesTotal; i++) {
thumbURL = myImages[i].attributes.thumb_url;
myThumb_mc = sliderBox.createEmptyMovieClip(i, sliderBox.getNextHighestDepth());
myThumb_mc._x = _root.thumb_height*i;
clipLoader.loadClip("thumbs/"+thumbURL,myThumb_mc);
preloader.onLoadStart = function(target) {
target.createTextField("my_txt",target.getNextHighestDepth(),0,0,1,1);
target.my_txt.selectable = false;
preloader.onLoadProgress = function(target, loadedBytes, totalBytes) {
target.my_txt.text = Math.floor((loadedBytes/totalBytes)*100);
preloader.onLoadComplete = function(target) {
new Tween(target, "_alpha", Strong.easeOut, 0, 100, .5, true);
target.my_txt.removeTextField();
target.onRelease = function() {
callFullImage(this._name);
target.onRollOver = function() {
this._alpha = 100;
target.onRollOut = function() {
this._alpha = 100;In what way do you mean the function is in all frames? If you write the function on a layer of its own and only provide one frame for it, it will only exist in that one frame.
If you mean that what the function creates lives throughout the timeline, then that is because you are creating content dynamically without securing it to an object that has a home in the timeline. Dynamically created content does not have a home in the timeline unless you make it a opart of something that has been manually affixed to the timeline, like a movieclip.
So what you might try is to manually add an empty movieclip in the frame where this code is (on a separate layer) and assign it an instance name, let's say you name it "container". Then you can change the following line from...
_root.createEmptyMovieClip("sliderBox",_root.getNextHighestDepth());
to
container.createEmptyMovieClip("sliderBox",container.getNextHighestDepth());
and that should end up retsricting the dynamically created movieclip to the frame where the container is. If there is any other content being added to the _root, that too should be retargeted to the container.
Maybe you are looking for
-
Will Disabling IPv6 harm a Windows 8 or Server 2012 R2?
I have a script that was written for Windows 7 and server 2008. I would like to know if it was harm a Windows 8 or any build of Server 2012 box. If so, could you please list what it would harm. It was create to help with speed issues for an older net
-
Some images are showing with some red color ¿how do I return to original colors?
I`m using Mountain Lion and everything works right. Only some images are showing with a redish color. The first example is my cover photo in fb. When I click it, it returns to the original color. Anyone who has this problem and know how to fix it? Th
-
Batch conversion to replace the anamorphic flag in DV Stream
I have a bunch of .dv files form my video camera but, unfortunately, when migrating them from iMovie '06 to iMovie '08 (and switching to a brand new iMac in between) some of them have lost the anamorphic flag. This means that when I try and import th
-
Funny instance with maps in UK
I have a question. I have downloaded UK maps and set the phone to NOT use the network. Everything works great, but this one time, while using the maps application in a different city from the one I live I got a message saying 'network access needed'
-
My iPod touch's menu button literally sank in and now I am unable to use my iPod totally because I cannot press the menu button at all. Can Apple rectify this if I send it to a service center?