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




Pop Up Using Attachmovie Method



I have no problems getting my pop up windows to work this way, my question is regarding the effects on the preloader. When you have the movies that will be called export for use in AS and export on frame 1 it effects the load time of the preloader. Is there any way I can tweak this so that it does not do this? It appears that I can't change the frame that the mc's export to or I would just do frame 3 instead of 1. Can anyone help? Thank you.



FlashKit > Flash Help > Flash ActionScript
Posted on: 10-12-2004, 01:09 PM


View Complete Forum Thread with Replies

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

[f8] AttachMovie() Method
Hi,

I am using a for() loop and attaching a movieclip from the library using the attachMovie() method. They are all being attached on onto of the other, usually I define a variable outside the for() loop and then add it to the previous movieclips width. Its not working for me today, so I must be doing something wrong. It is normally a messy process in my code anyway.

Anyone know a nice tidy way of doing this?

AttachMovie Method
I have a simple movie loader using attachMovie and a preloader animation showing download progression. So why does this work?


ActionScript Code:
movie1_btn.onPress = function() {
    startPreload("load/flashMarketing.swf");
};

movie2_btn.onPress = function() {
    startPreload("load/flashMarketing2.swf");
};

function startPreload(url) {
    container_mc.loadMovie(url);
    attachMovie("preloader anim","preloader_mc",500,{_x:275, _y:165});
    onEnterFrame = preloadContainer;
}


But this doesn't?


ActionScript Code:
function startPreload(url) {
    container_mc.loadMovie(url);
    attachMovie("preloader anim","preloader_mc",500,{_x:275, _y:165});
    onEnterFrame = preloadContainer;
}

startPreload("load/flashMarketing.swf");

The preloader animation doesn't show up.

Attachmovie()method ?
When using the attachMovie() method, the arguments are

ActionScript Code:
mc.attachMovie(symbolIdentifier, newName, depth, initObject)


How does the symbolIdentifier and newName work?

If the movie clip in my library is USA_mc, can I use any identifier and name when I link the movie clip?

AttachMovie Method
Hi!
I am using the attachMovie method to attach a movie from an external movie into the _root of another one.

so I have a movie loaded inside another and I use the attachMovie method to attach the movie on the _root of the parent movie, the movie that I want to attach is a movie of the library of the loaded movie.
The movie I want to attach is setted for export.

Can anyone tell me why it is failing?

XML AttachMovie Method
Hey all,
For whatever reason, this script won't run. It won't show all of my thumbnails, only one. I am supposing it is trying to load the button into a layer replacing the original one, but what can I do about that?
Code:

import com.mosesSupposes.fuse.*;
ZigoEngine.register(Fuse, PennerEasing, FuseFMP);

var xml:XML = new XML();
xml.ignoreWhite = true;
xml.onLoad = function(){
   var nodes:Array = this.firstChild.childNodes;
   for(var i=0;i<nodes.length;i++){
      _root.createEmptyMovieClip("zeLoader",this.getNextHighestDepth());
      var mc:MovieClip = _root.zeLoader.attachMovie("zeButton","z"+i,this.getNextHighestDepth(),{_x:(i*30)});
      mc.zeText.text = nodes[i].attributes.ide;
      mc.onRollOver = function(){
         var f1:Fuse = new Fuse();
         f1.push({target:this, scale:150, time:1, ease:"easeOutBounce"});
         f1.start();
      }
      mc.onRollOut = function(){
         var f1:Fuse = new Fuse();
         f1.push({target:this, scale:100, time:1, ease:"easeOutBounce"});
         f1.start();
      }
      mc.onRelease = function(){
         
      }
   }
}
xml.load("zeXML.xml");

AttachMovie's Level Method
i have a question regarding the specifying of the level in which to put the instance of whatever movie using "attachMovie".

i am running a script that is constantly adding and deleting instances of a movie clip using the attachMovie function. likke this:

for (i = 0; i < theArray.length; i++) {
_root.subMovie.attachMovie("mc", theArray[i], i);
}

so you can see that my level right now corresponds with the "i" counter number, which works great, until i start deleting and then adding new movies which end up getting the same level as the previously created movies. i'm just wondering, is there an easy way to make the level the same or something so that ever movie cllip instance will show up correctly. what am i to do?

thanks!

