Skip to main content
Participant
March 4, 2013
Answered

linking .swf or .fla to flash?

  • March 4, 2013
  • 3 replies
  • 1599 views

I have these three files in the folder:

Character-Animation.swf

Character-Animation.fla

Viz.as

MovieClip in the libarary save as: vishh

Output the way I want is stage should be EMPTY and animation play on a MOUSE CLICK.

this is the current code I have worked on...

package

{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

   

    public class Viz extends MovieClip

    {

        public function Viz()

        {

           

            stage.addEventListener(MouseEvent.CLICK, onClick);

        }

        function onClick(event:MouseEvent):void

        {

           

            // code...

        }

    }

}          

I am a beginner to this, please help!!!

This topic has been closed for replies.
Correct answer kglad

to make make all class instances play when the stage is clicked you would use:

package

{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    public class Viz extends MovieClip

    {

        public function Viz()

        {

            stage.addEventListener(MouseEvent.CLICK, onClick); // if you want this object to play when it is clicked, use this instead of stage.

        }

        function onClick(event:MouseEvent):void

        {

            this.play();

        }

    }

}          

////////////////////////////////////

if you wanted all Viz instances to be invisible until the stage is clicked and then you wanted them to become visible and play, you could use:

package

{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    public class Viz extends MovieClip

    {

        public function Viz()

        {

            this.visible=false;

            stage.addEventListener(MouseEvent.CLICK, onClick);

        }

        function onClick(event:MouseEvent):void

        {

            this.visible=true;

this.play();

        }

    }

}          

3 replies

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 5, 2013

to make make all class instances play when the stage is clicked you would use:

package

{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    public class Viz extends MovieClip

    {

        public function Viz()

        {

            stage.addEventListener(MouseEvent.CLICK, onClick); // if you want this object to play when it is clicked, use this instead of stage.

        }

        function onClick(event:MouseEvent):void

        {

            this.play();

        }

    }

}          

////////////////////////////////////

if you wanted all Viz instances to be invisible until the stage is clicked and then you wanted them to become visible and play, you could use:

package

{

    import flash.display.MovieClip;

    import flash.events.MouseEvent;

    public class Viz extends MovieClip

    {

        public function Viz()

        {

            this.visible=false;

            stage.addEventListener(MouseEvent.CLICK, onClick);

        }

        function onClick(event:MouseEvent):void

        {

            this.visible=true;

this.play();

        }

    }

}          

Participant
March 6, 2013

omg Amy your idea help as well as kglad....you guys made it seem so easy.

yes I worked around those two idea thanks alot for help ...solved my problem.


looking forward to do more ...reading books and more research!!!

kglad
Community Expert
Community Expert
March 6, 2013

if this is a classroom project, you may be dinged for using a timeline solution like amy's.

Amy Blankenship
Legend
March 5, 2013

Probably the easiest thing is to have an empty keyframe in frame 1, and viz in frame 2 and then the code you would need in your mouse click handler would be:

nextFrame();

kglad
Community Expert
Community Expert
March 5, 2013

is there anything in your fla associated with Viz??

Participant
March 5, 2013

fla is just my regular project, and from that I created a MovieClip (which saved in library name as biz). "Viz" is a class name for my object or sysmbol.

then I go to my actual stage (timeline) and delet all the frames since I want stage to be empty and animation start on a mouse click.

after that I created ActionScript 3 name as "Viz" and type this code as u see...and where it says:

"//code..."  I have to write code which will call, that specific MovieClip or swf file to play/run.

...so far my professor said "I am on right track" ...I am just lost how can I link something or make it invisible and make it visible on mouse click. (I don't want any buttons, just empty clear stage waiting for MOUSE EVENT)...