Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Creating Multiple Instance Of Single Library Item



So I'm trying to bone up on my AS3, and I wana make a dart game or something like Space Invaders so I'm going step by step. What I have so far is a little ship that moves left and right via key press, when you hit the space bar it fires off a rocket and does a simple hit test on a big block. What I'm wondering how to accomplish is when I hit the fire button I use addChild and it goes through the air, however I can't hit that fire button again to create a new addChild object, I'm wondering how you would create many rockets at once?I know there is a better way to queue up keyDown events into an array but I haven't worked through that logic puzzle yet (please don't include that code I wana figure it out my self)Here is the AS3 code I have so far, there are some extra variables in there for checking I plan on doing when I get to it.Code: package {   import flash.display.MovieClip;   import flash.display.Sprite;   import flash.display.Stage;   import flash.events.Event;   import flash.events.MouseEvent;   import flash.events.KeyboardEvent;   public class asteroids extends MovieClip {      public function asteroids() {         var staWidth:int = 400;         var staHeight:int = 400;         var topBounds:int = 0;         var leftBounds:int = 0;         var bottomBounds:int = staHeight;         var rightBounds:int = staWidth;         var isRocketFire:Boolean = false;         var hasHit:Boolean = false;         var ship:MovieClip = new SpaceShip();         var rocketFire:MovieClip = new rocket();         var bigBlock:MovieClip = new block();         addChild(ship);         ship.x = 200;         ship.y = 350;         addChild(bigBlock);         bigBlock.x = 200;         bigBlock.y = 10;         bigBlock.width = 400;         bigBlock.height = 20;         // Start of KeyDownHandler - Move rocket         stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);         function keyDownHandler(event:KeyboardEvent):void {            var LEFT:int = 37;            var RIGHT:int = 39;            var GO:int = 38;            var currentKey:int = event.keyCode;            // trace(event.keyCode);            if (currentKey == LEFT) {               ship.x -= 7;            } else if (currentKey == RIGHT) {               ship.x += 7;            }         }         // End of keyDownHandler         // Start of keyUphandler -- Rocket fire         stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);         function keyUpHandler(event:KeyboardEvent):void {            var FIRE:int = 32;            var currentKey:int = event.keyCode;            // trace(event.keyCode);            if (currentKey == FIRE) {               addChild(rocketFire);               rocketFire.height = 10;               rocketFire.x = ship.x;               rocketFire.y = ship.y - 15;               isRocketFire = true;            }         }         // End of keyUpHandler         stage.addEventListener(Event.ENTER_FRAME, moveRocket);         function moveRocket():void {            if (isRocketFire == true) {               rocketFire.y = rocketFire.y - 10;               stage.addEventListener(Event.ENTER_FRAME, hitTest);            }         }                  function hitTest():void {            if (rocketFire.hitTestObject(bigBlock) && (isRocketFire == true)) {               trace("boom");               isRocketFire = false;               stage.removeEventListener(Event.ENTER_FRAME, hitTest);            }         }      }   }}Thanks,Steve



Actionscript 3.0
Posted on: Sun Dec 14, 2008 12:07 am


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Creating Instance Of Random Library Item
I am trying to add 4 items to stage from the library, "Plane0", "Plane1"..."Plane3". Each uses a base class of "com.Plane", and an auto-generated class for itself (named "Plane0"..."Plane3").

com.Plane takes 4 parameters.

I use the following code to get the items on stage:


PHP Code:



// getDefinitionById is imported
for (var i:int = 0, i < 4, i++){
    var planeName:String =  "Plane" + i;
    var ClassReference:Class = getDefinitionByName(planeName) as Class;
    var myPlane:Plane = new ClassReference("param0","param1","param2","param3");
    addChild(myPlane);
}




but I get the following error:

ArgumentError: Error #1063: Argument count mismatch on Plane0$iinit(). Expected 0, got 4.

what am I missing here?

Library Item Drops Instance Names
Hi

I am using as3 and I have a SimpleButton in my library which I add via AS to my app.

The button is fairly simple with a 3 layers, text, hover and bg.
the text is a label which is across all the states with instance name = "btnLabel_txt" on a dynamic textField
the hover is a gfx which is across the last 3 states
and the bg is the initial gfx visible only on the first state.


When I run through the children of each of the button states they have all the correct objects in them but none of them have instance names (well ok they do but its the automatic ones not the ones I gave them)

What I have tried...
I have tried adding a single textfield for each state with different names but it didn't change the outcome.

My current clunky workaround...
I add a class that is the same as my Linkage name for the button
within it I determine which object the textfield is by using getQualifiedClassName I then set a ref to this textfield so I can change it using a simple setter


So what have I missed? Is there a way to keep the instance names?

or should I drop SimpleButtons and make my own via a MovieClip?

Thanks
T

Playing Multiple Videos In Single FLV Instance.
Hi, I'm trying to get a video application to work. The basic question I have is: can i get multiple videos on a flash streaming server to play in a single FLVPlayback instance? (I want the user to be able to choose the video based on a button, not play in succession.) Or do I have to set up a custom player using NetConnection and NetStream classes along with the NetStream.play(vidname) method ?

I really need to be pointed in the right direction on this because the project is due asap.

Thanks!!!

Creating Single Mc From Multiple Mcs On Different Layers
Could someone tell me how to take multiple layers of already created movie clips and combine them into one movie clip? It's easy to create a movie clip of a movie clip, but I'm not sure how to do so in this case.

Also, is it possible to do the same thing for a layer of shape tweens?

TIA,
aaroneousmonk

Creating Dynamic Instance Of Library Button
I didn't quite find exactly what I was looking for in my search for <creating dynamic instances of a Library button object>. It's obviously just a syntax question. So, here goes.


Code:
var LineBut:Array = [];
for ( i = 0; i < Lines.length; i++ ) {
this.moveTo( Lines[i][0], Lines[i][1] );
this.lineTo( Lines[i][2], Lines[i][3] );
// place a button in middle of line
ButPosX = Lines[i][0] + Lines[i][2] / 2;
ButPosY = Lines[i][1] + Lines[i][3] / 2;
LineBut[i] = new LineButton();
LineBut[i]._x = ButPosX;
LineBut[i]._y = ButPosY;
trace( LineBut[i].name );
LineBut[i].name = ["LineBut"+i];
addChild( LineBut[i] );
}
This ain't it. I'm trying to create a new instance of my Library button object, "LineButton", for each Lines entry. I'm not getting a syntax error, but the output from the trace is "undefined" for each LineBut array entry.name.

I think part of the problem is I am unsure of the jargon used to describe what I'm trying to do. I kept looking for "create", "spawn", "instance", "copy", etc. and really only found "new" to help make the instance.

All help is appreciated. I'll reply with the solution if I find it in my continuing research. Thanks.

Creating Drag And Drop - Multiple Objects To Single Target + Specific Feedback
Hi,

I've created a simple drag and drop flash file. What I need to know though is if I can have multiple objects being dragged to a single target? For example, I want an additional object paper_dr to also be dragged to the target Paper_Text.

And if so, can I provide a response to the user based on which object they dragged (using the single dynamic text field?).

The code is below...

Thanks in advance!


Code:
var dict = new Dictionary ();

// =================== START USER Config =====================
// Insert as many "dict[text_box] = movie;" statements you like
// Replace: text_box by the name of a matching dynamic text_box
// movie by the name of movie instances users can move around.

dict[Paper_Text] = Box_dr;
dict[Plastics_Text] = Plastic_dr;
dict[Glass_Text] = Bottle_dr;

// Do NOT change/delete any other line. Also make sure to respect
// the syntax, e.g. dont forget the ";" at the end of each line.
// ===================== END USER Config ====================

var hits = 0; // counts succesful hits
var max = 0; // used to compute dictionary length

// For each item in the dictionary we add event listeners
// "for each" will loop through the values ... not the keys

for each (var item in dict)
{
item.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
item.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
item.buttonMode = true; //needed for the hand cursor to work
max = max + 1;
}


// Define a mouse down handler (user is dragging)
function mouseDownHandler(evt:MouseEvent):void {
var object = evt.target;
// we should limit dragging to the area inside the canvas
object.useHandCursor = true;
object.startDrag();
}

function mouseUpHandler(evt:MouseEvent):void {
var obj = evt.target;
// obj.dropTarget will give us the reference to the shape of
// the object over which we dropped the circle.
var target = obj.dropTarget;
// If the target object exists the we ask the test_match function
// to compare moved obj and target where it was dropped.
if (target != null)
{
test_match(target, obj);
}
obj.stopDrag();
}

function test_match(target,obj) {
// test if the pairs match
if (dict[target] == obj)
{
// we got a hit
hits = hits+1;
Outcome_text.text = "That item has just been successfully sorted for recycling!";
// make the object transparent
obj.alpha = 0.5;
// kill its event listeners - object can't be moved anymore
obj.removeEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);
obj.removeEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);
// Test if we are done
if (hits == max)
{
// here we should play an animation
Outcome_text.text = "Congratulations& youve just recycled all the packaging in the workplace!";
}
}
else
{
Outcome_text.text = "Unfortunately, that wasnt correct. Review the content in this module, and try again.";
}
}