Problem Using Attachmovie Method
public function mc1():Void {
for (i=0; i<9; i++) {
c = c+30;
var mc_new = my_clip.attachMovie("mc_bread", "bread_"+i, my_clip.getNextHighestDepth()+1, {_x:80, _y:385-c});
mc_new._visible = false;
bread_1._visible = true;
}
}

when compiled the code gives error:
There is no property with the name 'bread_1'.

Pop Up Window Using AttachMovie Method
Hi All,

I'm trying to create a pop up window using the AttachMovie method and i want it to act like a coventional pop up window should do, i.e. it should be draggable and it should have a close button.

I have no problem getting the window to pop up and drag but when i try to use the close button it doesn't work or visa versa.

If anyone can help me to get both features working together i would be very grateful.

Cheers,

Winston.

Pop Up Window Using AttachMovie Method
Hi All,

I'm trying to create a pop up window using the AttachMovie method and i want it to act like a coventional pop up window should do, i.e. it should be draggable and it should have a close button.

I have no problem getting the window to pop up and drag but when i try to use the close button it doesn't work or visa versa.

If anyone can help me to get both features working together i would be very grateful.

Cheers,

Winston.

[MX04] Gallery With AttachMovie() Method
hi, my first post, maybe you can help me, this is the code from http://www.kirupa.com/ Tutorial named Photo Gallery - it use LoadMovie method. I want to make gallery with preloading ALL pictures, and don't need dynamic change fotos (want to improt them all into my library). So i think that attachMovie(); will be good for it. But don't know what should i change in a script. I tried change paths and functions so spent few hours with AS dictionary and AS training book and achived nothing Could You help me?


Code:
/*
i wrote this code, but you can use and abuse it however you like.
the methods are defined in the order which they occur to make it
easier to understand.
*/
// variables ------------------------------------------
// put the path to your pics here, include the slashes (ie. "pics/")
// leave it blank if they're in the same directory
this.pathToPics = "animation/";
// fill this array with your pics
this.pArray = ["image0.jpg", "image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg", "image6.jpg", "image7.jpg", "image8.jpg", "image9.jpg"];
this.fadeSpeed = 20;
this.pIndex = 0;
// MovieClip methods ----------------------------------
// d=direction; should 1 or -1 but can be any number
//loads an image automatically when you run animation
loadMovie(this.pathToPics+this.pArray[0], _root.photo);
MovieClip.prototype.changePhoto = function(d) {
// make sure pIndex falls within pArray.length
this.pIndex = (this.pIndex+d)%this.pArray.length;
if (this.pIndex<0) {
this.pIndex += this.pArray.length;
}
this.onEnterFrame = fadeOut;
};
MovieClip.prototype.fadeOut = function() {
if (this.photo._alpha>this.fadeSpeed) {
this.photo._alpha -= this.fadeSpeed;
} else {
this.loadPhoto();
}
};
MovieClip.prototype.loadPhoto = function() {
// specify the movieclip to load images into
var p = _root.photo;
//------------------------------------------
p._alpha = 0;
p.loadMovie(this.pathToPics+this.pArray[this.pIndex]);
this.onEnterFrame = loadMeter;
};
MovieClip.prototype.loadMeter = function() {
var i, l, t;
l = this.photo.getBytesLoaded();
t = this.photo.getBytesTotal();
if (t>0 && t == l) {
this.onEnterFrame = fadeIn;
} else {
trace(l/t);
}
};
MovieClip.prototype.fadeIn = function() {
if (this.photo._alpha<100-this.fadeSpeed) {
this.photo._alpha += this.fadeSpeed;
} else {
this.photo._alpha = 100;
this.onEnterFrame = null;
}
};
// Actions -----------------------------------------
// these aren't necessary, just an example implementation
this.onKeyDown = function() {
if (Key.getCode() == Key.LEFT) {
this.changePhoto(-1);
} else if (Key.getCode() == Key.RIGHT) {
this.changePhoto(1);
}
};
Key.addListener(this);

[CS3/AS2] Trouble With Depths Using AttachMovie Method
OK, what I am looking for is quite simple. I have a site where I set it up so that when you click one of the menu buttons, it attaches a movie clip in front of the current window. Here is the site:

http://www.thentsgroup.com/swirl_culture

If you click the buttons going from left to right, the movie clips open just fine, but then if you click one of the other buttons after the FEEDBACK button has been clicked, nothing happens because they are opening up behind the current movie clip. Which is not what I want. I want them always to open in front.

