Adobe Dreamweaver Forums



Last 10 THreads :         Drop-Down Boxes showing blank (Last Post : karimc - Replies : 2 - Views : 3 )           »          Color query, at specific point on screen (Last Post : atta707 - Replies : 4 - Views : 5 )           »          Get Locale country and language codes (Last Post : PaulH **AdobeCommunityExpert** - Replies : 21 - Views : 22 )           »          Odd.... (Last Post : steve grosz - Replies : 2 - Views : 3 )           »          Spry Tabbed Panels - Start with no default tab?? (Last Post : rhore - Replies : 0 - Views : 1 )           »          Flash Player 10 compatibility (Last Post : Captiv8r - Replies : 3 - Views : 25 )           »          Connecting to a Database (Last Post : sugar_d - Replies : 5 - Views : 6 )           »          Cannot import audio into Captivate 3.0 (Last Post : Captiv8r - Replies : 1 - Views : 2 )           »          dynamic table rows created based on input value (Last Post : AthroughZ - Replies : 4 - Views : 12 )           »          How to communicate between clients? (Last Post : yancaoshi - Replies : 9 - Views : 12 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Other Macromedia/Adobe Products > Flash > Actionscript 3
 
Tags:



Reply
  #1 (permalink)  
Old 10-06-2008, 02:31 PM
Richard Ragon
 
Posts: n/a
Diggs:
Default button test

Greetings,

Been experimenting with AS3 here. I've created a project with a
Document Class named "Main" and only a single MC in it named "Button_MC"
and linkage. Inside that Button_MC, I have a timeline with a couple of
stop()'s for some animation.

Here's my code (Main.as):
package {

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

public class Main extends MovieClip {

// put main vars here

// Constructor
public function Main() {

// put add on stage stuff here
var button1:QuickButton = new QuickButton("Click Me");
addChild(button1);
button1.x = 100;
button1.y = 100;
button1.addEventListener(MouseEvent.CLICK, onClick);
button1.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
}

private function onClick(e:Event):void {
trace("hi");
}
private function onMouseOver(e:Event):void {
//button1.play();
}
}
}



Also here's my (QuickButton.as) too:
package {

import flash.display.*;
import flash.events.*;
import flash.text.*;

public class QuickButton extends MovieClip {

public function QuickButton(myText:String):void {

// put in the button
var btn:Button_MC = new Button_MC();
btn.buttonMode = true;
//btn.useHandCursor = true;
addChild(btn);
// put in the text feild
var tf:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0x000000;
format.size = 12;
format.align = "center";
tf.defaultTextFormat = format;
tf.selectable = false;
tf.text = myText;
tf.width = 100;
btn.addChild(tf);
}
}
}

So my AS3 places a single instance of "button1" on my stage. How do I
access this to play it's animation?

button1.gotoAndPlay(2) will not work?

thanks

-richard




Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-06-2008, 02:52 PM
kglad
 
Posts: n/a
Diggs:
Default Re: button test

that should work if used in Main and if you want a reference accessible on your main timeline, pass one, for example, using a getter.
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 10:14 PM
Richard Ragon
 
Posts: n/a
Diggs:
Default Re: button test

kglad wrote:
> that should work if used in Main and if you want a reference accessible on your main timeline, pass one, for example, using a getter.


Greetings kglad,

The problem actually is.. that I can't get the timeline of my MC created
in flash, to play..

If you notice here:

---
private function onMouseOver(e:Event):void {
button1.play();
}
---

So, I tried some defferent angles.. I tried moving my "play()" to
QuickButton.as as a function.

I tried

1) this.play(); // won't play
2) btn.play(); // won't play
3) gotAndPlay(2); // won't play
4) this.gotoAndPlay(2); //won't play
5) btn.gotoAndPlay(2); // won't play
6) gotoAndPlay(2); // won't play..

I create a Movie Clip in the Library. I named it "Button_MC". Linked
it. Instantiated it inside QuickButton.as like this...

var btn:Button_MC = new Button_MC();

but I can't get it to play the time line?

I also tried to label it too..

I'm thinking this is a bug, and perhaps documented right here..
http://www.scottgmorgan.com/blog/ind...r-gotoandplay/


Bummer..

-Richard
Reply With Quote


  #4 (permalink)  
Old 10-06-2008, 11:43 PM
kglad
 
Posts: n/a
Diggs:
Default Re: button test

that's not a bug. that's an unsophisticated flash user that's failed to understand the render sequence in as3.