Change Format Of Single Combobox Item
Hi,

How can I change the format of an individual item in a combobox in AS3? I want to change the font of an individual item without affecting the fonts of other items.

thanks!

Jay

Library Item ?
Hello everyone,

I am currently working on a project that contains a significant amount of library items(around 700). Does anyone know if this will affect the performance of the movie?

Thanks in advance!


SunsFan13
duvalldesigns.com

Library Item In New Window
Hello all,

I am trying to open a new window to display a library item (graphic or movie clip.)

I hope to do this without using a getURL that points to an external .html file.

I've tried a loadMovie command where URL: _root.mygraphicname

and no luck.

Any thoughts?

Thanks-
Steve

Cloning A Library Item
I am going crazy over this, I'm new to flash and am using 2004 Pro.


How do I copy a Movie clip in the library without having it tied to the clip I copied it from?

ie. Create a simple clip call it clip1 and then duplicate it and call it clip2. I now have two separate clips in the library. They should be separate and distinct right? Now edit clip1 and change the color of an existing shape in the clip... say the color: red to green. When I look at clip2, the same shape has changed colors! I really don't want to have to make eachclip from scratch when they are complex and similar. How can I copy and item in the library and then place it as new distict item, not just an instance that will change evertime I edit the original I copied it from

any help from the rest of you would be greatly appreciated. I'm converting from swish to flash and find flash 100% frustrating and dificult, just hopin the switch will eventually pay off.