I'm using the getNextHighestDepth method, but it doesn't seem to be working. Furthermore, when I use getNextHighestDepth instead of just "0", the button only works one time (click the FEEDBACK button more than once and you'll see what I mean).

Does anyone have a solution for this?

Here is my AS on one of the buttons:


Code:
stop();

this.hitArea = mainhit

this.onEnterFrame = function(){
if(rewind == true){
prevFrame();
}
}

this.onRollOver = function(){
rewind = false;
play();
}

this.onRelease = function(){

attachMovie("menumain","mcMenumain",this.getNextHighestDepth());

mcMenumain._x = -298
mcMenumain._y = -97
}

this.onRollOut = function(){
rewind = true;
}

Problem With AttachMovie Method HEEEELP
Im having problems with the attachMovie Method, I created a function like the following:


Code:

function AdpoFunc() {
_root.sceneHolder_mc.contHolder_mc.cont_mc.adpoHolder_mc.attachMovie(adpo1,adpoSF,this.getNextHighestDepth());
}
Basicly I created a holder within a couple of movies and Im trying to attach a symbol who has a linkageID of "adpo1", then I call the function in a "on release" action in a button:

Code:

on (release) {
if (_root._currentframe !== (2)) {
_root.gotoAndStop(2);
_root.logo_mc.gotoAndPlay(1);
_root.sceneHolder_mc.gotoAndPlay("s2");
_root.sceneHolder_mc.contHolder_mc.cont_mc.gotoAndStop(2);
_root.sceneHolder_mc.contHolder_mc.cont_mc.Bene_txt.gotoAndStop("FFM");
_root.AdpoFunc();

for some reason is not working, can anyone send me a tip, or tell me what am I doing wrong?????

Thanks

Okay, How Do I Stop An FLV Loading With Attachmovie Method
I have seen this question asked a couple different places. But I am yet to see the answer.

I am creating dynamic FLVPlayback componenets on my page with attachmovie.

Once I start loading paused FLV files into these components, the system sits trying to load one at a time for about 3 minutes.

How can I get the movies to stop their load after a couple seconds worth? (But not kill or replace the partial loaded, paused flv)

I have tried:
if (myVideo.bytesLoaded > 10000) {myVideo.close();}

or

if (myVideo.bufferTime > 2) {myVideo.close();}

but had no success. Anyone?

Ron R.

[AS1] .attachMovie Method To Load Images
I am creating a gallery that loads the images from the library. The only method that I managed to do this is by creating movie clips that contain each of those images and then calling those movie clips from the library using the .attachMovie method because this method only works for movie clips and not instances of other library items such as actual images.

Is there anyway in ActionScript to create an instance of an image asset in the library?

Preloader Takes More Time To Come An FLA Using AttachMovie Method
Hi,

I've a movie with two scenes. First scene is preloader and the second is main movie.
//-----------
The preloader scene containes two frames. In the first frame using ifFrameLoaded () method is calling to check whether the main movie is loaded or not. In the second frame gotoAndPlay (1) to make a loop, until the main scene that is the second scene is loaded.
//------

I hope the above portion is clear. Let us move to the second scene

//---------
In the second scene a library file (a movie clip with a linkage ID ) calling to a movie clip on the stage using attachMovie () method.
Everything is working fine. Export in first frame is checkd in the linkage ID Dialogue box
//------

The problem is preloader comes after half the portion of movie is loaded. So a blank appears for a long time and suddenly shifted to the main scene.

Pls find the attached ZIP File

Preloader Takes More Time To Come An FLA Using AttachMovie Method
Hi,

I've a movie with two scenes. First scene is preloader and the second is main movie.
//-----------
The preloader scene containes two frames. In the first frame using ifFrameLoaded () method is calling to check whether the main movie is loaded or not. In the second frame gotoAndPlay (1) to make a loop, until the main scene that is the second scene is loaded.
//------

I hope the above portion is clear. Let us move to the second scene

//---------
In the second scene a library file (a movie clip with a linkage ID ) calling to a movie clip on the stage using attachMovie () method.
Everything is working fine. Export in first frame is checkd in the linkage ID Dialogue box
//------

The problem is preloader comes after half the portion of movie is loaded. So a blank appears for a long time and suddenly shifted to the main scene.

Pls find the attached ZIP File

AttachMovie Problem; The Loaded Movie's Method Cannot Be Working
Hi

I've loaded a MovieClip from library usibg attachMovie () method that is triggering by clicking on a button

I want to start the "oaded MC"playing (play ()) method.

But that is not working.,

//--------------------------
on (release) {

_root.container.attachMovie ("butterfly", "butterflynew", 2);
//trace (typeof (butterflynew));

_root.butterflynew.gotoAndPlay ("start");
}

//-----------------------------

Pls find the attached Zip file

Anybody to help me

Abhilash

AttachMovie Problem; The Loaded Movie's Method Cannot Be Working
Hi

I've loaded a MovieClip from library usibg attachMovie () method that is triggering by clicking on a button

I want to start the "oaded MC"playing (play ()) method.

But that is not working.,

//--------------------------
on (release) {

_root.container.attachMovie ("butterfly", "butterflynew", 2);
//trace (typeof (butterflynew));

_root.butterflynew.gotoAndPlay ("start");
}

//-----------------------------

Pls find the attached Zip file

Anybody to help me

Abhilash

Function In A Method Return True To Method's Caller?
I think I probably don't know the correct terminology to ask this question, but here goes:

In this example, can anyone tell me how to have the setComplete event function within the main method return true to the caller of the method, instead of just to the listener?


PHP Code:



    function loadAsset(target:MovieClip, asset:String, assetLoaderInfo:LoaderInfo): Boolean    {    var assetLoader:Loader = new Loader();    var assetURLRequest:URLRequest = new URLRequest(asset);    assetLoader.contentLoaderInfo.addEventListener(Event.OPEN, setLoaderInfo);    assetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, setComplete);    function setLoaderInfo(event:Event)        {        assetLoaderInfo = event.currentTarget;        }    function setComplete(event:Event)        {        target.addChild(assetLoader);        return true;        }    assetLoader.load(assetURLRequest);    }

Function In A Method Return True To Method's Caller?
I think I probably don't know the correct terminology to ask this question, but here goes:

In this example, can anyone tell me how to have the setComplete event function within the main method return true to the caller of the method, instead of just to the listener within the method?

Many thanks!


PHP Code:



function loadAsset(target:MovieClip, asset:String, assetLoaderInfo:LoaderInfo): Boolean
    {
    var assetLoader:Loader = new Loader();
    var assetURLRequest:URLRequest = new URLRequest(asset);
    assetLoader.contentLoaderInfo.addEventListener(Event.OPEN, setLoaderInfo);
    assetLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, setComplete);
    function setLoaderInfo(event:Event)
        {
        assetLoaderInfo = event.currentTarget;
        }
    function setComplete(event:Event)
        {
        target.addChild(assetLoader);
        return true;
        }
    assetLoader.load(assetURLRequest);

    }

[AS2 OOP] Calling A Method In A Method
Hi everyone
i'm not quite sure how to phrase my problem, so i'll examplify:

Code:
class A{
function A(){
trace("construct");
}
private function moo(){
trace("moo!");
}
private function cow(){
trace("start mooing");
moo();
}
}
this does what I expect it to: construct, start mooing, moo!

Code:
class A{
function A(){
trace("construct");
}
private function moo(){
trace("moo!");
}
private function cow(){
trace("start mooing");
_root.onEnterFrame = function(){
trace("moo!")
}
}
}
this also does what I expect it to: construct, start mooing, moo!, moo!, moo!, ...

Code:
class A{
function A(){
trace("construct");
}
private function moo(){
trace("moo!");
}
private function cow(){
trace("start mooing");
_root.onEnterFrame = function(){
moo();
}
}
}
yet this doesn't, I'd expect it to: construct, start mooing, moo!, moo!, moo!, ...
yet the moo! moo! moo! doesn't appear, as if moo() never gets called it all.
so what I'm I doing wrong?

AttachMovie() Within Another AttachMovie() Created Instance?
I'm still struggling away on my web site, but I've made quite a bit of progress and I think my code has cleaned up quite a bit. I still have the issue of not being able to attach my new content box movie clip when the button is pressed. I am successfully able to load the data for that instance of the tab, and can access the variables. It also is able to run the newContentBox() function inside it with success, but when it tries to run attachMovie(), nothing happens. Could this be a problem with my depth? Or is it my nesting?

I have been thinking about making a global variable for depth that will increment each time anything is created, so every movie clip is guaranteed to be on its own depth. Would this be a solution?

The site can be viewed here.
The source can be viewed here.
All the data files are located in that directory as well.

This is really driving me nuts, and I want to get something solved so I can move onto the submenu creation.

AttachMovie Inside Another AttachMovie
is it possible to attach a movieclip, and then attach another inside of it? i'm trying to load in images via using loadMovie and XML (a little background) i want the image to be dropped in to have a mask applied to it so that the image appears as a rounded rectangle... here's my code for the for loop that attaches the movie clips...


PHP Code:



for (i=1; i<=totalImages; i++) {
                attachMovie("multiplebox", "box_"+i, i);
                movieNamer=_root["box_"+i];
}




is it possible to attach a movie inside of 'box_"+i'?

AttachMovie Within An AttachMovie? Not Working
So I've finished a project (let's call it Project Blue) where I use attachMovie which references a folder (of swf's) to place each page of the swf. It worked fine. Next, I made a master 'shell' to place this project (among others) into. To do that I used attachMovie again to place Project Blue in the shell.

But now my attachMovie pages for Project Blue won't show up. Does Flash have a problem with using an attachMovie within an attachMovie?

Thanks for any insight on this....

AttachMovie Nested AttachMovie...
I have in the root timeline an empty movie clip that loads other movies inside of it. Using the attachMovie function.

Inside one of these attachMovie clips I have a nest "attachMovie" clip as well but for some odd reason it's not working. Is there anything I should be aware of when nesting an attached movie?

For... In ... Method
Hi all,
I have some problem with the

for( iterator in Object ) method

because it iterates on my Object returning properties in reverse order
In other words if I define a Object Person with

Fabio = new Person()

function Person(){
firstName = "Fabio"
birthday = "28-10-1970"
eyesColor = "Blue"
}

and then I use

for (i in Fabio){
trace(Fabio[i])
}

this method returns my Object properties in reverse order

eyesColor
birthday
name

instead of

name
birthday
eyesColor

Is there anyone who can tell me if it is possible to get my Object properties in the same order i defined them?

Any help will be very appreciated

GET Method
I have a PHP script that need two variables...
what is the correct syntax in flash ?



on (release) {
Status = "Beginning registration Process... Please Hold";
loadVariablesNum ("Register.php?RegName="+RegName ????&???? RegPassword="+RegPassword, 0);

}

thnx

A Method Of Self Help
This may sound odd, but for those who are budding flash developers, I think I found a way (aside from buying books and what not) to learn Flash MX commands rather well.

Open Flash MX, Press SHIFT+F1 (Reference), open the INDEX on the left, and one by one click on each and READ!

I've been doing this and what makes it all sink in is that I am writing what I read into a notepad file. The process of both reading and writing (seeing and doing) makes remember not only that object easier, but you know expand your thinking process when a problem presents itself.

Like you can get a eureka moment if a problem exists, and since you remember better what you read, you have an increased chance of formulating an answer with code.

Not only that, but you should try the code out. Set aside some time to test the code you're a little iffy on, and if that doesn't work, do a google search on ACTIONSCRIPT and the keyword you're having problems with.

I'm a forgetful person, and I've been doing these steps and learning SO MUCH. Hopefully it'll work well for others too.

& In Get Method
Hello!

I need to pass some text to display it in my .swf movie i'm using loadVariables to do this: http://myserver.com/content.php?id=1 but in this text there are some Baltic characters like õ, now php outputs it like this: text=ettev& #245;te and when my movie sees the & it treats it like another variable for example: text=tettevote&id=1 here are two variables text and id.

Is there a way around this?

Method In Other Method
Why if I call a method "makeFunction()" it works and if I call the same method fro the method "Down()" it doesen't work?

dynamic class SingleMovieClipEvents extends MovieClip {
private var movieClipPath_mc;
private var functionName;
private var args_array:Array;
private var theFunc;
public function SingleMovieClipEvents(mC:MovieClip, funNa, args:Array) {
functionName = funNa != undefined ? funNa : null;
args_array = args != undefined ? args : null;
movieClipPath_mc = mC != undefined ? mC : this;
setMovieClip();
makeFunction();
}
private function setMovieClip() {
movieClipPath_mc.onRelease = Down;
}
private function Down() {
this.gotoAndStop("down");
makeFunction();
}
private function makeFunction() {
if (functionName) {
theFunc = eval(functionName);
theFunc.apply(this, args_array);
}
}
}

WHAT's The Best Method? . . . .
Best Method for Text ?:

Ok, need a bit of help from some flash experts with a fair few applications under their belt, particularly ones that involved formatted text.

I’ve making an interface (application) that has about 6 different sections, video, multimedia, art, noise, bio’s and poetry text. So far i’ve basically got a “thumbnail” that you click, it then goes to the corrosponding frame in that scene and the movie/file needed loads into a movie/instance in that frame called “blank” (pretty creative naming huh? ;-)).

The interface its self is fairly bais, it stay with the style of graffiti and all things load on a brick wall, using graf fonts and a few tags etc. Most things work fine except for a few hiccups.

My problem is this:

I now have about 250-300 poems to get in to the interface, all with rich formatting (bold, italics, spacing, diff size fonts, etc) and all sent as DOCS. My thoughts were to do the following:
Convert all into RTF files using Appleworks (yes, I’m on a mac) or a similar converter (Vinc seems ok), import each one into Freehand since it seems to preserve most RTF and then bring the resulting SWF file into FLASH, paste it into a basic movie that has a simple scroll bar and then export that movie and name it appropraitely, move onto the next one . . .

I know it’s possible to load fomatted text into Dynamic text boxes from text files but I’ve so far not been able to get a handle on this (am using Flash MX) and I’m not sure it would be able to handle the “aligning” spaces, etc involved. The reason I’m using a scroll bar is that some poems are very long and won’t fit on the “WALL”, otherwise I’d just paste them in a graffiti font and leave it there.

Anyway, could ppl let me know of any pitfalls they see in this method, problems, etc or if anyone knows a better way (or has or has seen any examples of one) then please let me know. Have to get started on this soon and don’t want to be half way through it when some expert points out a brilliant stylish method that I hadn’t thought of that then makes me tear my hair out.

Thanks very much for any help or advice on this, it is GREATLY APPRECIATED.

Cheers

scart

Which Is The Best Method
Hi,

I would like to know, does anyone have any suggestions as to the best way to create a flash video gallery that can be used in a website.

I would welcome any samples or tutorials that may be available.

I would appreciate it very much.

Cheers

Best Method For:
Got a project I need help with and I need to know if the fallowing is possible and if so what would be the best method for accomplishing it.

Need:
Virtually I need to know how to build a small flash GUI that allows users to name their so called "projects" then click a button ("Build") that will copys/pastes a directory and name this copy what ever the user called it on this flash GUI.

Of course this Flash GUI will have to reside in the same folder as the directory its going to be duplicating. I just need to know if I should be looking at XML help or PHP or if action script might be able to do the whole copy and paste while naming actions.

Thanks.

Best Method For This?
hi all, im just creating a quick thing for my dad which has lots of objects on the stage and when the user hovers over an object he wants the object to turn red (50% tint) (the object can also be clicked to go to a different frame)
would it be best to have them all just as buttons, or as movieclips and addEventListeners to them all to the one function?
or is there a different way?
thanks
Dan

Key Hit Method?
Ive got this Key class, to replace what was lost with AS2 (Using AS3):


Code:
// Key.as
package {

import flash.display.Stage;
import flash.events.Event;
import flash.events.KeyboardEvent;

/*
* The Key class recreates functionality of
* Key.isDown of ActionScript 1 and 2. Before using
* Key.isDown, you first need to initialize the
* Key class with a reference to the stage using
* its Key.initialize() method. For key
* codes use the flash.ui.Keyboard class.
*
* Usage:
* Key.initialize(stage);
* if (Key.isDown(Keyboard.LEFT)) {
* // Left key is being pressed
* }
*/
public class Key
{

private static var initialized:Boolean = false; // marks whether or not the class has been initialized
private static var keysDown:Object = new Object(); // stores key codes of all keys pressed
private static var keysReleased:Object = new Object();
private static var wasPressed:Boolean = false;



/*
* Initializes the key class creating assigning event
* handlers to capture necessary key events from the stage
*/
public static function initialize(stage:Stage)
{
if (!initialized)
{
// assign listeners for key presses and deactivation of the player
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed);
stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
stage.addEventListener(Event.DEACTIVATE, clearKeys);

// mark initialization as true so redundant
// calls do not reassign the event handlers
initialized = true;
}
}

/*
* Returns true or false if the key represented by the
* keyCode passed is being pressed
*/
public static function isDown(keyCode:uint):Boolean
{
if (!initialized)
{
// throw an error if isDown is used
// prior to Key class initialization
throw new Error("Key class has yet been initialized.");
}
return Boolean(keyCode in keysDown);
}

public static function isPressed(keyCode:uint):Boolean
{
if (!initialized)
{
// throw an error if isDown is used
// prior to Key class initialization
throw new Error("Key class has yet been initialized.");
}
if (wasPressed == false)
{
return Boolean(keyCode in keysDown);
wasPressed = true;
}else{
return false;
}
}

public static function isReleased(keyCode:uint):Boolean
{
if (!initialized)
{
// throw an error if isDown is used
// prior to Key class initialization
throw new Error("Key class has yet been initialized.");
}

return Boolean (keyCode in keysReleased);

}


public static function clearKeysPressed():void
{
keysDown = new Object();
}

/**
* Event handler for capturing keys being pressed
*/
private static function keyPressed(event:KeyboardEvent):void
{
// create a property in keysDown with the name of the keyCode
keysDown[event.keyCode] = true;

}

/**
* Event handler for capturing keys being released
*/
private static function keyReleased(event:KeyboardEvent):void
{

if (event.keyCode in keysDown)
{
// delete the property in keysDown if it exists
keysReleased[event.keyCode] = true;
delete keysDown[event.keyCode];

}

}

/**
* Event handler for Flash Player deactivation
*/
private static function clearKeys(event:Event):void
{
// clear all keys in keysDown since the player cannot
// detect keys being pressed or released when not focused
keysDown = new Object();
keysReleased = new Object();
wasPressed = false;

}
}
}
Anyone any ideas how i can add a Key Hit method, so it'll only register when the key is initially pressed, then it'll go back to false?