are you trying to reference an object in frame after a goto or play method?
Reply With Quote
  #5 (permalink)  
Old 10-07-2008, 11:50 AM
Richard Ragon
 
Posts: n/a
Diggs:
Default Re: button test

kglad wrote:
> that's not a bug. that's an unsophisticated flash user that's failed to understand the render sequence in as3.
>
> are you trying to reference an object in frame after a goto or play method?


No, I guess your right.

I'm just trying to get a MC (created in Flash in the Library) timeline
to play from using AS3.

-Richard
Reply With Quote
  #6 (permalink)  
Old 10-07-2008, 05:32 PM
Richard Ragon
 
Posts: n/a
Diggs:
Default Re: button test

Richard Ragon wrote:
> kglad wrote:
>> that's not a bug. that's an unsophisticated flash user that's failed
>> to understand the render sequence in as3.
>>
>> are you trying to reference an object in frame after a goto or play
>> method?

>
> No, I guess your right.
>
> I'm just trying to get a MC (created in Flash in the Library) timeline
> to play from using AS3.
>
> -Richard


Well.. Day 3 now, of just trying to get a MC to play an animation time
line using AS3. So, I decided to dedicate all my free time on this bug
now.. So, I striped down a simple project, just to illustrate the problem.

1) Create a .fla file.
2) Create a MovieClip manually and name it "Box", and place it in the
Library. On the timeline of this MC, it has a stop(), 10 frames of some
animation, and it goes back to the stop() again.
3) Name the Document Class "Timeline".
4) Create a new .as file, call it "Timeline.as"
5) Copy this text into it.

--- cut ---
package {
import flash.display.*;
import flash.events.*;

public class Timeline extends MovieClip {

public function Timeline():void {

var myBox:Box = new Box();
myBox.y = 100;
myBox.x = 100;
myBox.addEventListener(MouseEvent.ROLL_OVER,move_b ox);
this.addChild(myBox);
}

private function move_box(e:Event):void {
myBox.play(2); // this fails??? don't know why
};

} //class
} // package
--- end ---

No matter what.. I can NOT get the myBox MC to play it's animation??

The funny thing is.. It works if you get rid of this document class, and
place all the AS3 on the frame instead.. But, I'm trying to learn AS3,
doing it the right way using document classes with AS3 all on the outside..

I can see why people are just not going to move to AS3, from AS2. Days
and days of trying to just do simply crap, like play a timeline..

I've also found some discussions on the matter too..


http://www.actionscript.org/forums/a.../t-140171.html

Thanks
-Richard

Reply With Quote


  #7 (permalink)  
Old 10-07-2008, 05:32 PM
kglad
 
Posts: n/a
Diggs:
Default Re: button test

there's no bug. there's are coder errors, though.

1. you made myBox local to the constructor so it's not available in the
class: the var and declare myBox as a class variable.

2. there's no argument in the play() method. use gotoAndPlay() if you want
to direct the timeline to a particular frame. (though in your case, play() is
adequate.)


Reply With Quote
  #8 (permalink)  
Old 10-07-2008, 11:32 PM
Richard Ragon
 
Posts: n/a
Diggs:
Default Re: button test

kglad wrote:
> there's no bug. there's are coder errors, though.

Ok,


> 1. you made myBox local to the constructor so it's not available in the
> class: the var and declare myBox as a class variable.


Lost me here??


> 2. there's no argument in the play() method. use gotoAndPlay() if you want
> to direct the timeline to a particular frame. (though in your case, play() is
> adequate.)


gotoAndPlay() will be used on the final project.. I just used play() as
a quick example.

-Rich
Reply With Quote
  #9 (permalink)  
Old 10-08-2008, 04:17 AM
kglad
 
Posts: n/a
Diggs:
Default Re: button test

1.:

package {
import flash.display.*;
import flash.events.*;

public class Timeline extends MovieClip {
var myBox:Box;
public function Timeline():void {

myBox = new Box();
Reply With Quote


  #10 (permalink)  
Old 10-09-2008, 10:32 AM
Richard Ragon
 
Posts: n/a
Diggs:
Default Re: button test

kglad wrote:
> 1.:
>
> package {
> import flash.display.*;
> import flash.events.*;
>
> public class Timeline extends MovieClip {
> var myBox:Box;
> public function Timeline():void {
>
> myBox = new Box();


Am, I missing something here? This is exactly what I have in my example
that I gave you???

-rich
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 03:20 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Inactive Reminders By Mished.co.uk