thanks!

Jeremy

Loadmovie On A Library Item
Hi,

If I set a library movie clip linkage to 'Export for Actionscript' (and say for example, named it mcContent), then in my timeline issue this command:

mcContent.loadMovie("blah.swf");

it doesn't work. I would have expected it to load the movie clip into the mcContent symbol.

Can anyone explain if this is possible or not and why?

I would like to perform some silent preloading while other things are happening.

Thanks

Loading Library Item
Hello folks! I have a situation that I need three graphics or movies from the library loaded into a movieClip that is on the stage.

When I click a button, I want to load "gfx_red" (which is a red circle graphic) into the movieClip called "colourHolder".

I've used this code, but it doesn't seem to do the trick:

on (release) {
attachMovie("colourHolder", "gfx_red");
}

What am I doing wrong? Oh BTW, when I made the graphics and movieClip I already "export as ActionScript" from the linkage menu.

Glenn

Library Item Conflict
Hi. I'd appreciate any help people can offer regarding this problem. I am creating some animations using Flash 8. Some work just fine. Others give me the following message when I try to add a new movie clip: One or more library items exists in document. It gives the choice to replace or not replace the items. Both choice are bad. If I replace the items, one of the original animations gets messed up. If I don't replace, the new animation gets messed up. I'm unclear about which items are overlapping. The problems don't seem to make sense. For example, if I say "don't replace" my new animation will suddenly have additional moving parts that were not part of the original.

Any ideas for solutions or workarounds?

Thanks.

Corrupt Library Item
How can I delete a library item without selecting it in the list. It is a .png file, and when I select it, the app crashes, so I'd rather not leave it in the library, and wish to replace it. Help...! belongs to MX 2004 pro fla file.

Why Would You Add A Library Font Item?
I'm just confused what a font item in the library would be for? Is it just like adding a dynamic textfield and embedding all the characters there??

Library Item Exists?
If there a way in flash to see of a linked object exists?  For example, I have in my library a Bitmap with the identifier "ico_UNK_48" (no quotes).  How can I discover in ActionScript if the Bitmap exists before I attempt to load it?

---------------------------------------
TINSTAAFL, which is why I contribute.