Best Method
For building my website, is it better to use getURL commands to load my other pages, or loadMovie commands and have it all be one happy .swf file?

AS3 Best Method
As of now, im using URLLoader to send a variable to a php file and use that to connect to mySQL, the php file then echos back an XML with the results. Once that is back in flash I parse it out and use the data. Once I receive the data my application begins to run extremely slow. I've removed the listener once the load has completed, i've tried loader.close(). So this is my question, is it possible to use the URLStream in this case? Will that have any effect? Or is there a better way to go about this. I'm only grabbing, as of now, about 10 values from the database, but there will be a lot more I need to get. So if it is lagging down to a crawl already, then something must be wrong.

There Is No Method With The Name ?
I have an .as file with the code:

Math.getMiddle = function(a,b){

...

}

I have a .fla file that includes the .as file and then trys to run the methods in the .as file. I get the error:

**Error** Scene=Scene 1, layer=Layer 1, frame=1:Line 357: There is no method with the name 'getMiddle'.

Anyone help?

What's The Best Method? . . . .
Best Method for Text ?:

Ok, need a bit of help from some flash experts with a fair few applications under their belt, particularly ones that involved formatted text.

I’ve making an interface (application) that has about 6 different sections, video, multimedia, art, noise, bio’s and poetry text. So far i’ve basically got a “thumbnail” that you click, it then goes to the corrosponding frame in that scene and the movie/file needed loads into a movie/instance in that frame called “blank” (pretty creative naming huh? ;-)).

