The McLeodGaming forums were permanently closed on April 30th, 2020. You are currently viewing a read-only archive.
View unanswered posts | View active topics It is currently Fri May 15, 2020 1:57 am

Forum rules


IMPORTANT

This Forum is for Flash related questions ONLY! Do not ask questions about spriting, Game Maker, Photoshop, or anything else not related to Flash.



 [ 1 post ] 
[Question, AS3] Calling a class function from main timeline? 
Author Message
Site Moderator
User avatar

Joined: Fri May 22, 2009 3:44 pm
Posts: 4156
Location: saying things with posed looks
Gender: Anime Girl
Skype: Snail's Legacy
Currently Playing: umib and unib
Waifu: SNAIL
Well I've finally gotten used to AS3 a bit after years of trying, but I'm still having trouble.

See, I have this class, the document class, called Main.as:

Code:
package org.kos{
   import flash.display.MovieClip;
   import flash.events.Event;
   import flash.net.SharedObject;
   import flash.display.MovieClip;
   import flash.events.ProgressEvent;
   import flash.media.Sound;
   import org.kingofsmash.globalVars;
   import org.kingofsmash.itemGet;

   public class Main extends MovieClip {

      public static var saveData = globalVars.vars.saveData;


      public function Main() {
         // CONSTRUCTOR CODE //======================================


         addEventListener(Event.ENTER_FRAME, checkData);

         trace("Just testing, bruddah.");


         function checkData(evt:Event):void {

            if (! saveData.data.hasOwnProperty("profile")) {
               saveData.clear();
               saveData.data.profile = {percentClear:0,awards:0,gameTime:0,powercount:0,settings:{qual:"MED",BGM:75,SFX:100,controllers:{player1:{LEFT:37,UP:38,RIGHT:39,DOWN:40,punch:65,kick:73,grab:68,sheild:90,taunt:88,special:67,Start:32},player2:{},player3:{},player4:{}}}};
               var powercount:Number = saveData.data.profile.powercount;
               ++powercount;
               saveData.data.profile.powercount = powercount;
               saveData.flush();
            } else {
               ++powercount;
               saveData.flush();
            }
            function itemGet(typeIcon:Number, typeOf:String, typeInfo:String):void {
               //Types (In order):
               //1.warning
               //2.award
               //3.character
               //4.stage
               //5.setting
               alert.x = 0;
               alert.y = 0;
               alert.play();
               alert.Title.text = typeOf;
               alert.information.text = typeInfo;
               alert.ico.gotoAndStop(typeIcon);
            }
         }

      }

   }

}


and I'm trying to call the itemGet function from a frame on the timeline. I want to call it when I press a button, so I used this code:

Code:
import org.kos.Main;
button.addEventListener(MouseEvent.CLICK, alertMe);

function alertMe(evt:MouseEvent):void {
   var iG:Main = new Main();
   iG.itemGet(5, "Profile Get!", "Profile successfully created.");
}


The problem is, this error keeps showing up:

Code:
Scene 1, Layer 'Action', Frame 6, Line 23   1061: Call to a possibly undefined method itemGet through a reference with static type org.kos:Main.


I don't understand the problem, really. What am I doing wrong?

Any help would be appreciated really, I'm just tired of this headache.

_________________
Image

Image Image Image

early 2k nostalgia mode


Sun Jun 02, 2013 12:12 am
Display posts from previous:  Sort by  
 [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

cron
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software for PTF.