Multiple Flash VM Instances Running With Multiple Swfs On The Single Webpage
Hi all,

I am developing a webpage having multiple swfs interacting with eachother. Not when I load many swfs, is it the case that multiple flash VM instances are running on my machine? Is there any way to check this.

The project I am doing has one of the requirements that only one flash VM should be running.

Please help me in this.

Multiple Flash VM Instances Running With Multiple Swfs On The Single Webpage
Hi all,

I am developing a webpage having multiple swfs interacting with eachother. Not when I load many swfs, is it the case that multiple flash VM instances are running on my machine? Is there any way to check this.

The project I am doing has one of the requirements that only one flash VM should be running.

To summarize my question is:

how to check whether multiple flash VM instances are running on the system when multiple swfs are loaded on the page?

Please help me in this.

Import Movie As A Library Item?
This may sound like a silly question, but how can I import a movie as a library item for another movie?

Help : How To Load Another Swf File And Use The Library Item Of It
I have two flash files

one is main.swf , another is library.swf
in the library.swf file , there is a movieClip which have choice the export for use and have already fill the exported URL field in "main.swf" and the ID is call EXT_TEST_MC, so that main.swf can call the library item of library.swf for use, it works fine if i use flash player 7 and AS 2 to complie, but if i use flash player 6 and AS 2 to complie , it doesn't work.

The script is as below,


Code:
#frame 1
myLoader = new MovieClipLoader();
myListener = new Object();
myListener.onLoadStart = function (target_mc) {}
myListener.onLoadProgress = function (target_mc, loadedBytes, totalBytes) {}
myListener.onLoadComplete = function (target_mc) {}
myListener.onLoadInit = function (target_mc)
{
_root.attachMovie("EXT_TEST_MC", "test", 10, {_x:0, _y:0});
}
myListener.onLoadError = function (target_mc, errorCode)
{}
myLoader.addListener(myListener);
myLoader.loadClip('library.swf', "_root");



The above code work fine in flash player 7 + AS 2,
but I need it also work fine in flash player 6 + AS 2,
then I try to change the above code as below



Code:
#frame 1
loadMovie('library.swf', 10);
....
....
....
#frame 10 // already make sure the ext. swf has loaded in it
_root.attachMovie("EXT_TEST_MC", "test", 10, {_x:0, _y:0});


but it doesn't work, it can't attachmovie from the ext. swf's library.

So , anyone can help me to solve the problem

Thanks,
Jack.

A Script To Make An Mc For Every Library Item?
I'm currently working on a flash file to put on cd. The problem is the intro component to this piece requires the loading of roughly 1000 scaled down thumbnails. Hence rather than get flash to load each thumbnail as it needs them off the cd (and pause the piece for half a second or so), I want to import directly into the main fla, or a secondary one I'll load in, scaled down versions of the images.

I can file->import to library the 1000 images, that's fine. My question then is, how can I make a new movieclip, place an image in it, add a linkage name... automatically, for all these items? I've heard there is a type of scripting available within flash for this, any helpers on the matter?

thanks guys

[CS3] Dynamic Text In A Library Item
If anyone could help me with this problem I'd really appreciate it.

In my library I have a Movie Clip called OneFrameTile.

As the name suggests, it has only one frame, and in that frame I have a dynamic text field called letter.

The constructor of my main class creates an instance of my OneFrameTile class and chooses a letter of the alphabet. The text property of the dynamic text field is set to the chosen letter of the alphabet.

That all works fine, no problem.

But then I have another Movie Clip in my library, called TwoFrameTile.

It has two frames, and the dynamic text field (still called 'letter') is on the second frame.

When I ask the constructor in my main class to create an instance of TwoFrameTile, and assign a letter of the alphabet to the text property of my dynamic text field, I get an error message saying Cannot access a property or method of a null object reference.

In this case, when I debug the movie, the letter property of my TwoFrameTile instance is shown as null.

If anyone can tell me what I'm doing wrong, I'd be grateful.

Thanks for reading this.

DD

Dynamic Load Of Library Item
Hi Guys,
I know and love how to add a library item to the display object on the stage.

exacmple, I have a library item named libraryClip in the library.

var newLibraryClip:Sprite = new libraryClip();
addChild(newLibraryClip);

What I am trying to do is load a library item from a dynamic variable passed in through an xml file.