The interface its self is fairly bais, it stay with the style of graffiti and all things load on a brick wall, using graf fonts and a few tags etc. Most things work fine except for a few hiccups.

My problem is this:

I now have about 250-300 poems to get in to the interface, all with rich formatting (bold, italics, spacing, diff size fonts, etc) and all sent as DOCS. My thoughts were to do the following:
Convert all into RTF files using Appleworks (yes, I’m on a mac) or a similar converter (Vinc seems ok), import each one into Freehand since it seems to preserve most RTF and then bring the resulting SWF file into FLASH, paste it into a basic movie that has a simple scroll bar and then export that movie and name it appropraitely, move onto the next one . . .

I know it’s possible to load fomatted text into Dynamic text boxes from text files but I’ve so far not been able to get a handle on this (am using Flash MX) and I’m not sure it would be able to handle the “aligning” spaces, etc involved. The reason I’m using a scroll bar is that some poems are long and won’t fit on the “WALL”, otherwise I’d just paste them in a graffiti font and leave it there.

Anyway, could ppl let me know of any pitfalls they see in this method, problems, etc or if anyone knows a better way (or has or has seen any examples of one) then please let me know. Have to get started on this soon and don’t want to be half way through it when some expert points out a brilliant stylish method that I hadn’t thought of that then makes me tear my hair out.

