Additional Info
|
I am trying to load a external swf but its not happening
Below is the code I am using to load & access external swf Code: [Select] import flash.events.KeyboardEvent; after testing the swf I am getting the following out put errorsCode: [Select] ReferenceError: Error #1065: Variable soundFX_7 is not defined. how can this be resolved. |
Additional Info
|
Ask yourself these questions:
I assume the code you tested is exactly the same as the one you've posted. If that's not the case, and the url for the swf you're trying to load is in another location, that might cause the errors. Providing the swf would help me pinpoint the cause of the errors. Also, remove the second semicolon in "mcAnk.gameVars.changeLevel();;". |
Additional Info
|
Problem: The class TouchEvent doesn't exist in Flash Player 9 and earlier.
Solution: Set the Flash Player version in as3.fla to 10+. |
Additional Info
|
Quote from: "kavya" thanks, now game is loading but when pressed the key getting error asThat's because the function is either not accessible (private/protected) or doesn't exist in the class. |
Additional Info
|
Quote from: "kavya" The function ClickedNext exist in a class named Game and its publicTry Google. I may look into it later, as I would also like to know if it's possible / how to do it. Edit: this looks interesting. Edit2: Download the file below (broken image removed) Pressing "1" resets the timer. |
Additional Info
|
Thanks man its working,
can you tell me how it done apart from the attachments in detail, it would be helpful for me further How can I use the same for future .swf loading & what are the points I need to take into consideration while making key event |
Additional Info
|
Quote from: "kavya" Thanks man its working,When you use addChild to add the loader its class is MainTimeLine, which, in this case, didn't contain the code we needed. To set the timer we need to call a function from the instance of the Timer class in the Game class. Using ApplicationDomain you can create a new instance of the Game class, however that would be futile, as it wouldn't affect the one in the game. Therefore, we need to find the document class (i.e. Main) through the MainTimeLine. We'll use the scanForChildren function in the attachment for this purpose by changing it from: Code: [Select] function scanForChildren(obj:DisplayObjectContainer, depth:int):void { to: Code: [Select] function scanForChildren(obj:DisplayObjectContainer, depth:int):void { What changed: depth > 5 => depth > 0 if(!child.name.indexOf("instance") == 0) And replace game with mcAnk in the following line in the keyListener function: Code: [Select] scanForChildren(game, 0); It'll find all the DisplayObjects in MainTimeLine - in this case only the instance of the Main class. To access it we need to call: Code: [Select] DisplayObject(mcAnk.getChildAt(0)) For other games you have to use the number given by the scanForChildren function.From here we access the variable game, which contains the variable timer we were looking for. The function we want to call on timer is Init and the parameter we need to give it is time_total (or however long we want for the level, which doesn't matter as we can reset it as many times as we like). Finally we get: Code: [Select] DisplayObject(mcAnk.getChild(0)).game.timer.Init(DisplayObject(mcAnk.getChild(0)).game.timer.time_total); Which can also be written as:Code: [Select] var game:DisplayObject = DisplayObject(mcAnk.getChild(0)); Note: the reason we can call these functions and variables is because they're public. We can't call functions such as GameCompleted in the class Game. |
Additional Info
|
(broken image removed) I have been looking for this from few days & finally I got here, thanks once again.
|
Additional Info
|
Hi KongregateHack
I tried to use the same code for keyevent on a external .swf & its throwing an error Code: [Select] TypeError: Error #1034: Type Coercion failed: cannot convert flash.display::Sprite@2de0f51 to flash.display.MovieClip. at as3_fla::MainTimeline/keyDownListener()[as3_fla.MainTimeline::frame1:24] Code: [Select] http://www.mediafire.com/?l1qcdcjo2prw5ne and also can you tell me whether the word used "game" in the loader is a variable define in the loader or its a class name exists in extenal .swf (Screen Snap Attached) (broken image removed) |
Additional Info
|
Quote from: "b_nany68" Hi KongregateHackSearch and replace "MovieClip" with "Sprite". It's used for typecasting, which may not be necessary, so you can try removing them and see if it still throws an error. Quote from: "b_nany68" and also can you tell me whether the word used "game" in the loader is a variable define in the loader or its a class name exists in extenal .swf (Screen Snap Attached)
|
Additional Info
|
Hi KongregateHack
when i replace MovieClip with Sprite the game is not loading and showing error Code: [Select] Scene 1, Layer 'Layer 1', Frame 1, Line 22 1119: Access of possibly undefined property LevelData through a reference with static type flash.display:Sprite. Code: [Select] Scene 1, Layer 'Layer 1', Frame 1, Line 28 1061: Call to a possibly undefined method unlockPage through a reference with static type flash.display:Sprite. Pls find attachmentCode: [Select] http://www.mediafire.com/?1p8nv6di8oi9836 |
Additional Info
|
bump
|