Somehow I need to pass the value of a variable to call on in the library

example...
//loading in xml
//xml now loaded
//variable passed on

var newLibraryClip:Sprite = new [dynamicVariable]();
addChild(newLibraryClip);


Does that make sense?

Clean Up Library After Item Removal
Hi everyone:


I tried to experiment with the Flash components and added a Button to the library and later discovered that the resulting size of the SWF became 700K (before it was around 60K). Now I removed the button from the stage and from the library and even though the size of SWF has shrunk down to 600K, it's still 10x larger than it was originally. Can someone suggest how to clean up my project and return to the original size of the SWF file?

AttachMovie Adds Library Item Twice?
Hi everyone!

I've come across this problem for the second time now, and I'm still not sure what solved it the first time.

I have a timeline that contains the clip "contentMC". On the same timeline the following AS appears:

_root.contentMC.attachMovie("home", "contentHolder", _root.contentMC.getNextHighestDepth());

The library item "home" contains several text objects. The strange thing is that, while the item is added as "contentHolder", the contents of "home" is also added to "contentMC". So when I use List Objects during preview, I get:

Level #0: Frame=24 Label="Interface Build"
Movie Clip: Frame=1 Target="_level0.contentMC"
Shape:
Text:
Text:
Text:
Text:
Text:
Text:
Text:
Text:
Movie Clip: Frame=1 Target="_level0.contentMC.contentHolder"
Shape:
Text:
Text:
Text:
Text:
Text:
Text:
Text:
Text:

The first row of "Text:" shouldn't be there.

I came across this problem before at a different level. That one was solved (I think) by replacing .getNextHighestDepth() with 1. This time, however, that doesn't help.
Anyone any ideas?

I've uploaded the .fla at: http://www.eurovoice.nl/flash/eurovoice01.fla

Thanks in advance!

Yours,
Andra

AttachMovie Adds Library Item Twice?
Hi everyone!

I've come across this problem for the second time now, and I'm still not sure what solved it the first time.

I have a timeline that contains the clip "contentMC". On the same timeline the following AS appears:
_root.contentMC.attachMovie("home", "contentHolder", _root.contentMC.getNextHighestDepth());The library item "home" contains several text objects. The strange thing is that, while the item is added as "contentHolder", the contents of "home" is also added to "contentMC". So when I use List Objects during preview, I get:
Level #0: Frame=24 Label="Interface Build"Movie Clip: Frame=1 Target="_level0.contentMC"Shape:
Text:
Text:
Text:
Text:
Text:
Text:
Text:
Text:
Movie Clip: Frame=1 Target="_level0.contentMC.contentHolder"Shape:
Text:
Text:
Text:
Text:
Text:
Text:
Text:
Text:The first row of "Text:" shouldn't be there.

I came across this problem before at a different level. That one was solved (I think) by replacing .getNextHighestDepth() with 1. This time, however, that doesn't help.
Anyone any ideas?

I've uploaded the .fla at: http://www.eurovoice.nl/flash/eurovoice01.fla

Thanks in advance!

Yours,
Andra

[CS3] RemoveMovieClip Not Working For One Particular Library Item
Hi there,

I built a website for our company, but because my boss kept adding stuff as I was building, the navigation-function became a total mess. On top of that, the need has risen to make the site multi-lingual, and I would like to get the back-button and deep-linking to work properly.

So, I decided to rewrite the navigation-function using the exanimo stateManager. The site structure basically has two levels: Six main sections (L1), most of which have subsections (L2). All these "pages" are library items that get attached to a holder MC (L0). So for instance, the first page is built by attaching "home_NL" to L0 and calling it L1, and then attaching "home_welkom_NL" to L1 and calling it L2.

This all works fine, until I've clicked “Voices”. If I click a section after that, the L0 gets faded out, but L1 is not removed. And since the function then tries to attach a new library item as L1 and will not continue until it is loaded, navigation simply hangs.

Unfortunately “luister_NL”, which is loaded when you click “Voices”, is a fairly complex movie clip (by my standards, at least). It allows the visitor to listen to samples of our voice-talents based on language, style and gender. These can also be selected and “ordered” through a form.
Something in this movie clip is preventing Flash from removing it from the stage, but I can’t figure out what.

I’ve uploaded the fla so you can check it out if you want.

