Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

how move main class to script in timeline

Participant ,
May 28, 2013 May 28, 2013

hi , in some component they use main class to load various as files

and when i see properties of my document i see the name of this class right down the Script : Action Script 3

whe i click on the pen ( edit ) of this class i see various codes about doing importing some AS files and ...

for example :

package {

   

    import flash.display.MovieClip;

    import flash.display.Sprite;

    import flash.events.Event;

    import flash.net.URLRequest;

    import flash.net.URLLoader;

    import flash.events.*;

    import com.Align;

    public class DocumentClass extends MovieClip {

       

        private var ***;

        public var ***;

        public var ***;

        public function DocumentClass() {

***

        }

       

        private function config():void {

***

        }

    }   

}

sometimes i want to use 2 or more component that use this technics and i can only choose and type the name one of them !! 

how can i put them all together or it will be better if possible to put class in script in timeline ...

TOPICS
ActionScript
801
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
May 28, 2013 May 28, 2013

import flash.display.MovieClip;

    import flash.display.Sprite;

    import flash.events.Event;

    import flash.net.URLRequest;

    import flash.net.URLLoader;

    import flash.events.*;

    import com.Align;

       

        var ***;

        var ***;

        var ***;

        function config():void {

***

        }

copy all the imports, get rid of the scope descriptions(private, public, protected etc.)

and delete the constructor.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
May 28, 2013 May 28, 2013

thanks for reply ...

do you mean i must copy all the imports AS file ?  so copy them to where ? and how can i link these files to my project ?

is there any setting in publish setting to put these AS in swf ( Internal ) or link them or i must use some script to do this ?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 28, 2013 May 28, 2013

Most import statements for built-in Flash classes are not necessary when you code in the timeline.  There are exceptions, such as possibly the Events, but most of the ones you show are not necessary since Flash can find them without the need to identify where.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 01, 2013 Jun 01, 2013

thanks Mr.Murphy

i try to remove package , private , public from class and move it to timeline as Script but no success at all !!

here is the Code and my menu :

http://www.jeffguthrie.com/drop-down-menu-with-as3

and here what i made at end :

import flash.display.MovieClip;

import flash.events.Event;

import flash.events.MouseEvent;

import flash.events.TimerEvent;

import flash.utils.Timer;

import com.greensock.*;

import com.greensock.easing.*;

         var _sMouseOver:MovieClip;

         var _sMenu:MovieClip;

         var _menuTimer:Timer;

         var _menuOpen:Boolean = false;

        function MouseOverMenu():void {

            addEventListener(Event.ADDED_TO_STAGE, init, false, 0, true);

        }

        function init(e:Event):void {

            _sMouseOver.buttonMode = true;

            _sMouseOver.addEventListener(MouseEvent.MOUSE_OVER, showMenu, false, 0, true);

            _sMouseOver.addEventListener(MouseEvent.MOUSE_OUT, startClose, false, 0, true);

            _sMouseOver.addEventListener(MouseEvent.MOUSE_OVER, cancelClose, false, 0, true);

            _menuTimer = new Timer( 50 );

            _menuTimer.addEventListener ( TimerEvent.TIMER, doCloseMenu );

            _sMenu.visible = false;

            _sMenu.alpha = 0;

            _sMenu.addEventListener(MouseEvent.MOUSE_OUT, startClose, false, 0, true);

            _sMenu.addEventListener(MouseEvent.MOUSE_OVER, cancelClose, false, 0, true);

        }

         function showMenu(e:MouseEvent):void {

            _menuOpen = true;

            _sMenu.visible = true;

            TweenLite.to(_sMenu, .5, {y:73, alpha:1});

        }

         function startClose ( e:Event ):void {

            //trace('startClose ' + e.target);

            _menuTimer.start();

        }

         function cancelClose ( e:Event ):void {

            //trace('cancelClose ' + e.target);

            _menuTimer.stop();

        }

         function doCloseMenu ( e:Event ) {

            closeMenu();

        }

         function closeMenu ():void {

            if ( _menuOpen ) {

                TweenLite.to(_sMenu, .5, {y:50, alpha:0, onComplete: hideMenu});

            }

            _menuTimer.stop();

            _menuOpen = false;

        }

         function hideMenu():void {

            _sMenu.visible = false;

        }

i really need this and i cant use Document class , thanks

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 01, 2013 Jun 01, 2013

If you look at the code you will see that it is all written into functions, but there is nothing of it that intiates calling any of those functions, so the code has nothing to do when you open the file.

It appears that maybe the init function you have is what needs to be executed to get things set up properly (that's usually what it would be for).  You have it assigned to be executed via the ADDED_TO_STAGE listener that appears to never get assigned since there is nothing to execute that function either.

So either try removing the Event argument from the init function definition and then try calling that function at the end of all you show and see if that gets things going, or, just move all of the init function content outside of the function so that it executes freely when the file loads.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jun 01, 2013 Jun 01, 2013
LATEST

thank so much Mr,Murphy for replay

i read your Guide many times and try , but it seems i cant success in this with this level of Knowledge ...

i think i must give it up and try some drop down menu , maybe

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines