Addressing Different Dynamically Added Movieclips
Hi, I want to programme a sliding menu. All tutorials I found, so far, are either without AS 2.0 or in AS 3.0 or written OO, i.e. too advanced for my skills.
How it's built up: Background image and heading are imported from an xml file. Clicking on a menu item, the other menu items are sliding to the closest border.
The problem: How do I know on which mc I click; how do I tell the other mcs to move; and last but not least,the distance to the border is different, depending on to which border it switches - how to tell the mc?
I want to achieve sth similar to http://ecco.se
The code:
ActionScript Code: import gs.TweenMax;import gs.easing.*;var xmlContent = "content.xml";var xmlObj: XML;init();function init() { xmlObj = new XML(xmlContent); xmlObj.ignoreWhite = true; xmlObj.load(xmlContent); this.onEnterFrame = checkXMLprogress; }function checkXMLprogress() { var tmpBytesLoaded = xmlObj.getBytesLoaded(); var tmpBytesTotal = xmlObj.getBytesTotal(); if ((tmpBytesLoaded==tmpBytesTotal) && (tmpBytesTotal > 4)) { delete this.onEnterFrame; addContent(); } }function addContent() { var mContent = xmlObj.firstChild.firstChild.childNodes; for(var i=0; i<mContent.length; i++){ var instance = ["bild"]+i; this[instance] = this.attachMovie("imgContainer","img"+i, this.getNextHighestDepth()); //Create Textfield and add style this[instance].createTextField("heading_txt", this.getNextHighestDepth(), 700, 50, 200, 50); var mainHeading:TextFormat = new TextFormat(); mainHeading.bold = true; mainHeading.font = "ArialBlack36"; mainHeading.size = 26; mainHeading.color = 0xFFFFFF; mainHeading.align = "center"; this[instance].heading_txt.border = false; this[instance].heading_txt.multiline = true; this[instance].heading_txt.embedFonts = true; this[instance].heading_txt.background = true; this[instance].heading_txt.backgroundColor = 0x000000; this[instance].heading_txt.setNewTextFormat(mainHeading); //adds the background image this[instance].image.loadMovie(mContent[i].attributes.url); //adds the text into the textfield this[instance].heading_txt.text = mContent[i].attributes.heading; TweenMax.to(this[instance], 2, { _alpha:95, _x:(i*-40), ease:Expo.easeOut}); this[instance].onPress = function(){ if(this._x > -40) { this._x == 0; } else if(this._x < -39 && this._x > -500) { TweenMax.to(this, 2, { _alpha:95, _x:-Stage.width+(i*40), ease:Expo.easeOut}); } } }}
the project as download:sliding-menu.zip
Thanks.
ActionScript.org Forums > ActionScript Forums Group > ActionScript 2.0
Posted on: 11-19-2008, 10:27 AM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Target Dynamically Added Movieclips
I have a movieclip I'm trying to access that has been added to the stage dynamically. In fact there's 10 of them, added, using a for statement so, symbol + i, so depending what i is, that's how many get added to stage.
But I just get the error message:
Property symbol0 not found on Number and there is no default value.
PLEASE PLEASE HELP ME!!
Has this got anything to do with me having to use array notation rather than dot or do I need to use the getChildbyName?
Here is some of the relevant code I've got so far (its the bit at the bottom I'm having trouble with:
var myText:TextField = new TextField();
var myTextFormat = new TextFormat();
var externalReq:URLRequest;
var externalLoad:URLLoader;
var yourTitleArray:Array;
addChild(myText);
myText.text = "Waterloo to Anywhere";
myText.embedFonts = true;
myTextFormat.font = "Arial";
myTextFormat.size = 11;
myTextFormat.color = 0x000000;
myText.autoSize = TextFieldAutoSize.RIGHT;
myText.x = 425
myText.y = 428
myText.setTextFormat(myTextFormat);
runMe();
function runMe():void
{
var externalReq:URLRequest;
externalLoad = new URLLoader();
yourTitleArray = new Array();
externalLoad.load(new URLRequest("external.txt"));
externalLoad.addEventListener(Event.COMPLETE, textLoaded);
}
function textLoaded(event:Event):void
{
var stringOfWords:String = event.target.data;
yourTitleArray = stringOfWords.split(",");
trace(yourTitleArray[0])
for(var i=0;i < yourTitleArray.length; i++)
{
var mybuttonclass:Class = getDefinitionByName("buttona" + i) as Class;
var symbol:MovieClip = new mybuttonclass();
this.addChild(symbol);
symbol.name = "symbol" + i
symbol.x = i*10
symbol.y = 428
["symbol"+i].addEventListener(MouseEvent.MOUSE_DOWN, doSomething)
function doSomething(event:MouseEvent){
trace("please work")
}
}
}
}
Preserving Dynamically Added Movieclips
Hi,
Does anyone know how to preserve dynamically added movieclips when the user skips back to an earlier part of the movie? They stay on screen if the movement is forward, but if the user is allowed to jump back to an earlier part of the movie they disappear.
Any suggestions would be greatly appreciated!
Thanks,
Yellowfry
Adding/Moving Dynamically Added MovieClips To Display List
I'm stuck in my pursuit of transitioning from AS2 to AS3...
I have a little app that loads in xml and populates a list component on the stage. It is an elearning user interface in which the content is all loaded dynamically via the xml file. All of the content and title/subtitle is working fine. But the problem is with one last feature I want to add...
I have in the library a movieclip that contains just a simple orange box. I set it's linkage to 'ProgressIndicator'. I then, in the code, loop through the number of topics in the list component and for each topic in there I add an orange box (ie, ProgressIndicator) to the stage. This works fine. But the problem is I can't then change any properties of any of the progress indicators. What I want to do is, as the user progresses through the course, as they go through each topic I want to change the alpha property of the corresponding progress indicator on stage. Hopefully this makes sense. Here is a picture of what I'm aiming for:
Here is the code:
Code:
//Store total number of topics (zero-based so deduct 1 to get real num)
var totalTopics:Number = -1;
//Store reference to current progressIndicator
var currentProgress:MovieClip;
//render the number of topics on screen for user to see their progress during module
function renderProgressBar():void {
//Module progress - for each 'topic' in the listbox add an OrangeBox instance to the stage then highlight progress
//ref to right-hand side of status bar
var xStart:Number = 969;
var yStart:Number = 80;
//create and instantiate progressIndicators on stage based on totalTopics
for (var i:uint=0; i <= totalTopics; i++) {
var progressIndicator:MovieClip = new(ProgressIndicator);
//render the progressIndicators on stage
addChild(progressIndicator);
//change its name to correspond to topic number (zero based!)
progressIndicator.name = "progressIndicator"+i;
//position it
progressIndicator.x = xStart;
progressIndicator.y = yStart;
//add space for next indicator
xStart = xStart - 15;
}
//set first progressIndicator's fill to 'in progress' color of orange
currentProgress = this.progressIndicator0;
currentProgress.alpha = 0.5;
}
The progress indicators are rendering on stage fine and in the right place, but they are not referenceable via the 'progressIndicator0' or 'progressIndicator1' etc names that I *think* I've assigned them. Help!
Removing Dynamically Added Movie Clips Dynamically
I've been looking for a long time, but I cannot find anything on removing dynamically added movie clips. I really need to remove these movie clips dynamically since they are being placed by xml and I can never be sure how many clips will be added. Here is my code:
Code:
function callText(e:MouseEvent):void{
for (var k:Number = 0; k < my_total; k++){
var words_url = myXML.list[k].@videotitle;
var textRollDwn:ThumbText_mc = new ThumbText_mc();
galContainer.addChild(textRollDwn);
textRollDwn.name = "textRollDwn" + k;
textRollDwn.x = k%3*200;
textRollDwn.y = Math.floor(k/3)*150;
textRollDwn.words_txt.text = words_url;
textRollDwn.alpha = 50;
btnArray.push(textRollDwn)
}
}
Now this code works but I'm trying to write a function that when I roll off of this movieclip it goes away. I pushed them into an array thinking that I could also make them go away, but they wont. I tried:
Code:
for (var m:Number = 0; m < my_total; m++){
galContainer.removeChild(btnArray[m])
}
with this i get: The supplied DisplayObject must be a child of the caller
and this:
Code:
for (car m:Number = 0; m < my_total; m++){
galContainer.removeChild(["textRollDwn"] + m)
}
I get a type coercion failer saying that flash can't convert "textRollDwn0" to flash.display.DisplayObject. But that's what I named the movie clips...according to the name property anyway!
Thanks for help in advanced! Gosh I need it....
Addressing Duplicated Movieclips
Is there (or what is the) best method to address duplicated movieclips?
For example if you duplicate a number of movieclips (or attach or anything else) through a for loop and give them names like mc1, mc2, etc, how can you address them outside the loop? Especially if the number of times you duplicate the clips is read from a file which can change constantly.
Example - an image gallery where you just add the files to your xml and they show up in the gallery.
N00b Misery Addressing MovieClips
I'm trying to create a programmable display effect in which I control bunches of MovieClips nested in other MovieClips to display various combinations of seven letters in varying degrees of visual distress.
Using "dot" notation I can do what I need to by brute force, listing each and every one of them by using the instance name given to each letter's position, like so:Letter0.Aon1.alpha = 0;
Letter0.Aon2.alpha = 0;
Letter0.Bon1.alpha = 0;
Letter0.Bon2.alpha = 0;...Letter6.Zon2.alpha = 0;The nested clips go another level deeper, like so:Letter0.Aon1.wide4
Letter0.Aon1.wide8...As you can see, I tried to name the nested clips so it would be straightforward to address them programmatically. BUT, I am failing in my efforts to assemble strings and then change some property or another in the nested mc's .
In a more perfect world I would be able to create Arrays-lists of clips/Sprites to act upon and then iterate through the arrays merrily creating new Sprites and tweening changes as I go. That's kinda the point, right?
Can someone point me to a tutorial on the basics of dynamically constructing references to MovieClips or Sprites and then using them to change their properties? How does a string become a working reference to an existing MovieClip/Sprite?
TIA
Dynamically Addressing Movieclip
i have this on my buttons (movieclips):
on (rollOver) {
name=this._name;
path=this._target;
_root.push (name, path);
}
on the timeline i have the function:
_root.push = function (name, path){
trace(name);
name.gotoAndPlay("over");
}
on rollOver i want to dynamically pass a movieclips name to a function which controls that the movieclip should goto its frame named "over", but i cant get the adressing to work.
if i trace the variable "name" in the example it gives me the moviename correctly. so i guess my syntax is wrong.
the function doesnt work with the path variable either.
i know this might be a stupid question. dont mind me, i'm a noob...
thanks for your help,
antronics
Dynamically Addressing Movieclip
i have this on my buttons (movieclips):
on (rollOver) {
name=this._name;
path=this._target;
_root.push (name, path);
}
on the timeline i have the function:
_root.push = function (name, path){
trace(name);
name.gotoAndPlay("over");
}
on rollOver i want to dynamically pass a movieclips name to a function which controls that the movieclip should goto its frame named "over", but i cant get the adressing to work.
if i trace the variable "name" in the example it gives me the moviename correctly. so i guess my syntax is wrong.
the function doesnt work with the path variable either.
i know this might be a stupid question. dont mind me, i'm a noob...
thanks for your help,
dual
Dynamically Addressing Movieclip
i have this on my buttons (movieclips):
on (rollOver) {
name=this._name;
path=this._target;
_root.push (name, path);
}
on the timeline i have the function:
_root.push = function (name, path){
trace(name);
name.gotoAndPlay("over");
}
on rollOver i want to dynamically pass a movieclips name to a function which controls that the movieclip should goto its frame named "over", but i cant get the adressing to work.
if i trace the variable "name" in the example it gives me the moviename correctly. so i guess my syntax is wrong.
the function doesnt work with the path variable either.
i know this might be a stupid question. dont mind me, i'm a noob...
thanks for your help,
dual
Dynamically Created Mc + Addressing / Event
Hi guys,
does anyone have a tip on how to "bind" events to dynamically created movieclips ?
Code:
public function createClip():Void {
var _images:ImageElement;
var x:Number = 0;
var y:Number = 0;
var _cc:Number = 0;
for (var j:Number = 0; j < _objectArray.length; j++) {
_images = _objectArray[j];
if (_images.get_image_page() == _cpage) {
rootMC.createEmptyMovieClip("images_"+_cc,_cc);
loadMovie(thumb_path + "/" + _images.get_image_thumb(),["images_"+_cc]);
setProperty("images_"+_cc,_x,x);
setProperty("images_"+_cc,_y,y);
["images_"+_cc].onPress = function() {
trace("CLICKED!");
}
_cc++;
}
}
}
Code:
["images_"+_cc].onPress = function() {
trace ("Blah");
}
gives me the following error :
Code:
Unexpected '.' encountered
["images_"+_cc].onPress = function() {
does anyone know how to bind (correct addressing syntax) the onPress function to the dynamically created movieclips ?
thx,
bustaa
Dynamically Created Mc + Addressing / Event
Hi guys,
does anyone have a tip on how to "bind" events to dynamically created movieclips ?
Code:
public function createClip():Void {
var _images:ImageElement;
var x:Number = 0;
var y:Number = 0;
var _cc:Number = 0;
for (var j:Number = 0; j < _objectArray.length; j++) {
_images = _objectArray[j];
if (_images.get_image_page() == _cpage) {
rootMC.createEmptyMovieClip("images_"+_cc,_cc);
loadMovie(thumb_path + "/" + _images.get_image_thumb(),["images_"+_cc]);
setProperty("images_"+_cc,_x,x);
setProperty("images_"+_cc,_y,y);
["images_"+_cc].onPress = function() {
trace("CLICKED!");
}
_cc++;
}
}
}
Code:
["images_"+_cc].onPress = function() {
trace ("Blah");
}
gives me the following error :
Code:
Unexpected '.' encountered
["images_"+_cc].onPress = function() {
does anyone know how to bind (correct addressing syntax) the onPress function to the dynamically created movieclips ?
thx,
bustaa
Deleting MovieClips Added With A Loop
Hi all,
I have a few MovieClips coming in from an XML file, and they're being added to the stage via a loops, like this:
Code:
var text_name:Array = [];
for (var i:Number = 0; i < city_array.length; i++) {
var m = attachMovie("brew_info", "brew_button" + setDepth(), setDepth());
m._x = loc_x[i].firstChild.nodeValue;
m._y = loc_y[i].firstChild.nodeValue;
m.text = city_array[i].firstChild.nodeValue;
/* m._alpha = 0; */
text_name.push(m);
trace(m);
var buttonURL = url[i].firstChild.nodeValue;
m.brewButton.onRelease = function():Void {
getURL(buttonURL);
}
}
My problem is that later on, I'd like to remove the MovieClips named 'brew_button', but since they are all being added with a different value appended onto them , I'm not sure what to do to remove those MovieClips.
Any help with this would be greatly appreciated. Thanks!
Addressing Dynamically Named, Duplicated Clips
I'm having a problem addressing duplicated clips and setting their ._x properties. I know how to do it when the clips are on the main stage, but when they're in another MC I get messed up.
I have a MC on my main stage called slider. Inside it, during a for loop, I duplicate a MC called thumbTemplate, like so:
for(i=1; i <= numImages; i++){ // numImages is defined elsewhere...
// make names for the duplicates
slider.thumbNailName = "thumbNail" + i;
//make the duplicates
duplicateMovieClip(slider.thumbTemplate, slider.thumbNailName, i);
That works fine. Then I set a variable to determine placement of each duplicated clip:
var xLocationOfNewThumb = //do various calculations
That works fine, too. The problem is how do I address those dynamically named clips so I can set their ._x properties. For clips on the main timeline,this would work:
this[thumbNailName]._x = xLocationOfNewThumb;
But I can't figure out what works for clips in the slider clip, such as:
this[slider[thumbNailName]]._x , or
slider[this[thumbnail]]._x , or various other attempts.
Any help is appreciated.
[CS3] Addressing Dynamically Created Instances Individually
When an asset is created in the Flash authoring environment, the instance can be given a name using the Properties tab edit field. It's then simple to target that instance using ActionScript, e.g.:
myClip_mc.alpha = 50;
Using ActionScript 2.0, I used the following code to specify a movie clip to remove:
myListener.onMouseMove = function() {
if (dragging == true) {
attachMovie("squareturn", "squareturn1" + level + "_mc", level);
eval("squareturn1" + level + "_mc")._x = _xmouse;
eval("squareturn1" + level + "_mc")._y = _ymouse;
removeMovieClip("squareturn1" + (level - 100) + "_mc");
level += 1;
}
};
I used the unique level of the movie clip to generate its name and later identify it for the removeMovieClip method. My question is, is there a better way to do this in ActionScript 3.0? (I know that the methods and syntax are different in 3.0.)
My example isn't very good, since it just removes any movie clip that is 100 levels "down" from the latest clip. I'm looking for a general purpose way to act on an individual movie clip that has been dynamically instantiated in ActionScript 3.0. What is the easiest way to give a dynamically instantiated movie clip a unique identity so it can be manipulated?
I know that I can use "this" or "target" to identify something that's been clicked on, but I want something more flexible. Maybe everything can be done using these methods and I'm just not used to thinking in 3.0 yet.
Any suggestions would be highly appreciated.
Thanks!
Added Child's Movieclips Jumping To Last Frame
AS3 is currently driving me insane!
I orignally had a movieclip/class being added via the contructor of main document class. And this worked fine.
I then changed my code so this movieclip/class was added to the stage when a button was pressed. But now all the sub movieclips in the added movieclip/class jump to the last frame!
Anyone know why this is? I dont quite get it since I havent altered any code inside the movieclip/class that is being added. The only difference is it was being called via the constructor vs an event listener.
Addressing Layers Dynamically For Preloading Multiple Movies
I'm building a portfolio site with a row of images that can be clicked to view the full-size image. Because the full-size images are so big, I'm saving each of them as a separate swf, then preloading them into layers 1 - 18. Then, when the user clicks a thumbnail, I simply make the appropriate layer visible and run it's animation. I have that worked out.
Problem...
I need to make my preloader load the images into the appropriate layers one at a time, in order, rather than just starting them all loading at once.
The concept is,
1: test to see if image one has any bytes loaded yet
2: If not, then start loading it
if(thelevel.getBytesLoaded() == null && thepic < 19){
loadMovieNum("http://www.mamasutra.com/rolston/pics/" + thepic + ".swf", thepic);
}else if(thepic == 19){
gotoAndStop(5);
}
3: wait until it's finished and start loading number 2
4: etc
I would prefer to do this with a loop, but can't figure out how to test for completion, because I can't figure out how to write the GetBytedLoaded statement using a variable.
Here's what I tried...
if(thelevel.getBytesLoaded() >= thelevel.getBytesTotal()){
//once this one's loaded, go to the next
thepic ++;
thelevel = "_level" + thepic;
gotoAndPlay(2);
}else{
//trace(thelevel + " loaded = " + thelevel.getBytesLoaded());
prevFrame();
}
Figuring I can test by level number, but this doesn't work. How can I write that statement to test when each one is finished loading?
Thanks
rpossum
Remove Dynamically-Added .swf
Hi folks. I have an AS3 app that allows users to pick from a menu of AS2 .swf movies to load into a MovieClip. Users are allowed click to view one movie, but if they change their mind and click a different clip, it should unload/delete/remove the .swf that's currently playing so that the user don't have overlapping movies playing at once. If someone can help me to accomplish this, I would appreciate it! Here's what I've come up with, but it doesn't work:
try {
//(see the load code below) If a .swf is already loaded, remove it
var clipToDelete:Loader = Loader(parentClip.getChildAt(0));
parentClip.removeChild(clipToDelete);
clipToDelete = null;
}
catch (e) {
}
//Load a .swf into parentClip
var loader:Loader = new Loader();
parentClip.addChild(loader);
loader.addEventListener(Event.ADDED, parentClipOnLoad);
loader.load(new URLRequest("someMovie.swf");
Thanks!
Andy
Accessing Child MovieClips Added On 2nd Frame Of A MovieClip
I am trying to build a simple dropdown menu but am running into some issues attaching event listeners to the nested movieclips for the submenu items. Here is what I have done:
Created a movieclip that on frame 1 only shows a one-row title, such as "FILE". On the second frame I added additional MovieClips below the FILE named "SAVE" and "EXIT". I gave these 2nd frame children an instance name of subFileSave and subFileExit. I placed the completed MovieClip FILE on the stage and gave it an instance name of menuFile. The individual movieclips are exported for actionscript with 1st frame option.
Now in the main actionscript associated with the fla, I have the following code to control the submenu dropdown. (typing from memory since I am not at home with the code):
menuFile.addEventListener(MouseEvent.MOUSE_OVER, menuMouseOver);
public function menuMouseOver(e:MouseEvent):void
{
menuFile.gotoAndStop(2);
menuFile.subFileSave.addEventListener(MouseEvent.CLICK, gotoFileSave);
menuFile.subFileExit.addEventListener(MouseEvent.CLICK, gotoFileExit);
}
I am getting an runtime error when attaching the event handlers for the submenus. At what time are the menuFile.subFileSave variables properly set so that I can setup the event handlers? Could someone explain to me how nested movieclips are handled if added after the 1st frame of a movieclip? Any help much appreciated, I dug through many forums and the adobe help texts to figure this out.
I am wondering if I have to wait after calling the gotoAndStop function before the properties for the submenu items are properly set, but cannot figure out how.
Edited: 04/21/2008 at 06:21:35 AM by rsentgerath
Removing Old Dynamically Added Objects...
Here is the situation. I am using flash remoting and based on the information I get back my function decides how many buttons I am going to display (in this case for functionality the buttons are actually movie clips). Once it gets the results it adds the movie clips and assigns their label values based on that data using the _root.attachMovie() function. Here is my problem, I need a good way that once these buttons are clicked and the movie advances to the next frame all the buttons added are removed... I have tried storing them in a global array and removing them on the next frame but once i add them to array I just get undefined back.
How To Bring My Dynamically Added Movie At Top Of All Other
Hi,
I am build a designer studio kind of application. in this I am able to allow user to upload images. Now, I am working on giving a option to user such that he can Write any text on area. for this what I did is that I put a check on mouseup for _root, if _xmouse and _ymouse coordinates are within my box, it draw Textfield there using _root.createTextField function. It all works fine and it create Textfield as well. now what I did, I use Selection.setfocus("newtextfield"); in my code to set focus in text field as soon as it is create. i.e. next line after createTextfield.
but still I am not able to set focus on text field, nor I can get focus on it. Though I can see its border and other thing perfectly.
Also, where I am drawing this text box just has one "Rectangle tool" drawn Shape through Flash toolbox nothing else
Can any one please help me in this. I am totally new to flash, and its just one week I am working on ActionScript 2.0 (Flash 8 Professional version).
Please
Cannot Click Dynamically Added Button
I have a movie clip and it is just a rectangle. I exported it for actionscript and dynamically added it like so:
Code:
var bet:foldBtn = new foldBtn;
bet.x = 330;
bet.y = 250;
bet.buttonMode = true;
bet.addEventListener(MouseEvent.CLICK, betClicked)
addChild(bet);
function betClicked(event:Event):void
{
trace("Clicked");
}
I cannot click this button. Please help.
ScrollPane And Other Dynamically Added Components
Hi All,
I'm trying to add a series of 10 ComboBoxes in a ScrollPane one below the other. Though the height of the each ComboBox is reported as 22 the content mc shows a height of 298 (9*22 + 100). After populating the ScrollPane with 10 ComboBoxes, the ScrollPane shows empty space below the last ComboBox. I guess somehow these components are retaining their default height (100) when added dynamically.
Sample code at the end.
The result is the same when adding components like Button, CheckBox, RadioButton.
Any ideas what could be possible wrong? How do I ensure the ScrollPane's content MovieClip's height is reported as 220 (10*22) with exact fitting ComboBoxes in the ScrollPane?
Thanks in advance.
Attach Code
import fl.controls.*;
import flash.display.MovieClip;
//
function myFunc() {
var mc:MovieClip = new MovieClip();
my_sp.source = mc;
for (var i=0; i<10; i++) {
var cb = new ComboBox();
mc.addChild(cb);
cb.y=i*cb.height;
}
my_sp.refreshPane();
trace(mc.height);
}
myFunc();
Moving A Clip Added Dynamically
Maybe this will be a simple question to answer.
I'm parsing an XML file and attaching a movie clip to the stage multiple times with data from the XML file. That part works ok.
What I would like is for each clip that was attached to scroll slowly.
How do I add the onclipevent code to each instance of that movie clip?
I tried adding it to the movie clip in the library, but I still get the error about it having to be a movie clip. Does all of this make sense?
Moving A Dynamically Added MC On A HitTestPoint
Hi,
I was reading through one of the tutorials from kirupa found here http://www.kirupa.com/developer/flas...es_AS3_pg2.htm
I got a lot out of it =]
but when i tried modifying the code to add a hitTest on it, it became "weird"
here is my .as file
package {
import flash.display.*;
import flash.events.*;
import flash.geom.Point;
public class Sq extends MovieClip {
var radians =0;
var speed =0;
var radius =0;
var randomValue=0;
public function Sq() {
speed =.01+.5*Math.random();
radius =2+10*Math.random();
randomValue= Math.random()*1;
this.x = Math.random()*550;
this.y = Math.random()*400;
this.rotation = Math.random()*360;
this.scaleX = this.scaleY = randomValue;
this.alpha = 1-randomValue;
this.addEventListener(Event.ENTER_FRAME, rotateSq);
}
function rotateSq(e:Event) {
if (this.hitTestPoint(mouseX,mouseY,true)) {
radians+=speed;
//trace("test works");
this.x+=Math.round(radius*Math.cos(radians));
this.y+=Math.round(radius*Math.sin(radians));
}else{
trace("nope");
}
}
}
}
the effect i'm trying to accomplish is when the user rolls over one of the MC's added
by the following function inside the .fla
function AddSq() {
for (var i:int =0; i<50; i++) {
var newSq:Sq = new Sq();
this.addChild(newSq);
}
}
AddSq();
is that the MC(which is a square) starts moving in a circle. but it seems that the hit area is in a different location and the square is in another.
is there something i'm doing wrong?
Thanks!
Dynamically Added Streaming Sound Not Playing
i'm working with flashMX and is currently having problems with getting a dynamically added sound to play.
onClipEvent (load) {
s = new Sound();
s.loadSound(_parent.exturl, true);
}
this code is not being loaded until it is being called from another movieclip wich does a gotoAndPlay("loadmusic")....the reference in the variable exturl comes from this other movieclip...
i have checked that the path in the exturl is correct, the file referenced is located on another server, could that be the problem?...it looks something like this... : http://www.anotherserver.com/mymp3.mp3/play
if i play the movie on my own computer, with reference to an mp3 on my own machine everything works perfect..
let me also mention that the sound examples on page 18 in the tutorial Flash MX Sound Object Tutorial Flash MX Sound Object Tutorial does not work either.
and yes i do have the latest player, flashplayer 7
pls...any comment or help is appreciated
Actionscript On Dynamically Added Movie Clips
I had a movieclip with lots of actionscript on it that worked perfectly. I decided to allow the user to choose how many of these movie clips there are. I can add them dynamically but none of the actionscript goes with it. Is there an easy way to keep it or do I have to modify the code a lot? Thanks.
GotoAndStop Does Not Work On Dynamically Added Movieclip
I'm making a game and I've run into a very strange problem. one of my symbols has a function in it that tells it to go to its second frame. this function is called when the symbol touches a missile fired by the player. when i physically add one of these symbol to the stage, it works fine. however, when i add it dynamically, it does not work. to make things more weird, i added a trace function before and after the gotoAndStop, and both traces appear when either the dynamically or physically added clips are hit--but the latter clip just won't go to its second frame. i made a new flash file and isolated the code that deals with this issue so you won't have to slog through all the unrelated code. could someone please take a look and tell me what's wrong?
I have both flash MX 2004 and flash 8. I saved the .fla as MX 2004.
How To Find Out The Movieclip Instance Name When Added Dynamically
I have created a movieclip with a text box and used that movieclip to add dynamically using the Action script.
According to the number of nodes present in the XML, i am adding the movieclip one by one. I need to know the movieclip name which is clicked. Is there any way to find out that. I have used _name but it is returning the last movieclip name which is added (itemClip3). I need the exact movieclip name which is clicked.
I have pasted the code below. anyone pls help me.
ACTION SCRIPT
--------------
menuXml = new XML();
menuXml.ignoreWhite = true;
menuXml.onLoad = function(success) {
if (success) {
menuItem = this.firstChild.childNodes;
for (var i = 0; i<menuItem.length; i++) {
item = _root.attachMovie("itemClip", "itemClip"+i, i);
item._x = 100;
item._y = 30*i;
item.itemLabel.text = menuItem[i].attributes.name;
item.myUrl = menuItem[i].attributes.url;
item.onRelease = function() {
/:name = item._ymouse;
for(var j=0; j<menuItem.length; j++) {
var strItemName = "";
strItemName = "_root.itemClip" + j;
eval(strItemName).removeMovieClip();
}
gotoAndPlay(144);
};
}
}
};
menuXml.load("xml/projects.xml");
XML FILE
---------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE projects SYSTEM "Projects.dtd">
<projects>
<project name="test1" folder="test1">
<menufilename>mnustars.xml</menufilename>
<templatename>template_stars.xml</templatename>
</project>
<project name="test2" folder="test2">
<menufilename>mnucrm.xml</menufilename>
<templatename>template2.xml</templatename>
</project>
</projects>
Assigning Actions To Buttons Added Dynamically.
Hello,
here is my problem, I am adding buttons to the stage run-time and for the life of my I can't get actions in them them to work. Now when i click the button nothing happens. Am I missing something??
Attach Code
for (x=0; x < someNum; x++)
{
// name and create the button...
btnName = "adButton_" + x;
this.attachMovie("btn", btnName, this.getNextHighestDepth());
// get button...
adButton = eval(btnName);
// position button...
this.adButton._x =somePosX;
this.adButton._y =somePosY;
this.adButton._width =someWidth;
// set and add actions for button...
set( "myButtonListener_" + x, new Object());
set( "myButtonListener_" + x + ".click", function(){ trace("test");});
this.adButton.addEventListener("click", "myButtonListener_" + x);
}
ScrollPane Issue With Dynamically Added Components
Hi All,
I'm trying to add a series of 10 ComboBoxes in a ScrollPane one below the other. Though the height of the each ComboBox is reported as 22 the content mc shows a height of 298 (9*22 + 100). After populating the ScrollPane with 10 ComboBoxes, the ScrollPane shows empty space below the last ComboBox. I guess somehow these components are retaining their default height (100) when added dynamically.
Sample code at the end.
The result is the same when adding components like Button, CheckBox, RadioButton.
Any ideas what could be possible wrong? How do I ensure the ScrollPane's content MovieClip's height is reported as 220 (10*22) with exact fitting ComboBoxes in the ScrollPane?
And yes, the required components are added in the library. The problem is not that they are not displaying.. They are all displaying fine... just that the hight of the ScrollPane's content is more than the actual content.
Attach Code
import fl.controls.*;
import flash.display.MovieClip;
//
function addComponents() {
var mc:MovieClip = new MovieClip();
my_sp.source = mc;
for (var i=0; i<10; i++) {
var cb = new ComboBox();
mc.addChild(cb);
cb.y=i*cb.height;
}
my_sp.refreshPane();
trace(mc.height);
}
addComponents();
Scrollpane With Dynamically Added MCs Not Showing All Content
I'm adding movieclips into a scrollpane. I'm tiling them vertically, so that you can scroll up and down to view more of them. It all works until I add a lot of clips, and then it doesn't scroll all the way down. Any ideas why it would do this and how to fix it? Thanks.
Dave
Remove Child From Dynamically Added Sprite
Code:
function LoadProjects():void {
var xmlLoader:URLLoader = new URLLoader();
var xmlData:XML = new XML();
var child:MovieClip;
var thumbLoader:Loader;
var holder_mc:Sprite = new Sprite();//thumbs load into
//var holder_mc:MovieClip; = new MovieClip;();//thumbs load into
var slideThumb:String
var slideFull:String
var slideName:String
xmlLoader.addEventListener(Event.COMPLETE, LoadXML);
xmlLoader.load(new URLRequest("menu.xml"));
function LoadXML(e:Event):void {
xmlData = new XML(e.target.data);
ParseImages(xmlData);
}
function ParseImages(imageInput:XML):void {
var imageList:XMLList = imageInput.sub;
for (var i:int = 0; i < imageList.length(); i++){
slideThumb=imageInput.sub.attribute("slide")[i];
slideFull=imageInput.sub.attribute("full")[i];
slideName=imageInput.sub.attribute("name")[i];
thumbLoader = new Loader();
thumbLoader.load(new URLRequest(String(slideThumb)));//access the thumbnails
thumbLoader.name = "thumb_"+i;
child = new MovieClip();
child.addChild(thumbLoader);
child.x=(125*i);
child.y=100;
child.addEventListener(MouseEvent.MOUSE_UP,onClick);
child.buttonMode = true;
child.name = "child_"+i;
holder_mc.addChild(child);
}
main_content.addChild(holder_mc);
}
var holder_mask:Shape = new Shape();
holder_mask.graphics.lineStyle(1, 0x000000);
holder_mask.graphics.beginFill(0xff0000);
holder_mask.graphics.drawRect(-395, 100, 790, 75);
holder_mask.graphics.endFill();
main_content.addChild(holder_mask);
holder_mc.mask = holder_mask;
holder_mc.name = "holder_mc";
function onClick(event:MouseEvent):void {
}
function addScrollListeners():void {
holder_mc.addEventListener(MouseEvent.ROLL_OVER,toggleScroll);
holder_mask.addEventListener(Event.ENTER_FRAME, getThisWidth);
}
function getThisWidth():void {
if(holder_mc.width > 0) {holder_mask.removeEventListener(Event.ENTER_FRAME, getThisWidth)
holder_mc.x=-1*(holder_mc.width/2)
}
}
function toggleScroll(event:MouseEvent):void {
holder_mc.addEventListener(Event.ENTER_FRAME, scrollThumbs);
}
function scrollThumbs(event:Event):void {
if(mouseX > 790/2) {
holder_mc.x -=5;
if(holder_mc.x <=790/2-holder_mc.width){
holder_mc.x = 790/2-holder_mc.width;
}
}
if(mouseX < 790/2) {
holder_mc.x +=5;
790-holder_mc.width;
if(holder_mc.x>=((790/2)*-1)){
holder_mc.x =((790/2)*-1);
}
}
}
addScrollListeners();
trace(main_content.holder_mc.numChildren);
/*if (main_content.holder_mc.numChildren > 0) {
trace(main_content.holder_mc.numChildren);
}
*/
}
I am trying to figure out how to remove the children added by the xml file.
Once I can detect the movies I think I should just be able to remove them with removeChild etc...
Its not pretty but its how I got it to work. I neeeeeed to buy a as3 book, coming from mx this is tragic.
Here is the error
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at home6_fla::MainTimeline/LoadProjects()
at MethodInfo-173()
Which I guess means that its empty. It loads fine etc, but as I change between screens it holds the children of that movie. I figure once I can get this figured out I can go back and clean up the rest of the mess.
Since I can hardly see my screen anymore I apologize in advance for any typos
Scrollpane With Dynamically Added MCs Not Showing All Content
I'm adding movieclips into a scrollpane. I'm tiling them vertically, so that you can scroll up and down to view more of them. It all works until I add a lot of clips, and then it doesn't scroll all the way down. Any ideas why it would do this and how to fix it? Thanks.
Dave
Adding/Referencing Dynamically Added Components
Is it possible to use XML as a source document to build dynamically generated components? As an example, if the XML specified to add a checkbox, then a checkbox component would be added to a pre-determined location.
What I am not sure is if the selected content for each component could then be referenced.
In other words, imagine that my XML has indicated that a check box, 3 radio buttons, and a list box should be added to the flash application. As the XML data is read into flash, each element value calls a different custom function (i.e. myCreateCheckBox).
How then do I refer to this component? Is it even possible? I was thinking it might be possible if I added the component object to an array of that component type.
Any thoughts on how I might approach this would be appreciated.
Thanks.
How To Get Handle To Control De Dynamically Added Movie Clip
hi everybody,
I'm using Flash mx 2004. And i'm supposed to make a calendar which have some funcitonalaity like when i'm clicked one date its color field to be changed according to the conditions apply.
Now my query is i'm dynamically adding each date as a MC from Lib., for a month (its about 35 dy. MC i.e 7 x 5weeks)
Can i get handle or control the which movie clip was clicked to change the properties. like color and text alpha etc.
It could be a silly thing. But i'm a beginner pls help me. I'm stuck upon with these things.
Thanx in adv.
How To Get Handle To Control De Dynamically Added Movie Clips
hi everybody,
I'm using Flash mx 2004. And i'm supposed to make a calendar which have some funcitonalaity like when i'm clicked one date its color field to be changed according to the conditions apply.
Now my query is i'm dynamically adding each date as a MC from Lib., for a month (its about 35 dy. MC i.e 7 x 5weeks)
Can i get handle or control the which movie clip was clicked to change the properties. like color and text alpha etc.
It could be a silly thing. But i'm a beginner pls help me. I'm stuck upon with these things.
Thanx in adv.
How Do I Attach A Function To A Movie Dynamically Added To Stage Through AttachMovie?
I am using the following code to attach a movie from the Library called the Display, in each instance I am loading a thumbnail. I would like to add functions to each thumbnail so that it may respond to user events such as press and rollover
any ideas? my code is below.
photos = ["photo-01.jpg","photo-02.jpg","photo-03.jpg","photo-04.jpg","photo-05.jpg","photo-06.jpg","photo-07.jpg","photo-08.jpg","photo-09.jpg","photo-10.jpg"]
countRows = 0;
countColumns = 0;
for(i=0;i < photos.length ;i++){
dname = "photo" + i;
_root.attachMovie("theDisplay",dname,(i+1),);
_root[dname]._x = (100 * countColumns)+5;
_root[dname]._y = (100 * countRows)+5;
thatNum = 14+i;
_root[dname].loadMovie(photos[i])
_root[dname]._xscale = 99;
_root[dname]._yscale = 99;
//the line below is giving me the problem.
_root[dname].onPress = function(){trace("function works!")};
countColumns ++;
if(countColumns == 5){countRows ++;countColumns = 0}
}
Dynamically Loading Images Into Dynamically Loaded MovieClips
I'm read through many of the posts and found several on this topic, none, however, that addressed all that I need addressed. I've tried several of the suggestions but so far nothing seems to work.
What I want to do is alter the width of images loaded dynamically into a dynamically loaded set of movieclips. all of the widths of the images are different, but i want them set to the same width. The width seems to stay at zero, however, and I cannot seem to change it.
Here is my code:
for (var i:Number = 0; i < 8; i++){
var mc = attachMovie("rect_mc", "r" + i, this.getNextHighestDepth());
mc._x = 90 + (i * (mc._width+5));
mc._y = 375;
mc.img_txt.text = "image" + (i+1);
mc.img_mc.loadMovie("myPic" + (i+1) + ".jpg");
mc.img_mc._xscale = mc.img_mc._yscale = (50/mc.img_mc._width) * 100;
};
The last line is the one that does not function properly.
I'd appreciate any help anyone can provide. thanks.
Changing Font And Size Of Text Added To Dynamically Created Text Fields
Whew.. That long-winded subject line pretty much covers it.
Link
In the galleries, I have text I am adding to a movieClip. I have been able to add the description text, change it's colour, but the font and size are not responding. I'm using FlashMX2004. Can anyone show me what I'm doing wrong? Here's the pertinent code:
_parent.Gallery.createTextField(["Txt_" + CVar], _parent.LevelCount + 1000, 175, _parent.EntryY, 325, 110);
_parent.Gallery["Txt_" + CVar].font = "Arial";
_parent.Gallery["Txt_" + CVar].text = _parent.Description[AVar];
_parent.Gallery["Txt_" + CVar].textColor = 0xFFFFFF;
_parent.Gallery["Txt_" + CVar].textSize = 25;
Thanks so much!
Generating MovieClips Dynamically
I thougth this was simple: I want an infinite supply of certain draggable items, that is i want to make duplicates of them each time they are dragged away from their original position. I have used the method duplicateMovieClip, wich creates a duplicate of the movieclip, gives it a new name and places it on a new depth.
But i can´t make it work!
here´s my code:
onClipEvent (enterFrame) {
i = 1;
this.onStartDrag = function () {
newMat = mata_mc.duplicateMovieClip(matCopy, +i);
newMat._x = mata_mc._x;
newMat._y = mata_mc._y;
}
}
should I place it on a frame or on the MC?
MOving Movieclips Dynamically
Hi all. This is my first posting here, so Im new….and would greatly appreciate a little help in a problem I will do my best to explain.
I found a nifty piece of actionscript (on the net, distributed freely) that makes a movieclip instance move into a position dynamically, with a fade, so it fades in as well as moves. This function was named MoveTo, as you see below the function is set up with its parameters…(by the way, Im using FlashMX 2004)
function MoveTo (clip, fadeType, xTo, yTo, speed)
{
clip.onEnterFrame = function ()
{
this._x += (xTo - this._x) * speed;
this._y += (yTo - this._y) * speed;
if (fadeType == "in" && this._alpha < 100)
{
this._alpha += 5;
}
else if (fadeType == "out" && this._alpha > 10)
{
this._alpha -= 5;
}
};
}
Then later on, on some frames further along (after you’ve clicked a button to go there) it activates the function, and moves a navigational panel specific to a page, in. In the panel is a thumbnail setup for viewing images. On that frame it arrives at (on the _root), to activate the function, is this piece of code for moving the panel in…
nav_bfh.onEnterFrame = function() {
MoveTo(nav_bfh, "in", 73.2, 385, 0.3);
MoveTo(nav_dt, "in", -47, -329, 0.3);
MoveTo(nav_saw, "in", -47, -329, 0.3);
MoveTo(nav_x, "in", -47, -329, 0.3);
MoveTo(nav_sau, "in", -47, -329, 0.3);
MoveTo(nav_per, "in", -47, -329, 0.3);
MoveTo(nav_res, "in", -47, -329, 0.3);
MoveTo(nav_har, "in", -47, -329, 0.3);
MoveTo(nav_ft, "in", -47, -329, 0.3);
MoveTo(nav_and, "in", -47, -329, 0.3);
MoveTo(nav_mod, "in", -47, -329, 0.3);
MoveTo(nav_bag, "in", -47, -329, 0.3);
MoveTo(nav_oma, "in", -47, -329, 0.3);
MoveTo(nav_gra, "in", -47, -329, 0.3);
MoveTo(nav_mau, "in", -47, -329, 0.3);
MoveTo(nav_umn, "in", -47, -329, 0.3);
};
Those little “nav_...” things are the panel instance names. As you can see, there are quite a few of them. If you compare what is in the brackets of each line, to this piece of code…
function MoveTo (clip, fadeType, xTo, yTo, speed)
…from the original setup of the function…you see references to a clip (the “nav_...” clips) and then an “in” for fadeType…as in fade in (you can also set it to fade “out” as well) some x and y references and a speed. Quite straight forward (though it should be mentioned I am not really a programmer and could not write this stuff out of my head)
I like this function, and it is really useful. So I started trying to get a little more clever with it. As I mentioned it is a pic viewing device I am using this on. And so wanted to give the user an option to play through the pics instead of just clicking for them.
The pics load dynamically into a movieclip on the _root called “bg_picloader” when you click a button inside the nav_panel.
There is also a button to play through them. What happens is when you click the button it moves the playhead out of the 1st frame within the movieclip “nav_...” and at intervals I have keyframes which load a different pic into “_root.bg_picloader” and it works. But I want the pics to fade in each time.
So using that earlier piece of code I set up a new function, which looks much the same, only I left out the movement aspects (the xTo, yTo and speed)…in order not to confuse Flash, I changed the name of the function to FadePic… I also changed the word fadeType to fadeHype, (though either way that doesn’t seem to make a diff)
function FadePic (clip, fadeHype)
{
clip.onEnterFrame = function ()
{
if (fadeHype == "in" && this._alpha < 100)
{
this._alpha += 5;
}
else if (fadeHype == "out" && this._alpha > 10)
{
this._alpha -= 5;
}
};
}
Then, within the “nav_...” movieclip, along its timeline, when it calls in a new pic to load (playthrough style) I have placed this piece of code to fade it in…
loadMovie("X_01.jpg", "_root.bg_picloader");
_root.bg_picloader.onEnterFrame = function() {
FadePic(_root.bg_picloader, "in");
};
I forgot to mention that the “bg_picloader” movieclip on the _root has to have an alpha setting of less than 100% to work, which I have done.
It loads in the pics at the given intervals, and that works fine. But it does not fade it in! (it stays as opaque as Ive set it) Ive tried a lot of things, but it wont work. Im sure the error is in that last piece of code I have given(though there are no errors reported in the output when I test it) , I don’t know if it’s the path, or if there is some confusion somewhere else, maybe a confliction. Though I have checked and re-checked my spelling of instances etc.
I hope I have explained this clearly, and that someone can help me out here.
Either way, you will find this a nifty piece of code for moving things dynamically in or out with the fade thing….for making some funky stuff… so go ahead and use it and I hope you get some enjoyment from it at least, as I have.
Remove Dynamically Placed MovieClips?
How do you remove dynamically placed movieClips from the stage?
my movieClip is exported as scorebullet from the library; this is how I have the array for my project:
code:
var j;
var k;
var i = 0;
cats = new Array();
for (k=0; k<3; k++) {
for (j=0; j<10; j++) {
duplicateMovieClip("scorebullet", "s"+i, 3+i);
bullets[i] = this["s"+i];
with (bullets[i]) {
_x = 8+j*28;
_y = 8+k*25;
}
i++;
}
}
So it creates three rows of ten bullets.
How do I go about removing them from a frame when Im done with them?
I know this doesn't work:
code:
removeMovieClip("scorebullet");
Getting Movieclips From The Library Dynamically
Hi I'm in the midst of a painstaking port from AS2 to AS3 on a game I have created. Now a piece of code I use a lot is for example;
function wave() {
for(var i:int = 0; i<10; i++) {
enemies.attachMovie("enemy"+i, i);
}
}
that way I can get enemy1, enemy2, enemy3,... and so on from my library.
how do I go about doing he same thing in AS3?
I have tried
var nextEnemy:MovieClip = new [enemy+i] as MovieClip;
and so on, but none of it works, any tips?
Dynamically Renaming Movieclips
Help needed!
Is it possible to dynamically rename movieclips in Flash? I have been attempting to rename mc's using movieclip._name on a clipEvent, however Flash keeps returning 'undefined'.
I have read elsewhere that it is possible to do this although all my attempts have failed. Is it possible to change a name during runtime, and is ._name a writeable property?
Any help would be much appreciated! thanks!
Creating Movieclips Dynamically
Hello,
I've been trying to improve a website by moving some pictures around with flash and changing their alpha levels. I'm loading the pictures from the server on purpose so the person I'm developing this for can still use his old webservices. I'm using objects so I can still move the jpeg's around after loading them (I'll post my code below). Now doing all that will not be much of a problem (as far as I can judge that now), but my code is rather elaborate.
I've been able to do some things with a for loop, but some things just do'nt work (it results in an empty screen, but no error messages. I'm not really familiar with object oriented programming, so go easy on me when posing a solution .
Thanks in advance,
Roel
// Initial coordinate positions of MovieClips on the screen
initPos = new Array(4, 4, 208, 4, 412, 4, 616, 4, 4, 158, 208, 158, 412, 158, 616, 158, 4, 312, 208, 312, 412, 312, 616, 312);
// Create movie clip instances.
for (a=1; a<13; a++) {
this.createEmptyMovieClip(["img"+a+"_mc"], this.getNextHighestDepth());
}
//Create Objects to couple to the MovieClips
var mc1_obj:Object = new Object();
var mc2_obj:Object = new Object();
var mc3_obj:Object = new Object();
var mc4_obj:Object = new Object();
var mc5_obj:Object = new Object();
var mc6_obj:Object = new Object();
var mc7_obj:Object = new Object();
var mc8_obj:Object = new Object();
var mc9_obj:Object = new Object();
var mc10_obj:Object = new Object();
var mc11_obj:Object = new Object();
var mc12_obj:Object = new Object();
//Place the MovieClips on the stage when they are loaded
for (a=1; a<13; a++) {
this["mc"+a+"_obj"].onLoadInit = function(target_mc:MovieClip):Void {
var target_depth:Number = target_mc.getDepth();// since the movieclips don't load in the correct order I'm positioning them on the sreen according to their depth property
target_mc._x = initPos[target_depth*2];
target_mc._y = initPos[target_depth*2+1];
};
}
//Create MovieClipLoaders
var img_mc1:MovieClipLoader = new MovieClipLoader();
var img_mc2:MovieClipLoader = new MovieClipLoader();
var img_mc3:MovieClipLoader = new MovieClipLoader();
var img_mc4:MovieClipLoader = new MovieClipLoader();
var img_mc5:MovieClipLoader = new MovieClipLoader();
var img_mc6:MovieClipLoader = new MovieClipLoader();
var img_mc7:MovieClipLoader = new MovieClipLoader();
var img_mc8:MovieClipLoader = new MovieClipLoader();
var img_mc9:MovieClipLoader = new MovieClipLoader();
var img_mc10:MovieClipLoader = new MovieClipLoader();
var img_mc11:MovieClipLoader = new MovieClipLoader();
var img_mc12:MovieClipLoader = new MovieClipLoader();
//Add listeners to the MovieClipLoaders to be able to know when they are fully loaded
for (a=1; a<13; a++) {
this["img_mc"+a].addListener(this["mc"+a+"_obj"]);
}
// Load an image into the MovieClips
img_mc1.loadClip("http://www.kovandun.nl/library/pictures/veld_1a.jpg", img1_mc);
img_mc2.loadClip("http://www.kovandun.nl/library/pictures/veld_2a.jpg", img2_mc);
img_mc3.loadClip("http://www.kovandun.nl/library/pictures/veld_3a.jpg", img3_mc);
img_mc4.loadClip("http://www.kovandun.nl/library/pictures/veld_4a.jpg", img4_mc);
img_mc5.loadClip("http://www.kovandun.nl/library/pictures/veld_5a.jpg", img5_mc);
img_mc6.loadClip("http://www.kovandun.nl/library/pictures/veld_6a.jpg", img6_mc);
img_mc7.loadClip("http://www.kovandun.nl/library/pictures/veld_7a.jpg", img7_mc);
img_mc8.loadClip("http://www.kovandun.nl/library/pictures/veld_8a.jpg", img8_mc);
img_mc9.loadClip("http://www.kovandun.nl/library/pictures/veld_9a.jpg", img9_mc);
img_mc10.loadClip("http://www.kovandun.nl/library/pictures/veld_10a.jpg", img10_mc);
img_mc11.loadClip("http://www.kovandun.nl/library/pictures/veld_11a.jpg", img11_mc);
img_mc12.loadClip("http://www.kovandun.nl/library/pictures/veld_12a.jpg", img12_mc);
Dynamically Modifying Movieclips
im trying to use this...
Code:
stop();
var shrinkInterval;
var shrinkCount = 1;
shrinkInterval = setInterval(shrinkAll, 50);
function shrinkAll()
{
trace("shrinkAll()"+shrinkCount);
this["maskPiece_"+shrinkCount].play();
shrinkCount++;
if (shrinkCount >= 17) clearInterval(shrinkInterval);
}
the MCs are NOT dynamically attached... but i think i've done this before without dynamically attached them...
i know ive used this with stuff like
_root["maskPiece_"+shrinkCount].play();
with the "_root" in front... but how do i do it inside a movieclip? i thought i was doing this right... but what am i missing?
thanks!
|