Any suggestions on what could be causing this behaviour would be very welcome.
Thanks in advance!

Yours,
Andra

Attach A Library Item To The Stage With AS2
Hey all,

Long time since i've done this and i'm a little rusty.
How do I attach a library item to the Stage using AS2??


ActionScript Code:
Stage.attachMovie("myLogo", "myLogo", 1);


Does not seem to work??

Thanks in advance!
George

Loading A Library Item Dynamically
Hello,

I hope someone can help me with this as it's sending me nuts, I realise I'm probably missing the obvious, but I have tried looking through the help in Flash and all the forums, but I'm still not getting it.

The code:

function row12_MOUSEUP (event:MouseEvent):void
{
var chosenAbbr = event.currentTarget.name.toString();
var chosenAbb:Object = MovieClip(root).abbrArray[chosenAbbr];// traces instance names ok
trace ("from array" + chosenAbbr + " " + chosenAbb);
var tempClip:MovieClip = new chosenAbb();
trace (tempClip);
tempClip.x = 0;
tempClip.y = 0;
MovieClip(parent).chosenAbb1.addChild (tempClip);
}


To explain, when the mouse event occurs the current target gets a value from an array, this returns as a string which is the same as the name of the item in the library (exported for AS). This string reads out correctly for example 'clip1', the above code work if I replace 'var tempClip:MovieClip = new chosenAbb();' with 'var tempClip:MovieClip = new clip1();'.

I need the 'clip1' reference to be taken from the value supplied by the array, as a String it reads correctly but the value is not used to create the child, do I need to change the whole way of working? I've tried all sorts but am getting nowhere fast, any help/pointers would be greatly appreciated...

Many thanks

Pete

Single Button, Multiple Action/Multiple Targets
I originally posted this on the MX board but I think it should be here. It's a difficult one to describe.

I want to assign two separate events to a single action, but I want one event to follow the other. Both targets are MovieClips nested within the same external swf, which has been imported into the main timeline. Follow me?

on (release) {
_root.loadMovieMC.FallMan.gotoAndPlay("end");
}
on (release) {
_root.loadMovieMC.gotoAndPlay("FishGirl");
}


Problem is that once the button is clicked it runs straight to "FishGirl" without playing FallMan("end"). If I take out the second expression, it will play FallMan okay, but not the two together.

I'm in over my head here, Can anyone please help?

Attaching A Library Item To The Stage From A Class
First.. I want to make sure I'm following the best practice for what I want to do... I have a flash quiz that uses a class file and then on the last frame I want to attach a custom movieclip with logo graphics, etc on it and the score in it. I heard that best practice is not to have any graphics, etc. in the FLA file and try to keep it all in external class files. I put this movieclip in the library and set up linkage identifiers like so:


Code:
class = logo_mc
base class = flash.display.MovieClip
checked "export for actionscript"
checked "export in first frame"
How do I add this movieclip to the stage?? I see similar posts but people are not adding things to the stage with classes...

I tried a sample document like this:

Code:
package {

import flash.display.Sprite;
import flash.display.MovieClip;
import flash.events.*;

public class testing extends MovieClip {
private var logo_mc:MovieClip;

public function testing(){
loadMovieClips();
}
private function loadMovieClips(){
this.addChild(logo_mc);
}

}
}
But then I get this error:

Code:
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/addChild()
at testing/::loadMovieClips()
at testing$iinit()
What am I doing wrong? I'm coming from the actionscript 2 way of thinking where I would have several movie clips in the library that I would attach to the stage with attachMovie when needed.

Any help is much appreciated!

Using Shared Library Item Seems To Lock Up .fla File.
hi guys,