Thanks very much for any help or advice on this.

Cheers

scart

What Method Is This?
Hello all. I came across a cool newsfeed on
http://iblog.chubzz.com/ ANyone know how they did it..? its to the rigt asa you open up the site.

-R

Tried The Form Method?
assuming you know how to make a form in flash just have them enter their e-mail address and with the submit button add this

LoadVaribles ("/cgi-bin/formail.pl)

that should work or maybe learn how to add cookies to your site.

If this isn't the answer you where looking for maybe show me some of the code you have in place already.
Fox.

Try Two Method Of But None Works Well. Please Help
i got four button when press will play a number of 10 frames before loading a movie. i have try a few script already, but none works please help. below are the script.

first method:
on first frame: the "start" frame
show = false

on end frame"
show = true

on button:
on (release) {
gotoAndPlay ("start");
if (_root.show == true) {
loadMovieNum ("intro.swf", 1);
}
}
for this script nothing happen when it reach the frame with the show = true on it.

second method:
on button:
on (release) {
_root:a = "a";
gotoAndPlay ("start");
}

on last frame:
if (_root:a =="a") {
loadMovieNum ("intro.swf", 1);
}
for this method, it works in the begin. but i got four button so when i play the movie, it seem like all the movie just anyhow loads. when i press "intro", it play "event", when i press "event", it plays "main page"

please help any method to use

Best Transition Method
Although there are many ways what is the best way to transition.

Stripped down example would be having three balls-red, blue, and yellow. Clicking on the red ball enlarges it. Clicking on the blue ball enlarges it and reduces the red ball. Clicking on the yellow ball enlarges it and reduces the blue ball and so and so on.

I figure this principle should also apply to page and mc transitions.

Like I said I've seen many ways to do this but what is the cleanest, most efficient.

Tx,
slhangen

HitTest Method
I know that there are 2 formats that can be used for the hitTest method.

anyMovieClip.hitTest(x, y, shapeFlag);
anyMovieClip.hitTest(target);

I drew 2 circles on the stage. I make the first one draggable. How do I use the first format to hitTest? I wanna use the first method because I can set the shapeFlag. What I do not understand is what x and y values to put in.

Just Like To Check If This Method Is Available?
hi, i was wondering if i can control the % of hit of a frame, eg:

i made a game wheel of forture, and have 51 frame in it. i put a random gotoandstop action in frame 1, and wanted to control the hitrate of frame 10 so that it will not be so easily to hit that frame maybe say out of 100%, only got 10% of chances to hit that frame.

is that possible?

Best Learning Method....
Hey!

I'm sure this is a very redundant question, but what is the best method to getting very fluent in Flash? I have read thru the Visual Quickstart book and the built in tutorials, but is there a good method to follow to get very good at Flash? I've followed some of the tutorials here, but I sometimes find myself attempting ones that are way past my ability.

Thanks in advance!
Lee

Key IsDown Method In SWF
hello,

does Key.isDown(Key.LEFT) method work in a browser?
it doesn't seem to in my movie...

does anyone know how to?

thanks

reynard

Possible Alternate Method?
Take a look:

for (n=0; n<2; n++) {
duplicateMovieClip ("mc", n, n);
setProperty (n, _x, n._x + (n+1)*50);
set ("text" add n, n._x);
}

I would prefer naming the duplicated MCs: mc0, mc1, etc... but then I can't seem to get the setProperty to work--I've already tried several methods, but it doesn't wanna fly. Here's another:

on (rollOver) {
swapDepths(_root.top);
_root.top=_name
}

This code is in a button in above MC. I'm currently using a different method that uses levels rather than targets, but I'd like this to work (yes _root.top is defined before this is run). Why won't this go?
Thanks in advance...


B

Animation Method
I was wondering what methods were used when getting ready to do an animated short (or not-so-short).

I'm a complete novice with animation, the most I've ever done really was mini flip books.

Having enough trouble actually drawing, I find it even more difficult to animate in Flash while keeping perportions correct, and many other aspects that I find it difficult to name or describe.

What do you do when getting to animate people?

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