i`m working with one master fla file and two child fla's.

the two child fla use library item that are linked to master fla file, and are updated every time .swf is published.
after working with the master .fla file, it becomes unable to save.

does anyone come across any similar problems? or know some solutions to this?

any help appreciated.

Convert Existing Library Item -> Drawing API?
Greetings, all -

I'd like to take an existing library graphic (vector, not bitmap) and "convert" it into a series of ActionScript commands which use the drawing API (beginFill, lineTo, etc.) to produce the same result. Is there any utility or export function that would facilitate this?

Or am I forced to try to convert the graphic into an svg file and then try to import that? I'm asking this because I like the idea of thoroughly encapulating the code for a preloader that uses my company logo. I'd love to have the whole thing, graphics and all, in an external AS file; nothing but text! For simple graphical elements that get reused, you wouldn't have to fish around for an external library item as well, or remember where that movie clip was...

Ed

Loading Library Item Into A Movie Clip?
How would I go about doing that?

Thanks,
Gerard

AS File Not Displaying Library Item On Stage
The following script works perfectly, but I can't get the library item (which is a mc, class "helmet") to display. Any ideas? Do I need to import additional classes to display the mc?


package {
import flash.display.MovieClip;
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;
import fl.controls.listClasses.CellRenderer;
import fl.controls.ScrollBarDirection;

public class media extends MovieClip {

private var xmlLoader:URLLoader;


//the following function is what is not working at runtime//

public function loadbuttons():void {
var vidbut:MovieClip = new helmet();
vidbut.x=620;
vidbut.y =50;
addChild(vidbut);
}

public function media():void {

xmlLoader = new URLLoader ();
xmlLoader.load(new URLRequest("/playlist.xml"));
xmlLoader.addEventListener(Event.COMPLETE, getXMLdata);


}

public function getXMLdata(event:Event):void {
var campXML:XML = new XML(xmlLoader.data);
var vid:XML;
for each(vid in campXML.vid) {
campList.addItem({label:vid.attribute("desc").toXMLString(),
data:vid.attribute("src").toXMLString()});;
}

campList.selectedIndex = 0;
campList.addEventListener(Event.CHANGE, playnewvid);
FLVPlayer.source = campList.selectedItem.data;
FLVPlayer.pause();
campList.visible = false;

}


function playnewvid(event:Event):void {
FLVPlayer.play(event.target.selectedItem.data);
}





























Edited: 09/27/2008 at 09:31:33 AM by iRyFlash

AS 2 Using Shared Library Item Seems To Lock Up .fla File.
hi guys,

i`m working with one master fla file and two child fla's.

the two child fla use library item that are linked to master fla file, and are updated every time .swf is published.
after working with the master .fla file, it becomes unable to save.

does anyone come across any similar problems? or know some solutions to this?

any help appreciated.

Using Shared Library Item Seems To Lock Up .fla File.
hi guys,

i`m working with one master fla file and two child fla's.

the two child fla use library item that are linked to master fla file, and are updated every time .swf is published.
after working with the master .fla file, it becomes unable to save.

does anyone come across any similar problems? or know some solutions to this?

any help appreciated.

Single MC Multi Instance Control
I have a MC that has several instances on stage. I dont want to target directly to each instance as more will be added and taken away at run time. I have tried setting a variable (XYZ) at root level and have the main mc look at that variable and set the ._current frame equal the that variable (XYZ). I then have two buttons the control the variable (XYZ) so that all the MC cliip instances would react and change based on the original clip. EXCEPT THAT IT DONT WORK. I think it sounds like it should but it dont. Any suggestions on how to pull this type of instance controlling off.

Thanks
Carter

Find All Instances Of Library Item Currently Present On The Stage?
Hi,

well the question is in the topic - is that possible or not? And if yes, how? Answer, link, whatever, thanks.

Refer The Library Item Inside A Scrollpane Component
Hi

I'm using a scroll pane component to load a movieclip from library. Everything is working fine. But I want to refer that movie clip inside the compnent to add a zoom option for that. How can we refer that.

If File Exists, Load It, Else Insert Library Item
I've googled around for a while tonight for things like "actionscript 1 check file exists" and so on, and the best I find is people saying to check if a file exists, do this
CODEfileExists=new LoadVars();
fileExits._parent=this;
fileExists.onLoad=function(success)
{
//success is true if the file exists, false if it doesnt
if(success)
{
//the file exists
var nm=this._parent.createEmptyMovieClip("swfHolder",1); //so create a movieclip
nm.loadMovie("myfile.swf"); //and load our .swf file into it
}
}
fileExists.load("myfile.swf") //initiate the test

JSFL - Add An Item From The Library To A Specific Frame On The Timeline
Hi all,
Is possible to do what I am asking in the title using JSFL?

Thanks

An Instance: Loop Vs. Play Once Vs. Single Frame ?
FlashMX: wondering what the difference is between the 3...

I have a single keyframe that I place a symbol (as graphic) in. Then under the "instance of: blahSymbol", I have a choice of LOOP, Play Once, or Single Frame.

Does it matter what I choose since this symbol (as graphic) will only exist in this one keyframe? I always leave it as Loop (default).

When would I use the other options and/or is it better to use the other options ?

Casting XML Node Text Back Into A Library Item Class
Hello,

In my library I have a movieclip called START_GAME_BTN that uses the same name for its class which is START_GAME_BTN.

The problem I am having is figuring out how to cast the node text for <clipName> which is START_GAME_BTN back into the item in my library.

The XML snippet looks like this:


Code:
<startGameButton>
<clipName>START_GAME_BTN</clipName>
<position>
<xpos>560</xpos>
<ypos>420</ypos>
</position>
</startGameButton>
In my class that is parsing the XML needed to derive the items necessary for screen display, I initally do this for the start game button:


Code:
private var _startGameBtn:MovieClip;
But this is wrong because it really needs to be cast like this:


Code:
private var _startGameBtn:START_GAME_BTN;
Unfortunately this is where I am a little stumped. I tried doing this:


Code:
_startGameBtn = _xmlScreenData.screen.startGameButton.clipName as MovieClip;
But when I ran through the debugger the value of _startGameBtn was still null. I then tried this:


Code:
var gameButton:String;
gameButton = _xmlScreenData.screen.startGameButton.clipName;
_startGameBtn = gameButton as MovieClip
Unfortunately _startGameBtn was still null.

It's almost like I need to do:


Code:
//
_startGameBtn:_xmlScreenData.screen.startGameButton.clipName as _xmlScreenData.screen.startGameButton.clipName
_startGameBtn = new _xmlScreenData.screen.startGameButton.clipName()
//
But I know this won't work...has anyone run into this problem before?

Any suggestions would be greatly appreciated.

cheers,

frank grimes

How To Access Nested Movieclips Inside A Library Item, From A Class
Hey everyone,

I got this dilemma, i have a Sprite in the library linked to a class. Inside the sprite i have a MovieClip and a TextField. My question is: how can i access the MovieClip / TextField from my class? (i want to add a MouseEvent to the MovieClip, also i want to change the text in the TextField).

Thanks in advance.

Grabbing BitmapData Library Item And Adding To Display List
I can't seem to get this to work with BitmapData library items, though it is working for the MovieClip items...

I have a utility function which grabs items from the library

public static function create(className:String):Class
{
return new (ApplicationDomain.currentDomain.getDefinition(cla ssName) as Class);
}


Here is the code i'm using to add the BitmapData to the stage...

var ChromeBackground:Class = Utilities.create("mc_chromeBackground");
var chromeBG_BD:BitmapData = BitmapData(new ChromeBackground());
var bmp:Bitmap = new Bitmap(chromeBG_BD);
this.addChild (bmp);


The BitmapData object isn't showing up on screen. What am i doing wrong??

THANKS in advance!!!
Lori-

Removing A Single Symbol From The Library On Over 100 FLAs ? Help - Newbie
Hi,

In my library, I have this symbol which I want deleted from many FLAs. Is there a way to remove this symbol without having to open each FLA, remove it from the library, then re-save my movie?

These FLAs will be called in my main interface. Can I target this symbol with action script when they are called OR is there a better way?

Many thanks,

Luke
:-)

Create Three Instances Of A Library Item Inside A Parent Movie, Then Assign Behaviors
I want to create three instances of a library item inside a parent movie, then assign behaviors to those three items...

My brain tells me this code would work, but the reality is it doesnt, even though the debugger lists the objects exactly like I set them up:

ActionScript Code:
// create the parent movie
var Movie1:MovieClip = new MovieClip();
addChild(Movie1);

// use a loop to load in the cloned library items, name them, and assign behaviors
for (var i:int = 1; i < 4; i++) {
var subMovie:MovieClip=new libraryClip;
subMovie.name="sub"+i;

Movie1.addChild(subMovie);

subMovie.x=i*20 // this spaces them apart on the stage

subMovie.addEventListener(MouseEvent.MOUSE_OVER,showName);
    function showName(e:MouseEvent){
        trace(this.Movie1.subMovie.name)
    }
}

I'm banging my head against this, and I feel like the solution is going to be a fundamental breakthrough for me...

Help?

Copyright © 2005-08 www.BigResource.com, All rights reserved